C problem...se megethos domhs
John Tsiombikas (Nuclear / the Lab)
nuclear at siggraph.org
Sun Jan 25 05:14:13 EET 2004
Aggelos Economopoulos wrote:
>>>>Kai genikos anti na kaneis dump ena struct sto disko, einai poly
>>>>kalyteri idea na organoseis kapos ena fileformat. opote to packing
>>>ton>structs kai alla tetoia den einai kan issue.
>>>
>>>To "na organoseis kapos ena fileformat" stereitai periexomenou.
>>>Mhpws mporeis na to diatupwseis kalutera?
>>
>>tora den katalabes ontos ti eipa i exeis oreksi gia koubenta?
>
>
> nai, eimai atomo periorismenhs antilhpshs. kane mou th xarh na grafeis
> mikres protasoules me apla logakia pou den proupo8etoun na skeftomai
> sto idio context me sena gia na ginoun katanohtes.
etsi fainete
>
>
>>einai eleino na kaneis memory dump se arxeio, kai profanos mi
>>efarmosimo se polles periptoseis (px an to structure sou exei
>>pointers, dynamically allocated members klp), pio anthropini methodos
>>einai na organoseis ena file structure analoga me ta dedomena sou kai
>>na exeis mia synartisi pou diabazei apo to arxeio, kai mia na grafei
>>sto arxeio.
>
>
> apo pou na arxisw? :)
>
> - uparxoun ena swro oxi-kai toso eleines efarmoges gia tis opoies to
> performance metraei polu perissotero apo thn maintainability/
> portability tou kwdika, p.x. filesystems, databases.
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.
Kai mi mou les emena gia performance critical apps, mono me tetoia asxoloume
synithos kai palia ekana diafora kolpa ston kodika gia na paro ligo perisotero
performance, alla stin teliki ta dirty coding tricks den einai ayta pou metrane
performance-wise.
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.
> - uparxoun ena swro file formats gia ta opoia einai apolutws xazo (apo
> programmatistikh apopsh) na mhn xrhsimopoieis fixed-size structs gia
> na ta diabaseis/grapseis eite me xrhsh twn read(2)/write(2) eite me
> th xrhsh tou mmap(2), p.x. elf, net protocols. An eisai tuxeros kai
> ta format einai kaloftiagmena, den 8a xreiastei pote na ta dhlwseis
> san packed.
>
> - an to structure pou 8eleis na grapseis sto disko exei pointers[0],
> eisai astoixeiwtos programmer[1] kai auth den einai mia periptwsh pou
> mas endiaferei.
E oxi me sygxoreis alla i les malakies i exeis ksefygei apo to thema.
Ta perisotera data structures xrisimopoioun pointers, ti simenei oti den prepei
na grafeis ta dedomena ayton ton structures se arxeia allios eise astoixeiotos
programmatistis?
PROFANOS de thes na grapseis ta pointers ayta katheayta kai giayto tonisa oti
prepei na exeis synartiseis pou apothikeyoun ta structures sou se kapoio
fileformat kai oxi na petas stegna to struct ston disko, giati ta pointers
theloun special treatment, otan exeis ena struct pou exei ena pointer meso tou
opoiou kaneis allocate ena chunk mnimis, profanos thes na apothikeyseis ta
periexomena tou chunk kai oxi to pointer (to opoio profanos einai axristo sto
arxeio) opote DEN petas to struct ston disko.
Epidi loipon aytou tou eidous oi domes dedomenon einai ypervolika synithismenes,
oi periptoseis pou mporeis na kaneis 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.
> - etc (hdh exoume arketa na suzhthsoume mexri na bare8oume kai oi duo,
> eilikrina bariemai na sunexisw)
Oxi den exo kamia oreksi na to syzitisoume peretero kai idika me ton tono
syzitisis pou etheses (kai akolouthisa), ego milisa an thes me akous an de thes
mi soseis, o kathenas einai ypeythinos gia ta programmata pou grafei kai gia to
styl tou an thes na malakizese go on.
-- Nuclear / the Lab --
More information about the Linux-greek-users
mailing list