-
Notifications
You must be signed in to change notification settings - Fork 16
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
Expose the new primops isByteArrayWeaklyPinned#
and isMutableByteArrayWeaklyPinned#
from GHC.Exts
#283
Comments
I'm afraid I've forgotten the latest status, according to the CLC, of the And for reference, here is a big previous discussion: #146 |
I assume it's the document in the foot note which merely raises the question:
What eventually was voted on was this comment: #146 (comment), according to which the following applies to GHC.Exts:
All that being said none of that really makes a clear proposal about how these or other future primops should be handled in regards to GHC.Exts |
@AndreasPK IMO, there is |
Personally I would prefer a wider design/agreement on how to expose primops via ghc-internal/ghc-experiment/base using a sensible module structure over use of GHC.Exts. But without time to design and implement such a proposal exposing them via GHC.Exts seems like the next best option to me. That being said I'm not adverse to adding it to ghc-experimental instead. But as I understand it the purpose of ghc-experimental is:
So if the CLC wants to stop exposing any primops from base (maybe even deprecating existing ones in the process) that wouldn't be unreasonable but then it seems unclear if these primops should still be exposed via ghc-experimental or simply remain relegated to ghc-internal. But then we also don't want to encourage dependencies on ghc-internal. Making for no obvious solution from my perspective. In light of all these complexities and unanswered questions to me the simplest and most consistent solution would be to expose those via GHC.Exts in line with existing primops and hope for someone to draw up a design for primops in the future. Ultimately the decision lies with the CLC. If the proposal is rejected however I would still welcome concrete suggestions on how to best expose these primops in particular or primops in general. |
I agree that the most sensible solution is to export it from Would that those interested in adding primops be the ones drawing up a design for primops... |
No, there was no particular CLC decision on In this particular case the primops are of primary interest for packages like |
In the long term we should move away from the monolithic That said, there's clearly work to be done to come up with a new design that answers the questions raised in this thread, and that won't happen overnight. Meanwhile, if specific new primops are sufficiently widely useful and stable enough to be desirable in |
If anyone is in favor of re-exporting these primops from |
I think new primops pop up regularly enough (this, #203, #188) that it would be great to figure out for the new primop export design sooner before the next primop is being added. I opened a GHC issue, https://gitlab.haskell.org/ghc/ghc/-/issues/25242 as I think it's more of GHC than CLC issue. |
Oops, sorry, this fall through the cracks. Dear CLC members, let've vote on the proposal to expose the new primops @tomjaguarpaw @mixphix @velveteer @hasufell @parsonsmatt @angerman +1 from me. Using these primops allows to leverage implicit pinnedness, which allows for zero-copy |
+1 |
1 similar comment
+1 |
I am not a voter. but I think this is bad. We don't need to bikeshed a new design, we just need to reexport things elsewhere. Pinned and unpinned arrays is a concept I do not think ever belonged in Really we should default to not adding things to
This strikes me as FUD. Create a new library, put in If we are like "well, everything else like this is already in |
So some functions are in the wrong spot, so these functions should also be in the wrong spot? Also, we don't have to limit ourselves to just We should never say "this should go in |
-1 I think we need to start being stricter. Just because the module already exists and is named Move it elsewhere. |
Weak +1 for exposing more and more primops. |
To clarify this for @hasufell, who asked me to kindly stick to one integer. -1 as proposed. |
@Ericson2314 Library names may be cheap, but designing, publishing and (indefinitely) maintaining new libraries is not. Somebody has to maintain them, and GHC HQ is sufficiently stretched already that it isn't reasonable to add maintenance burden alongside GHC releases. That's why for things like primops that are tightly coupled to GHC version, I think it makes sense for the GHC-maintained user-facing export to be in See also discussion on the role of (This is to some extent orthogonal to the question of whether these primops are useful enough to be worth exposing from |
Somebody has to maintain |
You are saying that 1 big library is much less work than N smaller libraries 1/N as large. That...really ought not to be true! That's really bad if it is true!
Sure, I have no problem with that at all. The raw blanket reexport of all primops is indeed highly experimental, and doesn't belong in But the rest of this discussion was saying that |
I think it makes sense to put these primops in At the moment there are multiple proposals where GHC contributors have tried to persist the status quo. In these threads, the CLC has decided that they don't like the status quo anymore. How are GHC developers supposed to know which one this is before starting to work on a patch? Perhaps the CLC could do some work to write some proposals which remove and deprecate the unstable parts of base which they don't want to maintain. It's my personal view that at the moment the whole process is hugely demotivating GHC development. It would be much better if the CLC could communicate beforehand which parts of the base API they don't want to keep maintaining rather than people repeatedly discovering this after performing a reasonable amount of work. |
Fine with me, we can see just how much
I wanted splitting base to be motivating, not demotivating, for both GHC dev and the CLC, and I agree that that doesn't appear to be happening yet. Something should change.
I am quite sympathetic to this. So long as I strongly encourage everyone to do the big deprecation, then the big breaking change, and get us out of the shitty status quo of dozens of people spending hundreds of hours doing hackage revisions every GHC release. It's absolutely worth the one-time pain of moving out a bunch of modules. And yes, we'll also end up with clear guidelines of what goes where going forward too, avoiding a lot of confusion in these CLC threads going forwards. |
FWIW, agree with this. IMHO |
@mpickering, I definitely don't want GHC developers to feel demotivated! Can you help me understand how the CLC can help them feel more motivated? As far as I understand it, when GHC developers want to add a feature to GHC they can do so without involving the CLC. If their feature requires something to be exposed from a library then, as you suggest, they can do that too, from a variety of libraries controlled by GHC HQ, including You elaborate:
Could you please clarify what you mean by "all these tasks"? Do you mean the task of creating stable packages for functionality exposed from a GHC package? I must have missed people suggesting that GHC maintainers "perform all these tasks". Could you link to the posts in question? My immediate suggestion to GHC developers would be: if, in the first instance, you expose new functionality through packages under the purview of GHC HQ then there's no way that CLC can stand in your way. Is that a good enough first step? After that is an established expectation then we can think about how to improve things further. Or have a missed something that means that that particular suggestion is unworkable? |
That's a general problem with committee driven workflow. You simply can't know beforehand and the proposal process requires an up-front implementation. However, you're free to inquire informally beforehand if something takes a lot of time to implement. But note however that those are still non-binding agreements. A different angle was #141 with the end goal of developing holistic policies for exactly that purpose.
As of now, the CLC isn't receiving any funding to do larger work and we are all volunteers. I expect GHC developers to be on board with the base split and assign resources to drive this forward, including classification of stability of modules. If you lack resources, please contact the HF. When we all discussed the base split, I thought it was clear that this will not come for free. And during that discussion we also agreed that we'd rather vote on a per-module basis, afair. So no one needs to come up with an exhaustive up-front list that will drown in bikeshedding. In the end, we are aiming for a shared goal: less intertwined GHC and base is less work for CLC and for GHC HQ. |
In theory CLC could also ask the HF to provide more resources.
Stable
Sorry, I've heard the pitch "let's wage the war to end all wars" quite a few times, and I'm not buying it. There is a never ending list of "one-time pains", which will cause nothing but resent and discontent.
Judging from https://gitlab.haskell.org/ghc/ghc/-/commit/39497eeda74fc7f1e7ea89292de395b16f69cee2, I take it that we settled on |
There are only orthogonal if we do a huge amount of shimming.
I don't want to do anything dramatically high budget. I just want to not be forced on a breaking change to But I am skeptical it will get done by shimming every last shitty I want the CLC, and you in particular, to be open to some breaking changes of module removal, because the costs of breaking some packages are not necessary higher than the costs of everyone else dealing with |
It's either we are wealthy enough both to break things and provide shims, or we are poor - in which case it would be wise to do neither.
I'm not sure why you are singling me out, because in fact I'm on less conservative part of CLC spectrum. I'm personally quite happy to remove things from base, provided that there is a (short) deprecation period and a proposer has prepared patches for affected packages. That said, judging from my experience as a Hackage trustee, I disagree with your costs analysis here. Assuming nothing was broken for real, even if a maintainer does not have two minutes per year to make a revision, a client can say |
Thanks everyone for the lively discussion! For something like base I think there is a natural tension between a desire for more features and the desire to avoid breaking changes and major versions. Personally I think there is a wide range between bare bones but stable, and feature rich but unstable that can be seen as reasonable. The decision made here gives a good idea of where on this spectrum the CLC thinks base should be. And while it's far closer to the "slim but stable" end than I would have expected, I think it's still in the reasonable range. Given that isByteArrayPinned# was stable for over 5 years, and the primops in question in this proposal would most likely have been just as stable. I think it's fair to treat this vote not just as a vote on these particular primops, but also as guidance for how high the bar for stability is for anything new to make it's way into base. However there is a vast amount of features currently in base falling short of this bar, and there will be new features doing so in the future. At least for those features somewhat closely coupled to GHC I opened https://gitlab.haskell.org/ghc/ghc/-/issues/25326 and would welcome feedback on how GHC should do things from it's side there.
At least technically when adding primops additional exports only require minor version bumps. There is no reason why we couldn't have Or am I missunderstanding your point? In terms of stability most primops have been very stable over time.And I agree that primops that are expected to be unstable in their behaviour or interface shouldn't be exported from base.
I think for new features that’s reasonable. After all there are no existing users that could be inconvenienced! But it becomes more difficult for changes like this one. I proposed to expose those primops via base because this makes it easy for people depending on This has been rejected and that is fine. But a lot of the arguments left me with the impression that the rejection had less to do with how base is, but with how base should be in the future. So now ghc maintainers and users of base alike have to find new ways to work around this. Does someone create a package that gives a more stable interface? Should packages just depend on ghc-experimental? Something else? Who has the time to do any of that? All that causes additional friction justified by the premise that it will be better when those primops will be removed or reorganized in base at some point by someone with no concrete plan in place. It would probably be better to have a ghc-all-array-things or similar package, and to deprecate all these primops in base. But implementing a well designed library takes time and competes with a lot of other tasks for ghc maintainers. This isn’t helped by expectations about how many resources GHC HQ can contribute to such efforts which doesn’t seem to be in line with what’s currently possible.Causing further frustration as expectations on various sides are at odds with each other. Inevitably causing frustration on all sides. |
I don't actually get the impression that the negative votes were to do with "stability" directly. Mine certainly wasn't. Of the four negative votes only @mixphix's mentioned stability. Even if I was given a sworn affidavit that these primops would never change for the next 100 years I still wouldn't want them exposed from
What distinction are you drawing that makes this change not a feature?
That would be my suggestion, yes. If I were a GHC developer then one thing I imagine I might do is advocate for a package I may have missed a good reason that this is unworkable, because I'm not a GHC developer and so I am missing context. Is it unworkable? If so, why?
I'm curious what aspect of creating a new package, purely for re-exports, is time consuming. Could you please elaborate? |
This is a very tempting position to take for CLC, but I'm afraid that kicking the can down the road does not help anyone. The only effect of this pursuit of stability for |
I don't suggest anyone depend on The status quo is that the CLC forces GHC HQ to make their library exports stable by asserting control over I have every confidence that stable packages will be produced, within GHC HQ's remit, for everything that they want to make available to end users. (Admittedly, it's less clear to me how the transition period will work.) |
Free work is in short supply, so I'm pessimistic. But we can say "not our problem" indeed. |
I mistakenly assumed that everyone was already on the same page about how the issue was to be resolved. Perhaps @angerman, @hasufell and @mixphix can share their thoughts about where they assumed these primops would live if not |
AFAICT no one volunteered for anything else than exposing these primops from It is a fine line to walk. IMO there is no point in dogmatic cleansing of |
If I make a package for you that exposes the primitives you need for the purposes mentioned above ( |
Boot packages such as There is no sizeable chunk of ecosystem which depends on "pure" part of |
@mpickering and @AndreasPK have both suggested that someone from outside GHC HQ could make a package to provide a stable interface to those primops.
Therefore, I'm willing to put my free work where my mouth is. I'm willing to make and maintain the boot package. I don't believe it can actually be very hard. Maybe I'm terribly naive, but if so I'll come back with a convincing report in six months about how we really ought to reexport the primops from No one maintains a package indefinitely. We all donate our free work and good faith efforts to the best of our abilities. That's what I commit to do in this initiative. |
Yes, it's time that GHC is getting a proper designed API with a set of packages that don't randomly change. Afair, there was a HF project to help with that: https://discourse.haskell.org/t/charting-a-course-toward-a-stable-api-for-ghc/7646 I don't know what happened to it. However, abusing base for such purposes is wrong. We need better boundaries. Edit: to be clear, I'm aware that the linked HF project was about GHC API (the package). I'm suggesting this needs to be expanded to whatever GHC HQ is producing and those efforts are the responsibility of GHC HQ. |
@Bodigrim I guess this is why I signaled you out. I really believe this sort of reason is 100% backwards -- more smaller libraries and a fine-grained dependency graph is more stable. It is (for sake of argument) the same code, and thus the same points of failure, but failures are less contagious because there are fewer spurious dependencies. I really would like to convince you of this, because ultimately I think we want same/compatible things, but I have no idea how to do so. Thank you so much @tomjaguarpaw for agreeing to create the package. I expect the experience to be quite easy, and I hope everyone can learn from that. |
Very few people gave explicit reasons and the majority of reasons given seemed to had to do with stability/maintainability. Personally I think base should be as wide as it can be without affecting stability but it seems I'm a minority in this regard.
I consider the feature "allow me to check if I need to copy this bytearray for ffi". The new primops don't allow you to do something "new" in that regard because In my mind that's similar to adding a method to a class, a field to a datatype etc.
It's easy to create a new package by just throwing all kinds of re-exports into it without giving it too much though. But I think if this happens one should sit down and carefully think about which concerns the package should cover and what functionality it should therefore expose and how the module structure should look like. If the goal is just to make "GHC.Exts" but in a different package of course that's easy. But the benefits of approaching it that way seem questionable. It would most likely not be any more stable than ghc-internal at that point. That wouldn't really help anyone. Yes a package filling this role doesn't need to be perfect but even doing a good job already takes effort.
If you want to contribute to efforts there I would love for you to give feedback on https://gitlab.haskell.org/ghc/ghc/-/issues/25326 which is about more than just ghc-experimental. Especially on the parts which you intend to cover in your package.
Yes there is no reason why a boot package can't be maintained by someone outside of GHC HQ. It just requires some coordination with GHC HQ especially around ghc releases. |
Those reasons were primarily not given by members of the CLC, as far as I can see.
I agree, though that's asking much more than the status quo! Currently we just throw all (well, a subset of) primitives into
Sounds like you are well ahead of the game. Excellent! I'll continue the discussion there. |
We will add these new primops to GHC in 9.12 (https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13144) and likely backport them to 9.10 as well.
I expect them to be stable and used widely going forward and would like to avoid people depending on ghc-internal for this feature. Therefore I propose we expose it from GHC.Exts in line with most other primops.
For background on the issue see https://gitlab.haskell.org/ghc/ghc/-/issues/22255
For details about what these primops do see the changes to docs/users_guide/exts/ffi.rst in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13144
The text was updated successfully, but these errors were encountered: