Skip to content

Compare the matcher context once per content type lookup - #2930

Open
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:content-type-context-compare-once
Open

vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:content-type-context-compare-once

Conversation

@vogella

@vogella vogella commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Opening an editor on a file in a project froze the UI in content type lookup. ContentTypeCatalog compared the matcher's scope context against the default context for every content type it visited, and for a project matcher that comparison resolves the project's content type preferences, which walks preference nodes and does a workspace tree lookup. With hundreds of installed content types one file lookup did hundreds of tree lookups, and it repeated for every content type query on a project resource.

The comparison now happens once per lookup in internalFindContentTypesSorted and its result is passed down to ContentType.hasFileSpec, so behaviour is unchanged for projects with and without project specific content type settings. Measured with the migrated ContentDescriptionPerformanceTest from #2929 and its 300 extra xml content types, 1000 project matcher look-ups drop from about 60 ms to 35 ms and the cold description pass over 5000 files from about 1 s to 0.65 s. The content type tests in org.eclipse.core.tests.resources pass with the bundle in the reactor.

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   59m 9s ⏱️ + 3m 12s
 4 810 tests ±0   4 788 ✅ ±0   22 💤 ±0  0 ❌ ±0 
12 321 runs  ±0  12 168 ✅ ±0  153 💤 ±0  0 ❌ ±0 

Results for commit abe5985. ± Comparison against base commit 64623ea.

♻️ This comment has been updated with latest results.

ContentTypeCatalog compared the matcher's scope context against the
default context for every content type it visited. For a project
matcher that comparison resolves the project's content type
preferences, which walks preference nodes and the workspace tree, so a
single file lookup did hundreds of tree lookups and froze the UI when
opening editors.

The comparison now happens once in internalFindContentTypesSorted and
its result is passed down to ContentType.hasFileSpec.

With ContentDescriptionPerformanceTest and its 300 extra xml content
types, 1000 project matcher look-ups drop from about 60 ms to 35 ms and
the cold description pass over 5000 files from about 1 s to 0.65 s.

Assisted-by: multiple AI agents and layers of automated tooling 🤖

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused optimization preserves existing matching behavior and introduces no unresolved issues.

Pull request overview

Optimizes project-scoped content-type lookup by reusing the default-context comparison.

Changes:

  • Compute context equality once per lookup.
  • Pass the result through name and extension matching.
File summaries
File Description
ContentTypeCatalog.java Reuses the context comparison throughout lookup.
ContentType.java Adds an internal overload accepting the cached result.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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