-
Notifications
You must be signed in to change notification settings - Fork 118
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
Improve the complexity of Action exception handling primitives #797
Comments
Is the O(log n) ever visible? Have you managed to measure that as a meaningful slowdown? It's possible to use smarter data structures to avoid that slowdown (an array, that grows, where you delete by swapping the end), but I never thought it might get frequent enough to matter. |
Regardless of whether it's visible or not it should be documented since the complexity is different from the assumed one. Fixing it would be a bonus, but that's not the main issue here |
I think this code is O(log N) in the number of simultaneously running calls to For the lock, we could introduce per-Action Cleanup pools, which would entirely remove the contention. Given the issue in HLS, I'd be keen to understand how much performance used to be lost due to Cleanup, how much performance currently goes into Cleanup, and if Cleanup was an order of magnitude faster, would we do things differently? |
It's hard to measure time performance precisely in Haskell, because the precision goes down with the number of SCC, too many and you are no longer measuring the real program, too few and you don't get correct cost attribution. I previously shared this profile but it's hard to say whether the costs attributed to |
Note that in Ghcide we do nest |
Why do you think documentation would do harm?
|
It's the number of simultaneously running actionBrackets across the program, so if you nest deeply somewhere else, that counts too. It also feels that if this matters to you, the solution is to fix actionBracket. But I guess there's no harm in mentioning it. |
Documented, and leaving the ticket to improve it (I don't think it would be too hard to make it O(1) with a suitable data structure). |
actionBracket
,actionFinally
andactionOnException
all have an unexpected O(logN) complexity where N is the total number of cleanups registered.The usual complexity for these primitives is O(1), so it should be documented (or if possible, fixed). Moreover, the cleanup store is global and locked, so these primitives introduce additional lock contention which is also worth documenting.
The text was updated successfully, but these errors were encountered: