# translation of Developer_Tips.po to # # AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: Developer_Tips\n" "POT-Creation-Date: 2010-10-26T17:59:50\n" "PO-Revision-Date: 2010-09-24 16:43+0100\n" "Last-Translator: luigi votta \n" "Language-Team: \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.11.4\n" #. Tag: title #, no-c-format msgid "Tips for Developers" msgstr "Suggerimenti per Sviluppatori" #. Tag: para #, no-c-format msgid "Every good programming textbook covers problems with memory allocation and the performance of specific functions. As you develop your software, be aware of issues that might increase power consumption on the systems on which the software runs. Although these considerations do not affect every line of code, you can optimize your code in areas which are frequent bottlenecks for performance." msgstr "Ogni buon manuale di progammazione affronta i problemi di allocazione memoria e le prestazioni di specifiche funzioni, un pò meno le questioni legate al risparmio energetico. Come buona pratica di sviluppo del software, quindi, si dovrebbero considerare anche quelle situazioni che possono influire sui consumi energetici nei sistemi sui quali il software dovrà funzionare. Queste considerazioni non influenzano ogni riga di codice, ma sono dirette ad ottimizzare quelle parti di codice che più freqentemente presentano limitazioni nelle prestazioni." #. Tag: para #, no-c-format msgid "Some techniques that are often problematic include:" msgstr "Alcune tecniche che risultano spesso problematiche, sono:" #. Tag: para #, no-c-format msgid "using threads." msgstr "utilizzo di thread." #. Tag: para #, no-c-format msgid "unnecessary CPU wake-ups and not using wake-ups efficiently. If you must wake up, do everything at once (race to idle) and as quickly as possible." msgstr "wakeup non necessari della CPU unito al loro uso poco efficiente. Alternativa: se occorre un wakeup, race to idle, eseguire i task il più velocemente possibile." #. Tag: para #, no-c-format msgid "using [f]sync() unnecessarily." msgstr "utilizzo non indispensabile della funzione [f]sync()." #. Tag: para #, no-c-format msgid "unnecessary active polling or using short, regular timeouts. (React to events instead)." msgstr "utilizzo non necessario di polling o di brevi regolari timeout. Alternativa: reagire agli eventi." #. Tag: para #, no-c-format msgid "not using wake-ups efficiently." msgstr "utilizzo non efficiente dei wakeup." #. Tag: para #, no-c-format msgid "inefficient disk access. Use large buffers to avoid frequent disk access. Write one large block at a time." msgstr "accesso inefficiente al disco. Alternativa: usare buffer capienti per ridurre gli accessi; usare blocchi di scrittura più grandi." #. Tag: para #, no-c-format msgid "inefficient use of timers. Group timers across applications (or even across systems) if possible." msgstr "utilizzo inefficiente dei timer. Alternativa: raggruppare, quando possibile, i timer di più applicazioni, o meglio ancora dei sistemi." #. Tag: para #, no-c-format msgid "excessive I/O, power consumption, or memory usage (including memory leaks)" msgstr "utilizzo eccessivo dell'I/O e della memoria, inclusi i memory leaks" #. Tag: para #, no-c-format msgid "performing unnecessary computation." msgstr "esecuzioni non necessarie di eleborazioni" #. Tag: para #, no-c-format msgid "The following sections examine some of these areas in greater detail." msgstr "Le seguenti sezioni esaminano in maggior dettaglio, alcune di queste aree." #. Tag: title #, no-c-format msgid "Using Threads" msgstr "Usare i Thread" #. Tag: para #, no-c-format msgid "It is widely believed that using threads makes applications perform better and faster, but this is not true in every case." msgstr "È un luogo comune credere che l'uso dei thread migliori le prestazioni e la velocità delle applicazioni: ciò non è sempre vero!." #. Tag: title #, no-c-format msgid "Python" msgstr "Python" #. Tag: para #, no-c-format msgid "Python uses the Global Lock Interpreter, so threading is profitable only for larger I/O operations. Unladen-swallow is a faster implementation of Python with which you might be able to optimize your code." msgstr "Python usa GIL o Global Lock Interpreter , che rende vantaggioso il threading solo in significative operazioni di I/O. unladen-swallow è una implementazione di Python più veloce, con cui è possibile ottimizzare il codice." #. Tag: title #, no-c-format msgid "Perl" msgstr "Perl" #. Tag: para #, no-c-format msgid "Perl threads were originally created for applications running on systems without forking (such as systems with 32-bit Windows operating systems). In Perl threads, the data is copied for every single thread (Copy On Write). Data is not shared by default, because users should be able to define the level of data sharing. For data sharing the threads::shared module has to be included. However, data is not only then copied (Copy On Write), but the module also creates tied variables for the data, which takes even more time and is even slower. " msgstr "I thread di Perl sono stati originariamente creati per eseguire applicazioni senza usare processi di fork (come nei sistemi windows a 32-bit). Nei thread di Perl, i dati vengono copiati per ogni singolo thread (Copy On Write). Per impostazione, i dati non vengono condivisi e gli utenti dovrebbero definire il loro livello di condivisione. Per la condivisione dei dati, occorre includere il modulo threads::shared. In tal modo, il modulo non solo copia i dati (Copy On Write), ma crea anche delle variabili ad essi collegati, con l'effetto di richiedere più tempo e di risultare più lento. " #. Tag: title #, no-c-format msgid "C" msgstr "C" #. Tag: para #, no-c-format msgid "C threads share the same memory, each thread has its own stack, and the kernel does not have to create new file descriptors and allocate new memory space. C can really use the support of more CPUs for more threads. Therefore, to maximize the performance of your threads, use a low-level language like C or C++. If you use a scripting language, consider writing a C binding. Use profilers to identify poorly performing parts of your code. " msgstr "I thread di C condividono la stessa memoria, ogni thread ha il proprio stack ed il kernel non deve creare nuovi descrittori di file ed assegnare nuova memoria. Il C può effettivamente avvalersi del supporto di più CPU per più thread. Perciò, per massimizzare le prestazioni dei thread, usare un linguaggio low-level come C o C++. Se si usa un linguaggio di script, si consideri la progettazione di un C binding. Impiegare un software di profiling per identificare nel codice, le sezioni con scarse prestazioni. " #. Tag: title #, no-c-format msgid "Wake-ups" msgstr "Wakeup" #. Tag: para #, no-c-format msgid "Many applications scan configuration files for changes. In many cases, the scan is performed at a fixed interval, for example, every minute. This can be a problem, because it forces a disk to wake up from spindowns. The best solution is to find a good interval, a good checking mechanism, or to check for changes with inotify and react to events. Inotify can check variety of changes on a file or a directory." msgstr "Molte applicazioni scansionano i file di configurazione alla ricerca di variazioni. In molti casi, la scansione avviene ad intervalli regolari, per esempio ogni minuto. Ciò può essere un problema, perchè forza la riattivazione del disco dal suo stato di spindown (lo stato inattivo, in cui il disco ruota a minime velocità). La soluzione migliore sarebbe impostare un intervallo adeguato o un buon meccanismo di controllo, oppure verificare le variazioni con inotify e reagire agli eventi. inotify può controllare un gran numero di variazioni sia in file sia in directory." #. Tag: para #, no-c-format msgid "For example:" msgstr "Per esempio:" #. Tag: programlisting #, no-c-format msgid "" "int fd;\n" "fd = inotify_init();\n" "int wd;\n" "/* checking modification of a file - writing into */\n" "wd = inotify_add_watch(fd, \"./myConfig\", IN_MODIFY);\n" "if (wd < 0) {\n" " inotify_cant_be_used();\n" " switching_back_to_previous_checking();\n" "}\n" "...\n" "fd_set rdfs;\n" "struct timeval tv;\n" "int retval;\n" "FD_ZERO(&rdfs);\n" "FD_SET(0, &rdfs);\n" "\n" "tv.tv_sec = 5;\n" "value = select(1, &rdfs, NULL, NULL, &tv);\n" "if (value == -1)\n" " perror(select);\n" "else {\n" " do_some_stuff();\n" "}\n" "..." msgstr "" "int fd;\n" "fd = inotify_init();\n" "int wd;\n" "/* checking modification of a file - writing into */\n" "wd = inotify_add_watch(fd, \"./myConfig\", IN_MODIFY);\n" "if (wd < 0) {\n" " inotify_cant_be_used();\n" " switching_back_to_previous_checking();\n" "}\n" "...\n" "fd_set rdfs;\n" "struct timeval tv;\n" "int retval;\n" "FD_ZERO(&rdfs);\n" "FD_SET(0, &rdfs);\n" "\n" "tv.tv_sec = 5;\n" "value = select(1, &rdfs, NULL, NULL, &tv);\n" "if (value == -1)\n" " perror(select);\n" "else {\n" " do_some_stuff();\n" "}\n" "..." #. Tag: para #, no-c-format msgid "The advantage of this approach is the variety of checks that you can perform." msgstr "Il vantaggio di questo approccio è dato dalla varietà di controlli che è possibile effettuare." #. Tag: para #, no-c-format msgid "The main limitation is that only a limited number of watches are available on a system. The number can be obtained from /proc/sys/fs/inotify/max_user_watches and although it can be changed, this is not recommended. Furthermore, in case inotify fails, the code has to fall back to a different check method, which usually means many occurrences of #if #define in the source code." msgstr "Il principale svantaggio è rappresentato dal limitato numero di controlli disponibili nel sistema, indicato nel file/proc/sys/fs/inotify/max_user_watches che si raccomanda di non modifcare. Inoltre, nel caso in cui inotify fallisca, il codice dovrebbe ricorrere ad un metodo di controllo alternativo; il che significa inserire nel codice molte istruzioni #if #define ." #. Tag: para #, no-c-format msgid "For more information on inotify, refer to the inotify man page." msgstr "Per maggiori informazioni su inotify, consultare le pagina man su inotify." #. Tag: title #, no-c-format msgid "Fsync" msgstr "fsync" #. Tag: para #, no-c-format msgid "Fsync is known as an I/O expensive operation, but this is is not completely true. For example, refer to Theodore Ts'o's article Don't fear the fsync! and the accompanying discussion." msgstr "fsync è nota essere una operazione di I/O molto esigente, ma ciò non è completamente vero. Per spezzare una lancia a favore di fsync, consultare l'articolo scritto da Theodore Ts'o' Don't fear the fsync! e la relativa discussione." #. Tag: para #, no-c-format msgid "Firefox used to call the sqlite library each time the user clicked on a link to go to a new page. Sqlite called fsync and because of the file system settings (mainly ext3 with data-ordered mode), there was a long latency when nothing happened. This could take a long time (up to 30 seconds) if another process was copying a large file at the same time." msgstr "Firefox usava caricare la libreria sqlite ognivolta che l'utente cliccava sul link di una nuova pagina. sqlite a sua volta chiamava la funzione fsync e a causa delle impostazioni del file system (soprattutto del f.s. ext3 in modalità data-ordered), si verificava una lunga latenza. La pagina web si caricava dopo un lungo ritardo, che poteva durare fino a 30 secondi se era in esecuzione un altro processo, che per esempio, copiava un file molto grande." #. Tag: para #, no-c-format msgid "However, in other cases, where fsync wasn't used at all, problems emerged with the switch to the ext4 file system. Ext3 was set to data-ordered mode, which flushed memory every few seconds and saved it to a disk. But with ext4 and laptop_mode, the interval between saves was longer and data might get lost when the system was unexpectedly switched off. Now ext4 is patched, but we must still consider the design of our applications carefully, and use fsync as appropriate." msgstr "Inoltre, in altri casi, in cui fsync non veniva per nulla usata, si verificarono problemi con il passaggio al file system ext4. ext3 era impostato in modalità data-ordered, che ripuliva la memoria ogni pochi secondi, salvando i dati sul disco. Ma con ext4 e laptop_mode (usato nei portatili per prolungare la durata della batteria), l'intervallo delle operazioni di salvataggio era più lungo e poteva esserci una potenziale perdita di dati se il sistema veniva spento, improvvisamente. Ora ext4 è stato patched: (morale della favola) progettare attentamente le applicazioni e usare in modo appropriato la funzione fsync." #. Tag: para #, no-c-format msgid "The following simple example of reading and writing into a configuration file shows how a backup of a file can be made or how data can be lost:" msgstr "Il seguente semplice esempio di lettura e scrittura in un file di configurazione, mostra come sia possibile eseguire un backup di un file o .... perdere i dati:" #. Tag: programlisting #, no-c-format msgid "" "/* open and read configuration file e.g. ~/.kde/myconfig */\n" "fd = open(\"./kde/myconfig\", O_WRONLY|O_TRUNC|O_CREAT);\n" "read(myconfig);\n" "...\n" "write(fd, bufferOfNewData, sizeof(bufferOfNewData));\n" "close(fd);" msgstr "" "/* open and read configuration file e.g. ~/.kde/myconfig */\n" "fd = open(\"./kde/myconfig\", O_WRONLY|O_TRUNC|O_CREAT);\n" "read(myconfig);\n" "...\n" "write(fd, bufferOfNewData, sizeof(bufferOfNewData));\n" "close(fd);" #. Tag: para #, no-c-format msgid "A better approach would be:" msgstr "Questa sarebbe una soluzione migliore:" #. Tag: programlisting #, no-c-format msgid "" "open(\"/.kde/myconfig\", O_WRONLY|O_TRUNC|O_CREAT);\n" "read(myconfig);\n" "...\n" "fd = open(\"/.kde/myconfig.suffix\", O_WRONLY|O_TRUNC|O_CREAT);\n" "write(fd, bufferOfNewData, sizeof(bufferOfNewData));\n" "fsync; /* paranoia - optional */\n" "...\n" "close(fd);\n" "rename(\"/.kde/myconfig\", \"/.kde/myconfig~\"); /* paranoia - optional */\n" "rename(\"/.kde/myconfig.suffix\", \"/.kde/myconfig\");" msgstr "" "open(\"/.kde/myconfig\", O_WRONLY|O_TRUNC|O_CREAT);\n" "read(myconfig);\n" "...\n" "fd = open(\"/.kde/myconfig.suffix\", O_WRONLY|O_TRUNC|O_CREAT);\n" "write(fd, bufferOfNewData, sizeof(bufferOfNewData));\n" "fsync; /* paranoia - optional */\n" "...\n" "close(fd);\n" "rename(\"/.kde/myconfig\", \"/.kde/myconfig~\"); /* paranoia - optional */\n" "rename(\"/.kde/myconfig.suffix\", \"/.kde/myconfig\");"