Posted on Saturday 5 February 2005
I was working with a large (400 items, 4 columns) recordset today and noticed that AMFPHP wasn’t all that fast for this kind of setup. I thought it might have been a consequence of my recent commit of charset handling functions but it turned out otherwise. It was spending over 90% of its time in AMFSerializer->writeRecordset. Recordsets are transferred to a transient multi-dimensional array before being serialized, and that needs a lot of datatype negotiation for each and every item in the array. Anyway, since the structure of the recordset is predictable I carefully unrolled the writeRecordset function, removed most function calls, keeping datatype negotiation to a bare minimum.
The results: a 50%+ speed increase in sending back large recordsets. You will really see a massive increase in speed when there are a lot of items sent back to Flash. It depends on the number of columns multiplied by the number of rows. If it’s more than, say, 500, you will start to see an increase in speed. For 5000-10000, we’re talking about 75% speedup.
Grab the latest CVS from SourceForge to try it out. And send an email on the list if I fudged anything (as I usually do).


