Skip to content
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

Merged
merged 1 commit into from
Dec 6, 2024
Merged

[chore] minor cleanup #763

merged 1 commit into from
Dec 6, 2024

Conversation

jprendes
Copy link
Collaborator

@jprendes jprendes commented Dec 5, 2024

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.

@jprendes jprendes force-pushed the cleanup branch 2 times, most recently from 6aa0035 to f405102 Compare December 5, 2024 13:16
@jprendes jprendes requested review from Mossaka and andreiltd December 5, 2024 13:17
Copy link
Member

@Mossaka Mossaka left a 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?

@Mossaka
Copy link
Member

Mossaka commented Dec 5, 2024

Hold on merging this PR till I finish releasing the shim binaries today!

Copy link
Member

@Mossaka Mossaka left a 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),
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Contributor

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]>
Copy link
Member

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Mossaka Mossaka merged commit 84fadbc into containerd:main Dec 6, 2024
71 checks passed
Copy link
Contributor

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants