Skip to content

Avoid a second tree lookup in Workspace.getResourceInfo - #2883

Open
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:elementtree-single-lookup
Open

Avoid a second tree lookup in Workspace.getResourceInfo#2883
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:elementtree-single-lookup

Conversation

@vogella

@vogella vogella commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Workspace.getResourceInfo is one of the hottest paths in the resources plug-in, and it walked the element tree twice for every read: once through ElementTree.includes and once more through ElementTree.getElementData. The single-slot lookupCache that is supposed to make the second walk free compares keys by identity and is shared by all threads, so with builders and indexers hitting the same ElementTree it gets replaced between the two calls and the second walk runs for real.

This adds the internal ElementTree.getElementDataOrNull, which performs one lookup and returns null when the element is absent, and uses it for the non-mutable case. That removes a full tree walk plus one monitor acquisition per call. Behavior is unchanged: an absent element and an element with null data both already produced null. org.eclipse.core.internal.watson is internal, so there is no API impact.

getResourceInfo walked the element tree twice for every read access:
once through ElementTree.includes and again through
ElementTree.getElementData. The single-slot lookupCache that is meant
to make the second walk free compares keys by identity and is shared
by all threads, so under concurrent access (builders, indexers) it
gets replaced between the two calls and the second walk runs for real.

Add the internal ElementTree.getElementDataOrNull, which does one
lookup and returns null when the element is absent, and use it for the
non-mutable path. This removes one full tree walk plus one monitor
acquisition from the hottest resource access path. Behavior is
unchanged: a missing element and an element with null data both
already resulted in null.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   56m 35s ⏱️ - 1m 23s
 4 761 tests ±0   4 739 ✅ ±0   22 💤 ±0  0 ❌ ±0 
12 174 runs  ±0  12 021 ✅ ±0  153 💤 ±0  0 ❌ ±0 

Results for commit f599e00. ± Comparison against base commit 2fa8a80.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant