-
Notifications
You must be signed in to change notification settings - Fork 14
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
Adding HasCallStack to the methods of the Ix typeclass #115
Comments
The proliferation of
Is there a core libraries policy on this? |
I am in agreement with @simonmar, |
Well, what makes me sad is that my development experience is more painful than it should be. I've been promised revolutionary debuggers for lazy functional programming languages in the form of 30-years old PhD theses that would rock my world if only someone would implement them. Python, Java, Ruby and Erlang have reasonable behaviours in the presence of exception. In Haskell we have promises from a time when I wasn't even born. Sorry for the salt in this message but the magic solutions that were promised when Oleg tackled the problem with Data.List functions still haven't shown up, and I have to work on Haddock in the meantime. Unless you're offering your help to work on Haddock @simonmar? In which case I'd be delighted. |
@mpickering Are these methods real? Do they have an entry in a manual somewhere? Is this something that can be used today? What are the drawbacks? |
Does profiling not work for you? |
What should |
I've had good luck with |
The amount of times I've seen the Usually it's some heisenbug that is a PITA to replicate to even have a guess at what gone wrong. So offline options like profiling wouldn't solve that. I don't care if that would be fixed with |
@ocharles And I'm glad that you've had good luck, I really am. But it doesn't seem to be what is needed here, from the results: https://paste.tomsmeding.com/zXemIGRu |
Hmm yes, it seems the actual error doesn't even show up there - that's no good! I think line 2651 is just your normal stderr, right? If so, I think that provides some motivation to this very issue. |
@ocharles 🎯 bullseye. |
What I'm really asking here is whether we've decided as a community that what we want to do is add |
It might be worth moving that out of this issue, even if it means this issue's discussion is blocked until that discussion settles. I only suggest this because I think there is a discussion to be had about exactly what @Kleidukos is proposed. One thought I had is in response to @simonmar
Yes, but in the context of this issue we're discussing |
I'd really like to see If Currently, |
@cdsmith Including it in the SomeException itself is impossible; we'd need to attach it outside somehow. A side benefit of that is that "while we're at it" we can tack on a bit indicating whether the exception is synchronous or asynchronous, which we currently don't have. The problem with enabling stack traces by default is that I believe they're fairly expensive. I'd certainly want to be able to turn that off. |
In my opinion we should rather focus our efforts on making sure that the backtrace provenance proposal makes it into 9.8 rather than continue to paper around the deeper issue of lacking backtrace support with more I would invite anyone interested in this area to refer to the proposal. Those interested in further detail on some of the lower-cost alternatives to |
@bgamari I'm glad to see that there are pragmatic solutions in the works. |
We've been through this argument multiple times, starting from https://mail.haskell.org/pipermail/libraries/2021-May/031246.html. No, profiling does not work: it's generally not possible to provide clients with a debug build and it is generally impossible to reproduce their environment reliably.
Core libraries have already converged to the opinion that indexing requires
I support adding @Kleidukos did you try to annotate instances with |
I support the stances of Ben and Simon Marlowe here. Bounds checking merely uses up branch predictor resources and can be a mostly hidden cost, whereas has call stack increases register resources, in a largely invisible way. And will also I suppose create a heap allocation and check! There’s some unfathomably bad regressions this will have on real code out there. the extra allocations from building the stack up would trigger minor gcs in zero allocation checked index code. |
I'm not convinced that adding |
It’s a shame I missed the vector discussion, because vector historically had an excellent solution: cabal build flags. Which are super easy to toggle with cabal.project files. But I’ve been busy with personal health matters much of the last 2-3 years. There should never be a “silent memory corruption ” vs “robust inner loop performance” in how operations are implemented. |
wait, does hascallstack stay an implicit parameter with associated heap allocations are runtime though? that can still be an issue there. That said, if you can show me core with an example that hoists that computation out of the innerloop (and robustly so), i'm super cool with all of this. |
Ok, but this is somewhat moving the goal posts. We can't have |
The EDIT: I see you just changed that. |
The error that |
Ok, that's fair - read my point as more about the error message itself. |
its worth remembering on some platforms we already have Stack Walking. Which only has a performance cost in the case of an error. The lack of dwarf stack traces on Darwin platforms is an issue of having the libraries for the RTS to correctly stack walk on MachO dwarf, rather than a fundamental limit. (I'm not sure what the corresponding story is on windows though) |
additionally, we can totally in the @Ericson2314 future, have Cabal Flags for build flavors of base that allow application builders / developers to choose which tradeoffs matter to them via some innocent cabal-flags about these very nuanced topics. |
@Bodigrim Somewhat shockingly (imo),
I experimented here: https://github.com/tbidne/hcs-class/blob/main/src/Lib.hs. |
Annotating both method declaration and implementation is perfect! Thanks @tbidne |
Just to conclude on my thoughts regarding @bgamari's work on ghc-proposals/ghc-proposals#330: As soon as we can migrate from HasCallStack to this, I'll be in the front-lines to submit migration patches. |
@tbidne You may be interested in https://gitlab.haskell.org/ghc/ghc/-/issues/22103, a discussion related to |
@adamgundry Thanks for the link; that's helpful. I was aware instances could provide more polymorphic signatures, but did not consider how this could interact with |
@Bodigrim says,
Sadly, this isn't quite true. If there is a |
Indeed. Which is exactly I’m im a tad sad to hear that’s not hidden behind
a build flag In vector. (I’m willing to slap together a patch for vector in
that direction if there’s appetite). Allocations within inner loops can be
problematic :(
…On Thu, Jan 19, 2023 at 9:08 AM Ben Gamari ***@***.***> wrote:
@Bodigrim <https://github.com/Bodigrim> says,
I'm not convinced that adding HasCallStack to index has measurable
performance impact. If index gets inlined in a monomorphic context (which
it usually does, being a very small function), there is no extra cost to
pay.
Sadly, this isn't quite true. If there is a CallStack from the call-site
of the index then we will incur another 4 words of (likely garbage)
allocation every time index is called.
—
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAABBQWSP44OVKTC3FNDVA3WTFDGJANCNFSM6AAAAAATZFGVWU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@Kleidukos what's the conclusion on this? Would you like to proceed with a vote? |
After a chat with @bgamari I have come to the decision to close the process. The inability to backport such a change (as it would create a context due to the nature of My thanks to everyone who helped with various suggestions, this has really helped crystallising the difficulties that we encounter as a community to teach and transmit our best practices when using Haskell in anger. |
Context
While working on a codebase that makes use of
Data.Ix
methods likeindex
, one can get such feedback:(haddock here is the program being working on)
I believe we deserve better traces when working with functions that throw exceptions like this.
Proposal
I'd like to add HasCallStack constraints to the methods of
Data.Ix
so that our life becomes less miserable when encountering such issues.Implementation
A draft implementation is up on the GHC GitLab at: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9694
The text was updated successfully, but these errors were encountered: