Implement our OOM-handling SecondaryMap from scratch#12621
Implement our OOM-handling SecondaryMap from scratch#12621fitzgen wants to merge 1 commit intobytecodealliance:mainfrom
SecondaryMap from scratch#12621Conversation
|
I'll be honest in that I continue to not really understand |
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "cranelift", "fuzzing", "wasmtime:api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
It is for whenever you want to associate extra data with a For example, in the
The key is already bounded by |
To say it another way that may also help (I've had this question too in the past):
So in Cranelift we tend to use them where we know most IDs will have an entry. Using a |
I realized we need to adjust its `V: Clone` bound into `V: TryClone` which means that we can no longer actually just wrap an inner `cranelift_entity::SecondaryMap<K, V>` and need to instead implement our own. This also made me realize that we need `remove` to be fallible because, when the entry being removed is in bounds, it overwrites the entry with the default value, but that default value needs to be `TryClone`d now which is, of course, a fallible operation.
9a7c37a to
3bba88d
Compare
|
Setting aside my reservations about Bringing back my reservations about The reason I also bring this up is that I don't feel this extra data structure implementation is necessarily justified. In practice the default value for |
It might be good to understand whether this is the case or not more objectively. Picking one use-site in the type interner, for example, here ( More broadly: I'm somewhat concerned that we're discussing the existential fate of And we should be clear about both asymptotic and implementation efficiency: (i) the I think we should satisfy ourselves that we do need the data structure, get everyone on that page, and then move discussion on toward only how to implement it. |
|
Also: @alexcrichton in addition to thoughts on the above, could you clarify what you mean by "model things as PrimaryMap"? A SecondaryMap is fundamentally different in that it associates values with existing IDs, while a PrimaryMap allocates new IDs for values that are inserted, so one can't be replaced with the other. |
|
Sorry I'm doing my best to disentangle my bias against I still want to clarify, though, what's the imapct of not having this PR at all? Does this actively block some OOM-handling work for example? My current understanding is that this fixes a footgun with Orthogonally it's probably most productive for me to just keep my concerns about |
Well, I guess that's why I'm asking about value-presence density for the specific use-cases in Wasmtime above. The one that I linked for func-type trampolines should be dense for most modules today, so using a |
|
I'm not actaully sure what the best data structure for Wasmtime is, but my assumption is that we'd replace it with As for the best data structure, we can construct things every which way: modules with the |
OK, so there's the root of the misunderstanding: the above is not true; a Given all that, a |
I realized we need to adjust its
V: Clonebound intoV: TryClonewhich meansthat we can no longer actually just wrap an inner
cranelift_entity::SecondaryMap<K, V>and need to instead implement ourown. This also made me realize that we need
removeto be fallible because,when the entry being removed is in bounds, it overwrites the entry with the
default value, but that default value needs to be
TryCloned now which is, ofcourse, a fallible operation.
Depends on
TryCloneforArc<T>,Option<T>, andResult<T, E>#12615TryCloneforGcLayout#12616TryCloneforPackedOption#12617TryCloneforRegisteredTypeandRecGroupEntryin the types registry #12619clearmethod to our OOM-handlingVec#12620