Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline Int{Map,Set}.fromList* for list fusion #1129

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

meooow25
Copy link
Contributor

Also add benchmarks and property tests.

Fixes #288, fixes #842.

This will be the baseline for #1128, I have an implementation in progress.


Benchmarks on GHC 9.10.1:

IntSet:

Name                          Time - - - - - - - -    Allocated - - - - -
                                   A       B     %         A       B     %
fromList:asc                   45 μs   45 μs   +0%    480 KB  480 KB   +0%
fromList:asc:fusion            56 μs   39 μs  -30%    768 KB  480 KB  -37%
fromList:asc:sparse            94 μs   92 μs   -2%    864 KB  864 KB   +0%
fromList:asc:sparse:fusion    106 μs   84 μs  -20%    1.1 MB  864 KB  -24%
fromList:random               458 μs  463 μs   +1%    1.5 MB  1.5 MB   +0%
fromList:random:fusion        484 μs  448 μs   -7%    1.8 MB  1.5 MB  -17%

IntMap:

Name                              Time - - - - - - - -    Allocated - - - - -
                                       A       B     %         A       B     %
fromList:asc                      100 μs   97 μs   -3%    864 KB  864 KB   +0%
fromList:asc:fusion               117 μs   88 μs  -24%    1.2 MB  864 KB  -30%
fromList:random                   471 μs  464 μs   -1%    1.5 MB  1.5 MB   +0%
fromList:random:fusion            497 μs  444 μs  -10%    1.9 MB  1.5 MB  -21%
fromListWith:randomDups           320 μs  312 μs   -2%    1.3 MB  1.3 MB   +0%
fromListWith:randomDups:fusion    338 μs  319 μs   -5%    1.7 MB  1.3 MB  -24%

Also add benchmarks and property tests.
Benchmarks times reduce by 20-30% for ascending keys and 5-10% for
random keys when fusing.
@meooow25 meooow25 force-pushed the inline-intmap-fromlist branch from 7618271 to 530dbe3 Compare March 31, 2025 06:33
@meooow25 meooow25 merged commit 389387f into haskell:master Mar 31, 2025
13 checks passed
@meooow25 meooow25 deleted the inline-intmap-fromlist branch March 31, 2025 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing INLINE/INLINABLE for fromList IntSet.fromList slower than repeated IntSet.insert
1 participant