x/tools/go/types/typeutil: gut Hasher #69407
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Thinking about #67161, I wanted to know whether the the new API should include Hasher. It complicates the API because it turns reads (lookups in typeutil.Map) into writes (memoization of hash values). Is it an effective optimization, or does it increase memory contention (and potentially the need for locking)?
I gutted its implementation, removing both memoization maps, and simplifying the implementation of Hasher.hashPtr to just
reflect.ValueOf(ptr).Pointer()
(which assumes a non-moving GC) and Hasher.hashTypeParam to a hash of t.Index(), making Hasher a stateless empty struct. Then I ran BenchmarkRTA, modified to analyze all of gopls, not just net/http.The results:
It is slightly faster and has lower variance. Whatever problems a stateful Hasher once solved, we have no further need for it.
Let's make it an empty struct, and disregard it when considering #67161.
@timothy-king @findleyr
The text was updated successfully, but these errors were encountered: