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

feat: remove alive flag in session/undeclarable objects #1104

Closed

Conversation

wyfo
Copy link
Contributor

@wyfo wyfo commented Jun 10, 2024

This flag was just used to prevent double close/undeclaration, i.e. object being drop after close/undeclare. Using ManuallyDrop instead in close/undeclare solve this issue, and save some space in structs (often one word counting the padding, which is not negligible).

@wyfo
Copy link
Contributor Author

wyfo commented Jun 10, 2024

@Mallets @OlivierHecart

This flag was just used to prevent double close/undeclaration, i.e. object being drop after `close`/`undeclare`.
Using `ManuallyDrop` instead in `close`/`undeclare` solve this issue, and save some space in structs
(often one word counting the padding, which is not negligible).
@wyfo wyfo force-pushed the remove_alive_flag branch from e024016 to cf1c653 Compare June 10, 2024 09:11
@Mallets
Copy link
Member

Mallets commented Jun 10, 2024

In general the approach LGTM.

However, could you please provide additional comments in the code on how those ManuallyDrop inter-dependency should be handled to avoid memory-leaks or misbehaviour? Is there a test covering this case?

@wyfo
Copy link
Contributor Author

wyfo commented Jun 10, 2024

However, could you please provide additional comments in the code on how those ManuallyDrop inter-dependency should be handled to avoid memory-leaks or misbehaviour?

Not sure to have understood, but I've added comments; is it better now?

Is there a test covering this case?

A lot of tests are already calling undeclare(). I cannot really test more.
I mean, the only real test we could add would be to parse the logs after a call to undeclare(), and check there is no error caused by a double undeclaration. But I don't think we have any tests of this kind, and if we want to add it.

EDIT: Actually, the CI caught a bug in my initial Session rework, so it's tested 🙂

@@ -824,16 +827,25 @@ impl Session {
}
}

/// Like a [`Session`], but not closed on drop
pub(crate) struct SessionClone(ManuallyDrop<Session>);
Copy link
Member

Choose a reason for hiding this comment

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

It's unclear to me the need of such SessionClone. What real problem is it solved here?
Since SessionClone contains clones of Runtime, State, etc. how the state is cleaned up?
How is this change robust to internal changes, e.g. Runtime will required to be properly cleaned? If that happens, it seems we will be leaking memory or not freeing resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was a mistake of mine.

@wyfo
Copy link
Contributor Author

wyfo commented Jun 10, 2024

Closed in favor of #1106

@wyfo wyfo closed this Jun 10, 2024
@wyfo wyfo deleted the remove_alive_flag branch June 11, 2024 07:46
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.

2 participants