-
Notifications
You must be signed in to change notification settings - Fork 0
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
Collaboration with alloc-wg and @CAD97's foundation grant #6
Comments
Hello! I'd love to help with pushing storages forwards towards Some quick thoughts here: I think untyping the handle loses some ergonomics, but also understandably simplifies the API, one of my current big pains is that a typed handle can't have a useful supertrait due to lack of things like casting support. You seem to have ended on a similar API, with some slightly different specific choices, but that may be a good point towards it as a good choice for the final API design - We separately came up with basically the same API from the original POC. I decided instead of |
Let me summarize my understanding of the trait net:
I think the guarantees/requirements of my From this I think my The exact behavior here is a complex combination of multiple refinements' interactions, but I think I do need to clarify that You would think that we could just have The one storage type (other than the All you have to do to understand the footgun that is I have talked myself in a circle and am not sure what my position is anymore w.r.t. this, let me walk away and mull on it for a bit. As for But the case of requiring a reference to the storage is more complicated. Obviously it's useful for your It's worth noting that Still, personally I'd prefer spelling it What usecases do you have for unleaking / reverse handle lookup with non-pointer types? And because I don't have a better place to note it right now: consider the rename: Also, we've just found that Apologies for the big brain dump. Hopefully I'll be able to set up an initiative/tracking repo/issue to keep track of these things in the near-ish future, but right now, this is it 🙃 (since I can't really start in on a libcollections fork until rust-lang/rust#97052 is available in bootstrap without a huge amount of distracting |
Bottom to Top: No problem with the brain dump, I appreciate the thoughts on potential API ramifications and etc, once there's a single location these thoughts can hopefully be centralized, and probably use issues or such to track these kinds of API decisions. The rename would probably be fine I think, but also that's probably the kind of thing that will get some bikeshedding later on :P From everything you've said, I agree that bounding the handle might be nicer. My use case was more about being able to relax |
Oh hi! I hadn't seen this until I saw it pop up in rust-lang/rust#97052.
I'm part of alloc-wg and about two months ago I picked up the Storage API again in this repo: https://github.com/CAD97/storages-api (docs: https://cad97.github.io/storages-api/storage_api/index.html)
As part of this refinement and simplification push, I ended up converting the
Storage
trait to be untyped: that is,Storage::Handle
is no longer a GAT, and notably this means that handle resolution can return regular references to[MaybeUninit<u8>]
rather than pointers with difficult to explain invalidation rules.There's some miscellaneous renaming involved, but also the simplification brought us down to a set of just four traits:
Storage
,SharedMutabilityStorage
,PinningStorage
, andMultipleStorage
. I've been advised (and agree) that controlling complexity is important here for a path to std inclusion; even with this simplified API surface without GAT, it's still a contender for the most complex API exposed by std. And that complexity is safety critical.I'm fairly convinced that the current shape in my repo is minimal for what we want to support, but I wasn't thinking the previous POC was terribly over-engineered1 either, so it's possible that a further simplification is hiding.
matthieu-m agrees that the untyping of storage is probably a good direction; the previous storage API was not typed due to some conscious decision due to necessity, but because it evolved from C++'s
std::allocator
design, which is typed, and matthiue-m just hadn't considered using an untyped interface. This does mean that usage of the storage traits becomes moreunsafe
/difficult, but this is easily addressed by adding a typedRawBox
aroundStorage
,RawVec
aroundStorage
of slices, and maybeRawArena
aroundMultipleStorage
? as a bridge between raw storage and high-level collections.(It's also quite possible that matthieu-m overlooked the possibility of making handles untyped because of the relative newness of the pointee metadata APIs at the time, in order to draw the conclusion that
S::Handle<T>
can be replaced by(S::Handle, <T as Pointee>::Metadata)
.)Anyway, getting to the point:
I received a Rust Foundation Community Grant. My project is sort of two projects; the first is unrelated work in the tracing ecosystem, but the second half (scheduled Oct..=Dec) is to develop and push the Storage API to an MCP. rust-lang/rust#97052 is actually an early start on prerequisite work for upstreaming storages, as otherwise a storage-generic
Box
can't be coerced.My plan for MCPing the Storage API is basically broken down into the following three parallel steps:
#[no_std]
compatible, so while refactoring in-place has the benefits of full API coverage and ease of "build with my fork of std" testing, wanting to move things into libcore means the diff would be little better than an external crate. Plus having to deal with std iteration times.tower::Service
" article.Allocator
trait.Ultimately, I think that this MCP is where the Storage API either sinks or swims. Either it gets accepted for in-tree implementation/experimentation, or it gets rejected, likely on the matter of being insufficiently motivated for std inclusion given its complexity. Especially given the async-wg group w.r.t. async in traits (e.g.
dyn*
), now really does feel like the time to say if we want to makeBox
the "owning handle to some storage" or if it's just an owning pointer to allocated memory. My claim is thatBox<T, ?>
can be both&move T
anddyn* T
, as well asInlineMaxSizeDst<T>
and so much more, so its a matter of proving it worth it.I'd like to work together, or at the very least avoid duplicating work you've already done unnecessarily. Adding your experience working with (your modified copy of) the storage API will help to strengthen the motivation provided in the MCP.
...I don't really know how to end this info dump. I guess...
TL;DR: Hi 👋 I'm working on the Storage API and would like to incorporate your experience working with it.
Footnotes
Even back then I disagreed on some details with matthieu-m, which ended up being integrated into the most recent iteration. Notably, matthieu-m had separate API trees for "
Element
" and "Range
" storage, but I've always advocated for "Range
" storage to just be "Element
" storage of an array/slice. Along with this difference is that matthieu-m's element storage takesT
to place it, whereas mine previously took<T as Pointee>::Metadata
(when it was still typed) and now just deals inLayout
. ↩The text was updated successfully, but these errors were encountered: