-
-
Notifications
You must be signed in to change notification settings - Fork 706
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
Add to PhobosV3 memory allocators from ProjectSidero #9078
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request and interest in making D better, @rikkimax! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#9078" |
de6460e
to
a4f0b18
Compare
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.
Use of @trusted
on functions that may free aliased memory is unsound. These functions must be @system
.
Okay, me Paul and Jonathan are in agreement about allocators must be entirely It is an example of why I recommend using containers (even dynamic array) to manage memory, rather than interact with an allocator directly. The next question that needs an answer to as this has been asked in relation to v2, is related to the GC allocator being |
I don't know what the GC allocator is doing or how you could possibly mark it as We're also going to have to have discussions on how we want to use In any case, I will say that while I'm fine with giving this a cursory glance, I'm not going to spend the time to review it in detail (and honestly, it's way too much code to review all at once). Personally, I think that if you ever need allocators, you're in a very dark place where I do not want to be, and I don't want to see them used in Phobos' API anywhere outside of the actual allocator modules - and I'd be perfectly fine with them not existing in Phobos at all. I don't feel so strongly about that that I'm going to fight to keep them out of Phobos (and clearly, there are folks who very much want them), but if we start doing like C++ did and templating stuff on allocators, I think that we have a serious usability problem. As it is, those template arguments are almost never used in C++. Either way, because I would avoid allocators like the plague, I'm likely not the right person to be making decisions on what exactly their API should look like. I can comment on general language issues, but if an issue is truly allocator-specific, other people (like Paul) are far better qualified than I am. Personally, I think that outside of very niche code, it's a mistake to use allocators (though there are certainly some high performance use cases where they're needed). |
My thoughts. First. This is an absolutely gargantuan PR. @rikkimax, is there any way we can split this up in to more digestible chunks? While on the topic splitting things up, would it be possible to split Second. Allocators have been a perennially contentious topic, with some like @jmdavis being of the opinion that we should not even have them because they are so specialized. And if they are agreed to be included, I am sure that the community has deeply held opinions on what they should look like. @pbackus I know this is a big ask, but would it be possible to review @rikkimax's design and determine if it is suitable for Phobos and how it compares to the existing design? It does not need to be a detailed code review, just enough to get an understanding of it. I know that the existing design has it's flaws and I think the community will be most curious to hear about how this design stacks up against it. Third. Once the first two items are done, we can open this up to the community for discussion on the design, detailed code review, and whether or not we should even have allocators. This is a huge component and I would feel uncomfortable merging this without a very thorough community discussion and review process. |
Ternary can certainly be split out. As for contents,
From my perspective, there isn't a whole lot that specifically needs looking at in terms of appropriateness of inclusion. As long as We can improve and fix bugs later. |
Just looking at
|
Re: should Phobos 3 have allocators. Just as the purpose of the range API is to serve as a common interface between generic algorithms and sources of data, the purpose of an allocator API is to serve as a common interface between generic containers and sources of memory. So, instead of asking "should we have allocators," what we should ask is, "should we have allocator-aware containers"? Given the current state of the D language (i.e., ignoring unreleased/experimental features), it is impossible to implement generic containers that are both (a) Personally, if we can only choose one, my vote would go to |
In neither article do you go into the fact that there is a subset of data structures that can use allocators and be Specifically if the data structure does not allow access to internal memory (at least in The path forward in my view, is to have containers that are classified in behavior, where that behavior is well defined. Some may not be implementable in D today with allocators, and others may lend themselves to GC only, that's fine, we can do both. |
I take it as given that Phobos 3's containers must allow by- |
Some of my data structures do not offer this intentionally and that is a key characteristic for their usage. We can have multiple variations of a data structure, we do not need to gatekeep based on the perceived requirements of a different variation. |
I got a bit sick of people saying allocators won't be coming.
So here we go, here are my ~2 year old allocators.
Some key differences from PhobosV2:
void[]
everywhere.export
) and negative annotation (@hidden
).I did have to add some utility modules such as my test test and set lock, and add Ternary to typecons.