-
Notifications
You must be signed in to change notification settings - Fork 97
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
[chore] minor cleanup #763
Conversation
6aa0035
to
f405102
Compare
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.
LGTM can you add this change to the CHANGELOG please?
Hold on merging this PR till I finish releasing the shim binaries today! |
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.
Added some comments and I'd suggest to add this change to the Changed
section in CHANGELOG.
@@ -64,7 +65,7 @@ impl<E: Engine> SandboxInstance for Instance<E> { | |||
Ok(Self { | |||
id, | |||
exit_code: WaitableCell::new(), | |||
rootdir, | |||
container: RwLock::new(container), |
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.
question: Why is a lock required for container?
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.
the operations we do on the container (start, kill, delete...) require mutable access, while we are only receiving an immutable reference. That's why we need the lock.
As to what we were doing before, the container object reads and write the state to disk. We were loading the container from disk. There's nothing enforcing synchronization at the filesystem level, but these operations should indeed be synchronized. With the previous version we could have had two mutable Container
instances simultaneously trying to write different states to the same files.
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.
Is there a scenario where that would happen when this is driven by containerd?
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 don't know. @cpuguy83 , do you know the answer?
In any case, I would expect the lock to be cheaper than loading and parsing the state from disk.
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.
It looks like there is a pending question here. I agree with @jprendes that this PR is a net gain for the perf, so I am happy to merge this to the main tree.
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.
Its probably faster in the startup, maybe a bit more memory consumption 🤷
Signed-off-by: Jorge Prendes <[email protected]>
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.
LGTM!
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.
LGTM
This PR reuses the container returned by
libcontainer
instead of reloading it from disk every time.Note: some of the functions removed here were part of the public API, probably incorrectly so.