C problem...se megethos domhs

John Tsiombikas (Nuclear / the Lab) nuclear at siggraph.org
Sun Jan 25 20:08:55 EET 2004


Aggelos Economopoulos wrote:
>>to file i/o einai buffered (an xrisimopoieis fwrite/fread klp) eite
>>kaneis ena fwrite() olo to struct mazi, eite kaneis 10 mikra fwrite()
>>gia kathe member ksexorista, to performance einai idio.
> 
> Elpizw na ennoeis /peripou/ idio, giati to performance katafanws *den*
> einai idio. An mia struct apoteleitai apo (p.x.) 10 32-bit integers,
> katalhgeis na kaneis 10 fwrite() (dhladh ta dekaplasia function calls)
> apla gia na doulepsei h stdio wste na ta balei pali se enan buffer kai
> na kalesei thn read(). Profanws se ena sunh8hsmeno programma, opou to
> i/o den einai to bottleneck, auto den prokeitai na epiferei metrhsimo
> slowdown, an omws h berkleydb kai h mysql xrhsimopoiousan apokleistika
> thn stdio 8a to eixan kleisei to magazi.

Koita na deis otan milame gia read/write se disko pou einai inherently argi 
diadikasia to function call overhead einai pragmatika ameliteo, eite ginoun 10 
function calls eite 100 den yparxei ousiastiki diafora. to bottleneck einai stin 
diadikasia tou I/O.
De nomizo oti kerdizeis kati me to na kaneis ousiastika to buffering monos sou 
kai na grafeis me write(), ase tin fwrite() na kanei ti douleia tis.

>>Kai mi mou les emena gia performance critical apps, mono me tetoia
>>asxoloume 
> 
> No offence, alla h upar3h an8rwpwn pou den exoun idea gia ton tomea tous
> exei papsei na me ekplhsei. Oxi, den ennow oti *esu* den exeis idea
> (mporei kai na exeis, mhn kolhsoume se esena twra), ennow oti to "trust
> me, I know"(tm) den einai sobaro epixeirhma.

Dekto, symfono kai epayksano, aplos itan prologos gia to parakato

>>Prota grafoume ton kodika *katharo* kai meta akolouthontas tis
>>symboules enos profiler kanoume optimizations. Kai bebeos ena kako
>>data structure tha se xtypisei sto ekatontaplasio sto performance apo
>>to na kaneis kati ston kodika pou ek protis opseos mporei na fanei pio
>>omorfo alla pio argo. Opote strive for clean code.
> 
> 
> ... kai ws edw mallon anoi3es to agaphmeno sou programming/softeng book
> h apla to apaggeleis apo mnhmhs. Se ka8e periptwsh, auta einai mallon
> asxeta me to exm ... "8ema mas".

oxi, milao ek peiras.
An diafoneis kalos, alla min prospatheis na ypobathmiseis ta legomena mou.

>>Ta perisotera data structures xrisimopoioun pointers, ti simenei oti
>>den prepei na grafeis ta dedomena ayton ton structures se arxeia
>>allios eise astoixeiotos programmatistis?
> 
> Ta perissotera data structures einai ftiagmena gia na kratoun in-memory
> objects. Mporw na arxisw na sou aradiazw on-disk structures mexri na
> kourastw na plhktrologw, alla den blepw to nohma na to kanw otan
> amfisbhteis to autapodeikto (endeiktika, apo popular source trees, gia
> na mporeis na ta deis kai monos sou:
> 
> freebsd (gia thn akribeia ta phra apo to dragonfly pou einai to mono
> leitourgiko pou exw proxeiro auth th stigmh):
> /usr/include/sys/disklabel.h:struct disklabel
> /usr/include/sys/diskmbr.h:struct dos_partition
> /usr/src/sys/vfs/ufs/fs.h:struct fs
> 
> apo to linux:
> fs/xfs/xfs_sb.h:struct xfs_sb
> (snipped superblock & inode structs sto fs/*, ta on-disk inode structs
> ei8istai na einai embedded sta in memory structs)


epidi kapoios kapou ekane kati se ena *popoular source tree* simenei oti einai 
kai kali praktiki ? kai nai profanos otan grafeis leitorugiko systima den 
mporeis na exeis ton kodika sou pliros katharo, prepei na kaneis kai hacks. 
Milame gia normal programmata tora (user space programs gia na to theso kalytera 
:) Allo to ena allo to allo.


>>memory dump sto disko einai sigoura special case, san geniko kanona
>>loipon den kanoume memory dumps ektos apo sygekrimenes periptoseis
>>opou 1) mas pairnei 2) to programma einai dirty hack kai den exoume
>>diathesi na to organosoume sosta.
> 
> 
> h 3) xreiazetai gia logous efficiency
>   4) aplopoiei ton kwdika

to 3 to kalypsame parapano kai diafono opos proanefera, to 4 einai valid reason, 
kai giayto eipa oti an den se endiaferei i sosti organosi tou programmatos pou 
grafeis alla einai kati grigoro mporeis na thysiaseis tin katharotita gia na 
aplopoiiseis ti diadikasia.

Anyway opos eipa o kathenas opos goustarei, aplos paratheto tin gnomi mou sto 
zitima (i opoia bebea panta einai "i sosti gnomi" :)))

-- Nuclear / the Lab --





More information about the Linux-greek-users mailing list