Skip to content

Simplify building the platform state key - #3085

Open
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:resources-platform-state-startup
Open

vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:resources-platform-state-startup

Conversation

@vogella

@vogella vogella commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Extracts the per-bundle formatting and SHA-256 hashing of ContentDescriptionManager.getCurrentPlatformState into toStateEntry and hash helper methods, using plain concatenation instead of String.format so the stream pipeline and state calculation are easier to read. The resulting key is unchanged, so the persisted content description cache stays valid.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   38m 39s ⏱️ +49s
 5 029 tests ±0   5 005 ✅  - 1   22 💤 ±0  0 ❌ ±0  2 🔥 +1 
12 978 runs  ±0  12 822 ✅  - 1  154 💤 ±0  0 ❌ ±0  2 🔥 +1 

For more details on these errors, see this check.

Results for commit 95d3227. ± Comparison against base commit a399aac.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the resources-platform-state-startup branch from 7e91b30 to 34d3d1e Compare November 30, 2026 04:40

@laeubi laeubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you please share a numbers here that are attributed to the String#format versus String concatenation? Also its unclear what "this method" means the call you change is not a method but a lamda (where a method would make it much more readable here).

To be honest I doubt we get any noticeable "improvement" here, the SHA-256 and its repeated lookup a few lines below is likely much more expensive than a String.format and this makes an already hard to read construct even harder to read (see my comment).

String ID = Arrays.stream(bundleContext.getBundles())
.map(bundle -> String.format("%d %s %s", bundle.getBundleId(), bundle.getSymbolicName(), //$NON-NLS-1$
bundle.getVersion()))
.map(bundle -> bundle.getBundleId() + " " + bundle.getSymbolicName() + " " + bundle.getVersion()) //$NON-NLS-1$ //$NON-NLS-2$

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is already hard to read, I would suggest to extract it into a method in any case.

@laeubi

laeubi commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

I wanted to see the effect myself, so I wrote a small plain-Java reproducer (same pipeline: map, sorted, joining, then SHA-256; synthetic bundles; no JMH, so indicative only).

Warm (JIT-compiled, 868 bundles):

  • String.format: ~0.3-0.4 ms
  • concatenation: ~0.08 ms
  • SHA-256 over the result: ~0.15 ms

Even with 10 000 bundles it is ~3 ms vs. ~0.8 ms.
So in steady state I can't see how this method could take a quarter of the workspace opening time.

Cold (fresh JVM, single call, 868 bundles):

  • String.format: ~17-23 ms
  • concatenation: ~1-5 ms
  • SHA-256 (MessageDigest + provider set-up): ~12-20 ms

So there is a one-time cost, and my claim that the digest is the bigger part was wrong: both are of similar size.
But this cold cost is mostly class loading and initialization, which probably already happened elsewhere in a real Eclipse startup.
It would also be attributed to whoever calls first, and JFR sampling/overhead can inflate such a short window.

@vogella

vogella commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

I'll drop the performance claim from the PR.

Comment on lines 509 to 513

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having this in a method would likely also improve readability.

@vogella
vogella force-pushed the resources-platform-state-startup branch from 34d3d1e to edac991 Compare November 30, 2026 05:55
@vogella vogella changed the title Build the platform state key without String.format at workspace startup Simplify building the platform state key Nov 30, 2026
Extract the per-bundle formatting and SHA-256 hashing of getCurrentPlatformState into toStateEntry and hash helper methods, using plain concatenation instead of String.format. The resulting key is unchanged.

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@vogella
vogella force-pushed the resources-platform-state-startup branch from edac991 to 95d3227 Compare December 2, 2026 15:23
@vogella
vogella requested a review from laeubi December 2, 2026 15:24
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