-
Notifications
You must be signed in to change notification settings - Fork 223
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
Lift burden of single parity-util-mem
version per Repo
#607
Comments
CC @cheme |
The reason we have this restriction is because parity-util-mem is also used to setup a global allocator and if two version are used with different allocators, that will lead to nasty bugs. |
@ordian do you believe there is a reasonable way to solve this anyways? Maybe by syncing the |
I remember we thought splitting the crate in two (allocator choice part and alloc-size trait part) could help. |
Okay. Yeah, thanks for the fast feedback. Currently I close this for now if there is no solution on the horizon. |
One further question:
|
FWIW, I would like to see this crate being removed from Substrate. We don't really use it and there is no real benefit in it. I would more like to switch to something that is being used in the Rust ecosystem (not sure if there currently exists such a crate). |
Before using it we did use one that was being used in the rust ecosystem, but it stops being maintained and we had to use this (we use code from the servo project, which was the more likely to be the next thing getting use by the ecosystem but I think it never did happen). I did not look recently if maybe other crates could be use instead, but I would be pleasantly surprised if there was, and of course would find it great to switch. |
it is the global allocator used by rust so could be use in the wasm build, but in practice I think we only use it to switch to jemalloc in clients builds. |
Dumb question. Why is this not possible to use jemalloc? https://blog.rust-lang.org/2018/08/02/Rust-1.28.html#global-allocators [Edit: Typos] |
That's what the crate does. (the thing that is really awkward with the crate is the trait that needs to be implemented by everyone, the allocator choice is just a small utility with little added value). |
Sorry, it's been a long time since I look at this code. |
Yeah I know where it originates, but the problem is also that our version is also not really maintained anymore. There are some fixes from time to time, but only if they are really required. |
Just out of interest. Could I set my own global allocator in a dependency and then my project would use two different allocators? Or how does the compiler handle this? And would any dependency that defines a global allocator affect the allocator being used? |
You cannot define two global alloc. It will result in a compiling error :( |
That 's why defining the global allocator in a library is a bad idea. |
But then I don't understand the reason for having an artificially single version of this crate introduced .
I |
We already had a bug due to two version of parity-util-mem: paritytech/polkadot#922. |
The issue when using two different version is that you are using two different traits for MallocSizeOf, so then when you compose structure things will not work (eg XCM will impement the trait of parity-util-mem v0.8 but Call will implement the trait of parity-util-mem V0.9, then XCM will not implement any of those). |
Oh yes, that's even worse :( (a bad fix could have been to set the same allocator feature for both version, but it would be hell to maintain). |
But this bug then only results from the wrong estimated size being used by Couldn't we set the Sorry, if I am annoying as hell here, and you can shortcut this if this solution is insufficient, but I really want this restriction to be gone 😄 |
That is similar to idea behind splitting the crate that I mentioned above. So problem like #922 will only show when the crates actually call the size evaluation (which requires importing both split crate), and it is a better situation. But in the end it does only help you producing incompatible implementation of the malloc trait. It is probably the reason why I did not proceed to do the split at the time the idea was previously bring. |
In itself I don't think there is an issue with splitting the crate, it is mainly extracting traits to another crate (derive crate will then use it and the current crate could even reexport so it does not require any other changes). |
@cheme is there some way to test, if the #922 is safely prevented when playing around with this here? I mean, when I change the restriction it goes through, but not if its safe. |
I drafted the split here https://github.com/cheme/parity-common/tree/split-mem, if your code depends only on the new crate, there is absolutely no code touching the global allocator, so I don't really think testing is worth it. This quick draft makes me realize there is a bit of thing that can fail (missing feature reexport, change of feature condition), and I am really not sure anymore if it is worth merging/maintaining. |
Are there any plans for lifting the burden that only a single version of
parity-util-mem
is allowed per project?I am not in the picture if this is solvable, but this restriction currently basically means that projects must use a single substrate version across all their dependencies. Due to the wiring of node and wasm this currently means
node-substrate-version = wasm-substrate-version
.And correct me if I am wrong, this would also mean that projects that actually want to use the
enum Call
from other projects (e.g. for example for creating aXcm<Call>
) must be in sync with respect to substrate version being used.The text was updated successfully, but these errors were encountered: