Table lookups - this is pretty definitive

Walter Bright newshound2 at digitalmars.com
Tue Apr 1 12:49:42 PDT 2014


On 4/1/2014 12:23 PM, John Colvin wrote:
> It's not really possible to tell anything from that benchmark, especially with
> fancy modern optimisers and branch predictors.

I disagree, read on.

> 1) ldc and gdc both optimise away some/all of the tests respectively.
 > 2) once isIdentifierCharX is inlined, the compiler can determine what the
 > results will be before-hand.

This is always an issue with benchmarking in order to find the best way to write 
an algorithm. I just adjust it so the particular compiler used can't throw it away.


> 3) Even without 1) and 2), the results are unrealistically (very!) correlated,
> leading to a branch-prediction bonanza. I'm sure you know how significant that
> can be on modern CPUs. It is also very friendly to pre-fetching of the lookup
> table*

This is exactly why I wanted to test it.


> Perhaps have the same benchmark, but working on realistic data from a file.

Switching to it in Warp produced a very significant speedup on real files.

https://github.com/facebook/warp/pull/5



More information about the Digitalmars-d mailing list