Skip to content

Conversation

Shimuuar
Copy link
Contributor

This approach is complementary to inspection tests. We want to compile some functions on vectors to tight non allocating loops and it's difficult to formulate property in terms of inspection tests. It's however easy to measure allocation and check that we don't allocate anything except vector's buffer and some constant overhead

These test trip up if rewrite rules for unstreamM and generateA are removed. So this is good way to check that rewrite rules and other optimizations work as intended and make much less scary to touch them.

@Shimuuar
Copy link
Contributor Author

And sure enough it found problems with optimizations in older GHC

@Shimuuar Shimuuar force-pushed the test-traverse-optimizations branch from 2621bd1 to d7d4405 Compare September 14, 2025 13:42
Shimuuar and others added 3 commits September 17, 2025 19:30
Co-authored-by: Alexey Kuleshevich <[email protected]>
This is good way to check that GHC generate tight non-allocating loops
for monadic/applicative functions.
@Shimuuar Shimuuar force-pushed the test-traverse-optimizations branch 2 times, most recently from 9c5cf65 to fea5c2d Compare September 17, 2025 17:24
@Shimuuar Shimuuar force-pushed the test-traverse-optimizations branch from fea5c2d to fc83758 Compare September 17, 2025 18:02
@Shimuuar
Copy link
Contributor Author

I disabled some tests for older GHC (<9.4). I have no desire to find what went wrong with them.

It will make nice regression test for GHC optimizer

Copy link
Contributor

@lehins lehins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@Shimuuar Shimuuar merged commit 0f60257 into haskell:master Sep 17, 2025
22 checks passed
@Shimuuar Shimuuar deleted the test-traverse-optimizations branch September 17, 2025 21:24
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.

2 participants