-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
libexpr: allocate ExprPath strings in the allocator #14106
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
0785e68 to
e6f9778
Compare
|
We can remove the accessor field entirely. It was introduced to support lazy trees, but it's no longer needed there since we mount every input on top of I have an unfinished PR stashed away somewhere that does this. I'll have a look at reviving it. |
|
I'm working on reviving Eelco's changes (thanks!) In the meantime that shouldn't impact this PR. |
e6f9778 to
fc12be9
Compare
fc12be9 to
f70b0b5
Compare
|
BTW, is this stuff thread-safe? I'd hate to move away from the goal of having a multi-threaded evaluator. |
|
It doesn't look like it, but a thread-safe bumper allocator sounds easy to implement. All we need is an atomic for bumping the size. |
|
Opened up: #14140 |
| } | ||
| Path path(getHome() + std::string($1.p + 1, $1.l - 1)); | ||
| $$ = new ExprPath(ref<SourceAccessor>(state->rootFS), std::move(path)); | ||
| $$ = new ExprPath(state->alloc, ref<SourceAccessor>(state->rootFS), path); |
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.
can we somehow make state->alloc thread local? That would also solve the issue.
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.
I doubt having more global variables is a good idea. Maybe as a last resort, but it seems unnecessary at this point if there's other avenues we can explore first?
Motivation
See this tracking issue for big-picture plan and motivation
Where does this fall in that picture?
Note that we've added a bunch of copies that weren't necessary before. This doesn't seem to impact performance. In the future, we can address this by passing the allocator down into functions like
getHome()and having them allocate directly there instead.Rant about plans for removing the `accessor` field as well
I would like to also remove `ref accessor`. It does take up 16 needless bytes, but the bigger reason is that eventually I want `ExprInt`, `ExprFloat`, `ExprString`, and `ExprPath`, all the "literals" to be referred to **as** Values directly (See tracking issue's todo item "Combine `Expr`s and `Value`s into one address space...") This would remove a layer of indirection and the need to store the Expr at all, but it requires that they not have any other fields (i.e. `accessor`).The only thing
accessoris doing is incrementing/decrementing a refcount for theSourceAccessor. I scoured the internet and could not find a reasonable way to manually increment / decrement the refcount of anstd::shared_ptr. I did come up with a janky way that involves usingmemsetandmemcpyto skip constructors/destructors, but that seemed like a bad path to go down.I'm now thinking
boost::intrusive_ptris the way to go here, but I think we should tackle that down the road when it actually becomes relevant.Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.