[fpc-devel] Alternative parsers

Michael Van Canneyt michael at freepascal.org
Tue Oct 19 20:38:22 CEST 2010



On Tue, 19 Oct 2010, Sergei Gorelkin wrote:

> Alexander Klenin пишет:
>> 
>> Ok, I went ahead and have taken look at the code.
>> I assume you speak about TFPHashList vs TFPCustomHashTable.
>> The classes are not really comparable, because they use quite
>> different internal data structures.
>> So instead I converted TFPHashList list to use ansistrings.
>> 
>> Benchmarking included 3*10^6 calls to Add and Find methods
>> with the arguments of various lengths.
>> 
>> Average string length 5 characters:
>> ShortString: 1.15 s
>> AnsiString: 1.56 s
>> 
>> Average string length 45 characters:
>> ShortString: 12.0 s
>> AnsiString: 3.2 s
>> 
>> I agree that the first case is more relevant for the compiler,
>> but still you can see that ShortStrings are clearly not always faster.
>> 
> I believe it's not ShortStrings per se to blame, but storing them in a large 
> single memory block as it is being done in TFPHashList. Adding a lot of keys 
> will cause many reallocations. Large size of the block forces memory manager 
> to use variable-size pool, which is less efficient than using fixed-size 
> blocks in case of small chunks.

Strange. 
The whole idea of the implementation was to improve memory efficiency.
And at the time, it was definitely and consistently faster.
If Alexander sends me his code, I will check, and then I should ask 
Peter Vreman, who wrote the code. (if he'll still answer).

Michael.


More information about the fpc-devel mailing list