Skip to content

perf: look up case sensitivity without locking - #1584

Merged
rubenporras merged 1 commit into
dsldevkit:masterfrom
rubenporras:perf/case-sensitive-lookup
Oct 29, 2026
Merged

rubenporras merged 1 commit into
dsldevkit:masterfrom
rubenporras:perf/case-sensitive-lookup

Conversation

@rubenporras

Copy link
Copy Markdown
Member

ConcurrentHashMap.computeIfAbsent checks only the first node of a bin without locking, so a key that shares a bin with another key locks the bin on every call, even when it is already present. EClasses use identity hash codes, so whether this happens differs from run to run. When it hit a frequently used EClass, the compiler's request workers serialized on that bin while resolving proxies (JDK-8161372).

Read the cache with get() first and only call computeIfAbsent on a miss. Also compare case-insensitively first, so that the cache is only consulted for candidate matches rather than for every element of the containment list.

ConcurrentHashMap.computeIfAbsent checks only the first node of a bin
without locking, so a key that shares a bin with another key locks the
bin on every call, even when it is already present. EClasses use
identity hash codes, so whether this happens differs from run to run.
When it hit a frequently used EClass, the compiler's request workers
serialized on that bin while resolving proxies (JDK-8161372).

Read the cache with get() first and only call computeIfAbsent on a
miss. Also compare case-insensitively first, so that the cache is only
consulted for candidate matches rather than for every element of the
containment list.

@joaodinissf joaodinissf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. The get() before computeIfAbsent makes hits lock-free, and the reordered condition matches the same objects. Optional: a test for case-sensitive vs. insensitive sibling lookup, and a note that the contention has been there since d023749 (17.2.0).

Posted by Claude Code on behalf of @joaodinissf.

@rubenporras
rubenporras added this pull request to the merge queue Oct 29, 2026
Merged via the queue into dsldevkit:master with commit 7cd7487 Oct 29, 2026
4 checks passed
@rubenporras
rubenporras deleted the perf/case-sensitive-lookup branch October 29, 2026 10:47
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