September 09, 2016 Re: Templates are slow. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 9 September 2016 at 12:09:32 UTC, Steven Schveighoffer wrote:
> I just had a thought. If you hash the string, and then compare the length of the string and first and last character along with the hash, what are the chances of it being a false positive?
Any chance of a false positive is nontrivial when hashes are being compared so often.
Never, never ever in production code are you to assume that hashes and other non-definitive data can be used to guarantee uniqueness.
|
September 09, 2016 Re: Templates are slow. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 9 September 2016 at 12:09:32 UTC, Steven Schveighoffer wrote: > On 9/8/16 6:57 PM, Stefan Koch wrote: >> Hi Guys, >> >> I have some more data. >> In the binderoo example the main time is spent in the backend. >> generating code and writing objects files. > > If we ever get Rainer's patch to collapse repetitive templates, we may help this problem. https://github.com/dlang/dmd/pull/5855 > >> >> The front-end spends most of it's time comparing strings of unique >> type-names :) > > I thought the front end was changed to use the string pointer for symbol names as the match so string comparisons aren't done? In this case the string is freshly and not available as reference to an already lexed string . > Hm... maybe to intern the string? That kind of makes sense. Yes that would be the way to go. > I just had a thought. If you hash the string, and then compare the length of the string and first and last character along with the hash, what are the chances of it being a false positive? This depends entirely on the distribution of strings. It's probably quite high :) |
September 09, 2016 Re: Templates are slow. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu Attachments:
| On Thu, 2016-09-08 at 14:23 +0200, Andrei Alexandrescu via Digitalmars- d wrote: > On 9/8/16 7:02 AM, Stefan Koch wrote: > > > > > > I will write an article about why templates are slow. > > > > The gist will be however : "Templates being slow is an inherent > > property > > of templates." (We are only talking about templates as defined by > > (C++ > > and D)). > > That would be a great article. Are there any situations that we can special-case away? Raising the roof. -- Andrei One that could get published in CVu or Overload. https://accu.org/index.php/journal -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
September 09, 2016 Re: Templates are slow. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 9 September 2016 at 12:09:32 UTC, Steven Schveighoffer wrote:
> On 9/8/16 6:57 PM, Stefan Koch wrote:
>> Hi Guys,
>>
>> I have some more data.
>> In the binderoo example the main time is spent in the backend.
>> generating code and writing objects files.
>
> If we ever get Rainer's patch to collapse repetitive templates, we may help this problem. https://github.com/dlang/dmd/pull/5855
>
>>
>> The front-end spends most of it's time comparing strings of unique
>> type-names :)
>
> I thought the front end was changed to use the string pointer for symbol names as the match so string comparisons aren't done?
>
> Hm... maybe to intern the string? That kind of makes sense.
>
> I just had a thought. If you hash the string, and then compare the length of the string and first and last character along with the hash, what are the chances of it being a false positive?
>
> -Steve
You need to compare the string to unique them, so it doesn't change anything.
|
September 09, 2016 Re: Templates are slow. | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On Friday, 9 September 2016 at 18:17:02 UTC, deadalnix wrote:
>
> You need to compare the string to unique them, so it doesn't change anything.
It changes the frequency of comparisons.
|
Copyright © 1999-2021 by the D Language Foundation