Skip to content

Avoid thunks in IntSet minView and maxView - #1277

Open
oheliav wants to merge 1 commit into
haskell:masterfrom
oheliav:strict-intset-minview
Open

oheliav wants to merge 1 commit into
haskell:masterfrom
oheliav:strict-intset-minview

Conversation

@oheliav

@oheliav oheliav commented Nov 8, 2026

Copy link
Copy Markdown

Fixes #1251.

The go helpers in minView and maxView now return a StrictPair instead of a lazy tuple, so the rebuilt set is constructed right away instead of being left as a thunk. The signBranch case also forces the result of binCheckL/binCheckR before wrapping it in Just.

After the change, the Core for the go worker returns the rebuilt Bin/Tip/Nil directly in the unboxed tuple, with no lazy case left in the second component.

Benchmarks (intset-benchmarks, GHC 9.10.3, aarch64-osx):

benchmark before after change
deleteMin 39.1 ns 19.5 ns -50%
deleteMax 11.8 ns 6.84 ns -41%
delete 42.5 μs 39.7 μs same (doesn't use minView, for comparison)

intset-properties and intset-strictness-properties pass.

Use a strict pair in the go helpers and force the rebuilt set before wrapping it in Just. Fixes haskell#1251.
@treeowl

treeowl commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

How does this compare to IntMap? Do we want to produce the Just before descending the tree?

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.

IntSet's minView and maxView creates unwanted thunks

2 participants