Skip to content

Conversation

@kentonv
Copy link
Member

@kentonv kentonv commented Nov 14, 2024

I'd forgotten to internalize the string, but the hash map was comparing strings by identity, so computed strings would always miss cache. (Worse, their hash codes were computed by content, so they would cause excessive hash collisions.)

@kentonv kentonv requested a review from justin-mp November 14, 2024 16:02
@kentonv kentonv requested review from a team as code owners November 14, 2024 16:02
I'd forgotten to internalize the string, but the hash map was comparing strings by identity, so computed strings would always miss cache. (Worse, their hash codes were computed by content, so they would cause excessive hash collisions.)
@kentonv kentonv force-pushed the kenton/fix-sql-cache branch from 6bc0b12 to cc4c191 Compare November 14, 2024 16:12
@kentonv kentonv merged commit 8e9bcd5 into main Nov 14, 2024
13 of 14 checks passed
@kentonv kentonv deleted the kenton/fix-sql-cache branch November 14, 2024 17:23
// to all other internalized strings with the same content. If the string is already
// internalized, this returns the same value. Note that strings originating from literals in the
// code are always internalized.
JsString internalize(Lock& js) const;
Copy link
Contributor

@jclee jclee Nov 14, 2024

Choose a reason for hiding this comment

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

Huh... Looks like the V8 headers have a comment that says internalization is a "hint", which makes me wonder if there are cases where it is (or was, in some earlier V8?) not guaranteed to be applied.

Not that it particularly matters for this change, since it's just improving the performance of cache lookups, which seems consistent with V8's other uses of internalization. And the tests should let us know if it breaks for some reason.

https://github.com/v8/v8/blob/13.1.201.8/include/v8-primitive.h#L113-L118

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.

5 participants