%HTMLlat1; %HTMLsymbol; %HTMLspecial; ]> Script-Fu
Roland van Ipen­burg
To be stolen or blogged
BETA

Script-Fu

Fri­day 22 Jan­uary 2010 07:04

Trow­el is writ­ten around AnyEvent, an event loop pro­gram­ming frame­work. That means the pro­gram is de­v­id­ed in units that can con­tin­ue to run with­out wait­ing for each oth­er. This is con­ve­nient when we're us­ing net­work con­nec­tions that are apt to hang - like twit­ter - so the parts that have noth­ing to do with the net­work con­nec­tion can keep go­ing in­de­pen­dent of the state of the net­work con­nec­tion (in the­o­ry). The down­side is that you nev­er know in what or­der the var­i­ous units in­ter­act and to pre­vent race con­di­tions in which two or more units try to change the same cen­tral data at the same time the in­ter­ac­tion has to be atom­ic. For Trow­el this means one unit push­es the col­lect­ed tweets onto an ar­ray while the oth­er unit pops them of to dis­play them, so at my lev­el of ab­strac­tion the units don't have to ex­plic­it­ly wait for each oth­er to fin­ish chang­ing the con­tents of the ar­ray. I as­sume there's one proces­sor that is chang­ing val­ues in mem­o­ry and in one proces­sor cy­cle the push and the pop can't be done si­mul­ta­ne­ous­ly.

With lin­ux on Cell Broad­band Engine hard­ware it's pos­si­ble to do awe­some things. But the trick is that the Cell con­sists of a rather slow proces­sor and about 6 su­per fast spe­cialised proces­sor units. To cre­ate pro­grams that uti­lize all the proces­sors it is re­quired to write them about the same as with an event loop. The pro­gram would re­quire mul­ti­ple threads that try to keep all the spe­cial­ized proces­sors busy, and the hard part is to man­age the data that is used in all those threads. be­cause if 6 units want to pop or push the same ar­ray at the same time you're sud­den­ly look­ing at one of those that will have to wait up to 5 cy­cles, and a big­ger chance that it should be af­fect­ed by what the oth­er 5 units have been do­ing.

Get­ting bored of some repet­i­tive task in the Gimp I de­cid­ed to write a script that would do the same task with the push of a but­ton. The chal­lange was that it had to be done in Scheme. Which is a pain. Just like with the Cell you're con­front­ed with how the un­der­lay­ing hard­ware re­al­ly works and not how your brain works. After a while your brain starts to work like the hard­ware though and it gets eas­i­er, but it shows that writ­ing op­ti­mized code is still hard. And why a lot of code is still slow on to­day's blaz­ing­ly fast hard­ware...

:

Book­mark this on De­li­cious

Add to Stum­bleUpon

Add to Mixx!

Share/Save/Book­mark


:

Com­ment/Con­tact
application away browser buy cool data days different flash game gta html ibook internet linux movie open play playstation possible run screen server side site stuff system train web windows work

Blog Posts (418)

Image Gal­leries

ipen­bug Last.fm pro­file

ipen­bug last.fm pro­file

Fol­low me on Twit­ter

Roland van Ipen­burg on face­book
Lin­ux Regis­tered User #488795
rolipe BOINC com­bined stats

Sub­scribe

Add to Google

Valid XHTML + RFDa Valid CSS! Hy­phen­at­ed XSL Pow­ered Valid RSS This site was cre­at­ed with Vim Pow­ered by Bri­co­lage! Pow­ered by Post­greSQL! Pow­ered by Apache! Pow­ered by mod­_perl! Pow­ered by Ma­son! Pow­ered by Perl Made on a Mac Pow­ered By Mac OS X XS4ALL This site has been proofed for ac­cu­ra­cy on the VISTAWEB-3000 Creative Com­mons Li­cense
This work by Roland van Ipen­burg is li­censed un­der a Creative Com­mons At­tri­bu­tion-Non­com­mer­cial-Share Alike 3.0 Un­port­ed Li­cense.
Per­mis­sions be­yond the scope of this li­cense may be avail­able at mail­to:ipen­burg@xs4all.nl.