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

Interned all strings. #6011

Open
wants to merge 1 commit into
base: dev-v2.7.0
Choose a base branch
from
Open

Interned all strings. #6011

wants to merge 1 commit into from

Conversation

orizi
Copy link
Collaborator

@orizi orizi commented Jul 11, 2024

This change is Reviewable

Copy link
Contributor

@mkaput mkaput left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 124 files reviewed, 1 unresolved discussion (waiting on @gilbens-starkware, @ilyalesokhin-starkware, and @orizi)

a discussion (no related file):
This change sounds like it will create a massive memory leak-style behaviour, especially in the LS. Salsa has no means for garbage collection for interned items (LRU doesn't work there), so it will hard for me to combat in LS.


@ilyalesokhin-starkware
Copy link
Contributor

Why did you remove all the Smolstr usage?

@ilyalesokhin-starkware
Copy link
Contributor

crates/cairo-lang-syntax/src/node/ids.rs line 12 at r1 (raw file):

use crate::node::stable_ptr::SyntaxStablePtr;

define_short_id!(TextId, Arc::<str>, SyntaxGroup, lookup_intern_text, intern_text);

Maybe StringId?
(non-blocking)

Suggestion:

StringId

@ilyalesokhin-starkware
Copy link
Contributor

crates/cairo-lang-semantic/src/items/modifiers.rs line 16 at r1 (raw file):

    modifier_list: &[Modifier],
) -> Mutability {
    let mut last: Option<&Modifier> = None;

why is this change is the same PR?

Code quote:

let mut last: Option<&Modifier> = None;

@ilyalesokhin-starkware
Copy link
Contributor

crates/cairo-lang-semantic/src/resolve/mod.rs line 502 at r1 (raw file):

            ast::PathSegment::WithGenericArgs(_) => false,
            ast::PathSegment::Simple(simple) => {
                simple.ident(syntax_db).text(syntax_db) == TextId::interned("super", self.db)

Suggestion:

simple.ident(syntax_db).text(syntax_db).lookup_intern(self.db).as_ref() == "super"

Copy link
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 92 of 124 files at r1, all commit messages.
Reviewable status: 92 of 124 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware and @orizi)


crates/cairo-lang-semantic/src/resolve/mod.rs line 502 at r1 (raw file):

            ast::PathSegment::WithGenericArgs(_) => false,
            ast::PathSegment::Simple(simple) => {
                simple.ident(syntax_db).text(syntax_db) == TextId::interned("super", self.db)

other places as well.

Copy link
Collaborator Author

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Most of it should just have become the inner arc - there may be some spill over.
in any case - it seems the over abundance of arc is enough of an issue to make this not really worth it.

Reviewable status: 92 of 124 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware, @ilyalesokhin-starkware, and @mkaput)

a discussion (no related file):

Previously, mkaput (Marek Kaput) wrote…

This change sounds like it will create a massive memory leak-style behaviour, especially in the LS. Salsa has no means for garbage collection for interned items (LRU doesn't work there), so it will hard for me to combat in LS.

this is no worse than the entire existing db - only removing the duplication of data.



crates/cairo-lang-semantic/src/items/modifiers.rs line 16 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

why is this change is the same PR?

it was removal of being text dependent.

Copy link
Contributor

@mkaput mkaput left a comment

Choose a reason for hiding this comment

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

Reviewable status: 92 of 124 files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware, @ilyalesokhin-starkware, and @orizi)

a discussion (no related file):

Previously, orizi wrote…

this is no worse than the entire existing db - only removing the duplication of data.

Yes, it is no worse, but it's also not better, and I think it'd be better to only take steps towards better memory management?

Have you measured how much memory is actually deduplicated here? Note that Arc<str> and SmolStr do also deduplicate clones, yet they properly deallocate when the last instance is dropped.


Copy link
Contributor

@mkaput mkaput left a comment

Choose a reason for hiding this comment

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

Reviewed 124 of 124 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @gilbens-starkware, @ilyalesokhin-starkware, and @orizi)

a discussion (no related file):
FYI https://doc.rust-lang.org/stable/alloc/sync/struct.Arc.html#impl-Default-for-Arc%3Cstr%3E stabilized in Rust 1.80


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.

3 participants