Bacebise ukubandakanya kwi-Linux kernel ukuphunyezwa ukuya kumaxesha angama-4 ngokukhawuleza kwe-memchr

Mva nje kwakhutshwa isindululo sekernel yeLinux, apho kucetywayo ukuba kufakwe iiseti zeepetshi ezine uphumezo olulungisiweyo lwe memchr () umsebenzi isetyenziselwa ukukhangela umsebenzi kuluhlu.

I memchr () umsebenzi uhlola i-n bytes ekhokelayo yendawo yenkumbulo eyalathwe ngo s ngokokuqala kwe c. Zombini ii-c kunye nee-bytes kwindawo yenkumbulo eyalathwe ngu-s zitolikwa njengoonobumba abangatyikitywanga.

Isindululo Izithembiso khawuleza ukukhangela umsebenzi kwibhloko yememori. Kwiimvavanyo zomphuhlisi, ukuphunyezwa okutsha kunokuba phantse amaxesha amane ngokukhawuleza kukhangelo olukhulu

Ngokungafaniyo noguqulelo lwangaphambili, olusebenzisa uthelekiso lwe-byte-byte, ukuphunyezwa okucetywayo kudalwa ngokuqwalasela ukusetyenziswa ngokupheleleyo kweerejista ze-CPU ze-64-bit kunye ne-32-bit. Esikhundleni se-bytes, uthelekiso lwenziwa ngokusebenzisa amagama omatshini, okuvumela ukuba ubuncinane ii-bytes ezi-4 zithelekiswe ngexesha.

Olu ngcelele lweepatches lulungiselele "memchr()" kwaye longeze i-macro ye
"memchr_inv()" ukuze yomibini imisebenzi ikwazi ukuyisebenzisa ukwenza i-bitmask.

Ukuphunyezwa kokuqala kwe "memchr()" kusekwe kuthelekiso lwe-byte,
engasebenzisi ngokupheleleyo irejista ye-64 okanye ye-32 kwi-CPU. Siphumeza a
uthelekiso ngamagama ukuze ubuncinane iibhayithi ezi-4 zithelekiswe ngokufanayo
imozulu. I-memchr () elungiselelweyo iphantse yakhawuleza kayi-4 kuneyokuqala
ngamatyathanga amade. KwiLinux Kernel, sifumanisa ukuba ubude bomtya
Ikhangelwe ngu "memchr()" ifikelela kwi 512 bytes kwi drivers/misc/lkdtm/heap.c.

Xa ukhangela kwiintambo ezinkulu, inguqulo entsha yajika yaba malunga namaxesha ama-4 ngokukhawuleza kunokudala (umzekelo, kwimitya enamagama ayi-1000). Kwimixokelelwane emincinci, ukusebenza kakuhle kokuphunyezwa okutsha akubalulekanga kangako, kodwa kusephezulu kunenguqulo yokuqala.

Into enomdla malunga nesindululo esitsha kukuphuculwa kwamatyathanga amakhulu, aphucula kakhulu amaxesha. Kufanelekile ukukhankanya ukuba kwi-Linux kernel, ubungakanani bemitya esetyenzisiweyo kwi-memchr () ifikelela kwi-512 bytes. Kwiimvavanyo zethu, ukuzuza ukusebenza kweentambo ze-512-byte, kwimeko apho umlingiswa wokukhangela isekupheleni komtya, yi-20%.

Kufanelekile ukukhankanya ukuba uguqulelo loqobo lwe-memchr () luphunyeziwe ngobuchule bothelekiso lwe-byte, olungasebenzisi ngokupheleleyo iirejista kwi-64-bit okanye 32-bit CPU.

Sisebenzisa uthelekiso lwamagama apheleleyo ukuze iimpawu ezisi-8 zithelekiswe ngaxeshanye kwi-CPU. Le khowudi isekelwe ekuphunyezweni kukaDavid Light.

Senza iifayile ezimbini ukulinganisa ukusebenza kwefayile yokuqala equlathe i-avareji yoonobumba abali-10 ngaphambi kombhalo wendawo. Ifayile yesibini iqulathe ubuncinane 1000 amagama phambi kwe umlinganiswa ekujoliswe kuwo.

Ukuphunyezwa kwethu "memchr()" kancinci ngcono kuvavanyo lokuqala kwaye phantse amaxesha ama-4 ngokukhawuleza kunokuqala ukuphunyezwa kuvavanyo lwesibini.

Uvavanyo lwe-Kernel 5.18 olunotshintsho olutsha lwe-"memchr ()" lwe-32-bit kunye ne-64-bit ye-architectures. khange iveze naziphi na iingxaki.

Kwenzeka ntoni ukuba u-p akalungelelaniswanga u-8 (okanye u-4 kwi-32 bit target)? Ayizizo zonke iithagethi ezixhasa imithwalo engahambelaniyo (esebenzayo), akunjalo?
 Ndicinga ukuba iyasebenza ukuba u-p akahambelananga 8 okanye 4 byte. Masithi umtya ziibyte ezili-10. I-loop apha izakukhangela iibyte ezisi-8 zokuqala. Ukuba uphawu lokusingwa lukwi-bytes ezi-2 zokugqibela, eyesibini ye-loop iyakuyifumana. Ikwasebenza ngolu hlobo koomatshini be-32-bit.

Inzuzo yokusebenza iyonke ayikavavanywa yendlela ezisezantsi ze kernel xa usebenzisa eyonyuliweyo "memchr()" umahluko, kwaye akukaxoxiswanga nokuba kugqwethwa uphumezo (i memchr() umsebenzi umnxeba wenzeka amaxesha ali-129 kwikhowudi yekernel, ukuquka abaqhubi kunye neenkqubo zefayile).

Gqibela Ukuba unomdla wokwazi okungakumbi ngayo, ungajonga iinkcukacha Kule khonkco ilandelayo.


Umxholo wenqaku uyabambelela kwimigaqo yethu imigaqo yokuziphatha yokuhlela. Ukuxela impazamo cofa apha.

Yiba ngowokuqala ukuphawula

Shiya uluvo lwakho

Idilesi yakho ye email aziyi kupapashwa.

*

*

  1. Uxanduva lwedatha: UMiguel Ángel Gatón
  2. Injongo yedatha: Ulawulo lwe-SPAM, ulawulo lwezimvo.
  3. Umthetho: Imvume yakho
  4. Unxibelelwano lwedatha: Idatha ayizukuhanjiswa kubantu besithathu ngaphandle koxanduva lomthetho.
  5. Ukugcinwa kweenkcukacha
  6. Amalungelo: Ngalo naliphi na ixesha unganciphisa, uphinde uphinde ucime ulwazi lwakho.