You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Name Time - - - - - - - - Allocated - - - - -
A B % A B %
lookup absent 474 μs 502 μs +5% 145 B 317 B +118%
lookup present 469 μs 459 μs -2% 128 KB 329 B -99%
Great reduction in allocations, but no effect on time saved. I expect GHC is just very fast with short-lived allocations.
IntMap:
Name Time - - - - - - - - Allocated - - - - -
A B % A B %
lookup_half 279 μs 296 μs +6% 148 B 147 B +0%
lookup_hits 479 μs 522 μs +8% 1.0 KB 335 B -67%
lookup_misses 472 μs 499 μs +5% 309 B 305 B -1%
lookup_mixed 246 μs 268 μs +9% 148 B 161 B +8%
lookup_most 438 μs 474 μs +8% 308 B 293 B -4%
Surprisingly, there are no allocations even without this change. I checked the Core and found that lookup is small enough that GHC inlines it and simplifies, removing the allocations. With this change, GHC no longer inlines lookup, which makes it slightly slower. I would argue it is still a good change because it has a positive impact on code size and compile time if lookup doesn't inline at every call-site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trying this out for #801.