-
Notifications
You must be signed in to change notification settings - Fork 273
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
Fix triggering of Worker Wrapper optimization on Stack #5468
Conversation
e149582
to
1e9f863
Compare
1e9f863
to
e2b8302
Compare
9a8d8f4
to
0c20a8e
Compare
dependencies: | ||
- inspection-testing | ||
- condition: flag(dumpcore) | ||
ghc-options: -ddump-simpl -ddump-stg-final -ddump-to-file -dsuppress-coercions -dsuppress-idinfo -dsuppress-module-prefixes -ddump-str-signatures -ddump-simpl-stats # -dsuppress-type-applications -dsuppress-type-signatures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave these commented out flags here because they're sometimes useful and it's annoying to go look them up every time I need them.
@@ -136,15 +165,6 @@ refNumTm cc r = | |||
(M.lookup r -> Just w) -> pure w | |||
_ -> die $ "refNumTm: unknown reference: " ++ show r | |||
|
|||
refNumTy :: CCache -> Reference -> IO Word64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several methods ended up being unused when I added the export lists.
If @dolio is attached to any of these we can certainly revive them :)
0c20a8e
to
dcddb9d
Compare
dcddb9d
to
cc68b25
Compare
Just curious - I read the precise exceptions page, but I don't know if I get it. It seems like if the function is strict in all its arguments, it shouldn't matter whether you use |
To be honest I admit I don't fully understand what's happening here or why aside from that the linked issue does seem to be relevant. All I know is that at least in theory the worker-wrapper should trigger with the existing setup but the Core reflects that it doesn't and that this fixes it. I could spend more time digging in if we think it's important, but changing from a throw to an error seems like a pretty reasonable alternative and adding the test at least makes sure it won't suddenly regress without us noticing :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests ftw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
A couple of those removed functions might become relevant again with different calling conventions. But they can be added back (and maybe a more systematic approach would be better).
The testing library you're using for this sounds interesting.
Overview
Worker/wrapper was failing to trigger, and thus failed to unbox
Stack
, which resulted in us re-allocating the Stack wrapper object on every machine instruction, wasting a ton of allocation time and triggering a ton of garbage collection in the process.This PR gets the optimization firing again, and includes a test to ensure it remains active.
Implementation details
XStack
. GHC can't rewrite these dynamic functions at optimization time, so this is a necessary step.error
, and also inserted a few unreachableerrors
, click through to see more information on why that might be.Stack
type is mentioned withineval0
. This should be sufficient to detect if worker-wrapper starts to fail again.Benchmarks
For the 'count to a billion' tight loop I've reduced allocations significantly from
88.8 GB
to16.8 GB
, a 5.3X improvement, but we're still allocating much more than we should. I found a few more spots to look into next.trunk
this branch
trunk -> this branch: