digitalmars.D.learn - string hash significant speedup
- Johnson Jones (9/9) Aug 10 2017 when using T[string], hashing is used. Computing the hash is
- Steven Schveighoffer (4/9) Aug 10 2017 It computes them on insertion, and caches the result in the structure of...
- Johnson Jones (3/13) Aug 10 2017 Thanks. What is the cache size?
- Steven Schveighoffer (4/17) Aug 14 2017 size_t.sizeof
- HyperParrow (5/15) Aug 10 2017 But i think he speaks about the strings that are tested for
- Steven Schveighoffer (5/19) Aug 14 2017 If this is the case, then no, there is no cache. It would have to be a
when using T[string], hashing is used. Computing the hash is slow(relatively speaking). Does D cache the hashes? Strings are immutable so there is absolutely no reason why the hash ever need to be computed more than once. Essentially the hash should be attached to strings like their length and address. Does D compute the hash of a string every time it is looked up? If so, any way to optimize that it?
Aug 10 2017
On 8/10/17 3:36 PM, Johnson Jones wrote:when using T[string], hashing is used. Computing the hash is slow(relatively speaking). Does D cache the hashes? Strings are immutable so there is absolutely no reason why the hash ever need to be computed more than once.It computes them on insertion, and caches the result in the structure of the hash table. -Steve
Aug 10 2017
On Thursday, 10 August 2017 at 20:07:35 UTC, Steven Schveighoffer wrote:On 8/10/17 3:36 PM, Johnson Jones wrote:Thanks. What is the cache size?when using T[string], hashing is used. Computing the hash is slow(relatively speaking). Does D cache the hashes? Strings are immutable so there is absolutely no reason why the hash ever need to be computed more than once.It computes them on insertion, and caches the result in the structure of the hash table. -S
Aug 10 2017
On 8/10/17 5:10 PM, Johnson Jones wrote:On Thursday, 10 August 2017 at 20:07:35 UTC, Steven Schveighoffer wrote:size_t.sizeof https://github.com/dlang/druntime/blob/master/src/rt/aaA.d#L173 -SteveOn 8/10/17 3:36 PM, Johnson Jones wrote:Thanks. What is the cache size?when using T[string], hashing is used. Computing the hash is slow(relatively speaking). Does D cache the hashes? Strings are immutable so there is absolutely no reason why the hash ever need to be computed more than once.It computes them on insertion, and caches the result in the structure of the hash table.
Aug 14 2017
On Thursday, 10 August 2017 at 20:07:35 UTC, Steven Schveighoffer wrote:On 8/10/17 3:36 PM, Johnson Jones wrote:But i think he speaks about the strings that are tested for inclusion (i.e opIn RHS), not those who are inserted, for which obviously the hash is known.when using T[string], hashing is used. Computing the hash is slow(relatively speaking). Does D cache the hashes? Strings are immutable so there is absolutely no reason why the hash ever need to be computed more than once.It computes them on insertion, and caches the result in the structure of the hash table. -Steve
Aug 10 2017
On 8/10/17 6:30 PM, HyperParrow wrote:On Thursday, 10 August 2017 at 20:07:35 UTC, Steven Schveighoffer wrote:If this is the case, then no, there is no cache. It would have to be a cache of the hash per pointer/length combo. I don't know that it's worth the effort, certainly not for built-in AA. -SteveOn 8/10/17 3:36 PM, Johnson Jones wrote:But i think he speaks about the strings that are tested for inclusion (i.e opIn RHS), not those who are inserted, for which obviously the hash is known.when using T[string], hashing is used. Computing the hash is slow(relatively speaking). Does D cache the hashes? Strings are immutable so there is absolutely no reason why the hash ever need to be computed more than once.It computes them on insertion, and caches the result in the structure of the hash table.
Aug 14 2017