Small Buffer Optimization for string and friends

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Apr 9 07:55:17 PDT 2012


On 4/9/12 4:21 AM, Manu wrote:
> After thinking on it a bit, I'm becoming a little worried about this
> move for 2 rarely considered reasons:
> Using lowering to a template, debug(/unoptimised) performance will
> probably get a lot slower, which is really annoying. And
> debugging/stepping might become considerably more annoying too, if every
> time I press F11 (step in) over a function call that happens to receive
> an arg from an array, the debugger then steps into the array templates
> index operator... We'd be no better off than with STL, unless the
> language has clever ways of hiding this magic from the debugger too, and
> optimising/inlining the index even in debug builds...? But this is the
> built-in array, and not a library we can optionally not use.

I agree. So we have the counterarguments:

1. Lowering would treat array primitives as sheer D code, subject to 
refusal of inlining. That means worse performance.

2. Unless the compiler takes special measures, source-level debuggers 
will trace through core, uninteresting code for array operations.

3. There are patterns that attempt to optimize by e.g. using .ptr, but 
end up pessimizing code because they trigger multiple memory allocations.


Andrei


More information about the Digitalmars-d mailing list