Virtual Methods hurting performance in the DMD frontend

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 12 00:54:42 PDT 2016


On 2016-09-11 23:48, Stefan Koch wrote:
> Hi,
>
> As you may know I am currently optimizing template-related code inside
> of DMD.
> Inside DMD code quality is quite high, there is little low hanging fruit.
>
> However there is one thing that suspiciously often shows up the on
> profilers display.
> Those are indirect class which have a high number of L2(!) i-cache misses.
>
> These calls don't do a lot of work. They are needed either for downcasts
> or to verify the dynamic type of an AST-Node.
> Even without the i-cache related stalls the call overhead alone is
> something to think about.
>
> For template-heavy code matching template parameters is one of the most
> frequently operations.
> Since Template Parameters can be types expressions or symbols the
> dynamic-types are heavily queried.
>
> First experiments suggest that a speedup of around 12% is possible if
> the types where accessible directly.
>
> Since dmd uses visitors for many things now the benefit of virtual
> methods is highly reduced.
>
> Please share your thoughts.

What about using an enum in the base class that indicates the runtime 
type? The Expression class is already using this technique. Add it to 
Declaration and Statement as well, or even to RootObject.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list