-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
c api: add EvalState argument to nix_init_* #14592
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
Conversation
We will need this argument in the future as we put things in managed memory. see NixOS#14584 for an example.
|
@Ericson2314 Now that I'm making this PR I realise we might have it backwards. most of the Only the string and path init functions allocate StringData on the heap. |
|
I suppose separate vectors per type will also break that? (Though it is also less clear we can/should do that for values than exprs.) |
|
Yeah that design is (a) not necessary for Values (almost all of them will fit naturally in 8 bytes) (b) not possible for Values (they start out as thunks and then become another type when they're forced) Though after sleeping on it, I realise that we will need an Though I also realised there may be a way to shoehorn all of this into the old API. Are we treating types like Side note: eventually |
|
(It would be possible to make forced thinks a double indirection, which is then cleaned up at GC time, but yes I am suspicious about that.) I lean towards:
I think those choices make for something which is compatible with many types of heap designs. |
|
@Radvendii the types are intentionally opaque so that their implementation contents can be adjusted as needed. Changing these signatures should really be a last resort. Storing something like |
|
What would be the purpose of the Also want to note that changing the size of a type is an observable effect on consumers of the API, even if the type is opaque. Maybe we're expecting people to not depend on that, I just wanted to bring it up in case it needs to be considered. |
|
|
|
Oh @Ericson2314 good point that forced thunks could be an indirection. I don't think there's a compelling reason to design it this way, but I haven't given it much thought yet. I'll bear this in mind. |
|
I just realised that |
|
@Ericson2314 I think this means that we don't need to worry about changing |
Delayed construction when the necessary I do like that it doesn't store the |
|
We can make a new v2 API after we are done, and hack as needed to make the old one back-compat. @Radvendii good to close this then, I think? |
|
Yep! Closing as changing the c api is not necessary. I'll update #14584 so it changes |
|
I'm a bit late to the party, but I'd like to note that since usually operator new hands out (on 64 bit system) already 16 byte aligned pointers we are not wasting any more memory by keeping an EvalState * in nix_value.
|
|
Hmm... Thinking about this more I don't know what you mean @xokdvium.
Changing it to Changing it to Either way we double the memory footprint of |
|
You can only have a reference to the value state (i.e. |
|
The code uses I think maybe this design was a minor mistake, and it would have made more sense to make nix/src/libexpr-c/nix_api_expr_internal.h Lines 40 to 43 in 5caebab
|
|
Ohhh wait if you're talking about the changes I'm making now, I was coming to the same conclusion you were. It can't be |
Motivation
We will need this argument in the future as we put things in managed memory.
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.