Skip to content

Add opt-in startup and renderer performance tracing#15

Open
vogella wants to merge 1 commit into
masterfrom
startup-trace-instrumentation
Open

Add opt-in startup and renderer performance tracing#15
vogella wants to merge 1 commit into
masterfrom
startup-trace-instrumentation

Conversation

@vogella
Copy link
Copy Markdown
Owner

@vogella vogella commented Apr 21, 2026

Two complementary tracers for measuring where Eclipse actually spends time, instead of estimating from code inspection. Both emit CSV summaries on JVM shutdown.

StartupTrace is opt-in via -Declipse.startup.trace=true and reuses the shared class from org.eclipse.core.internal.runtime (introduced by vogella/eclipse.platform#4), so workbench and platform bundles share one ~/.eclipse/startup-trace.csv and one runId. Instrumented points cover Workbench.init phases, E4 bootstrap (E4Application, ResourceHandler, ModelAssembler), IDEApplication.start, and the first-touch of context functions in WorkbenchPlugin (PerspectiveRegistry, ViewRegistry, ActionSetRegistry, IntroRegistry, PreferenceManager, ThemeRegistry, WorkingSetManager, WorkingSetRegistry, EditorRegistry). With the property unset, the cost is one static-final boolean read per call site.

RendererPerfTracer is always active in this debug build and writes to ~/renderer-perf-trace.csv (configurable via -Declipse.renderer.perf.trace.file=<path>). It covers 14 hotspots across AreaRenderer, MenuManagerRenderer, MenuManagerRendererFilter, PerspectiveStackRenderer, SashRenderer, StackRenderer, ToolBarManagerRenderer, ToolControlRenderer, ToolItemUpdater, and WBWRenderer, with a persistent writer, shutdown hook, daemon flusher, and a deterministic top-N summary. The H10 showTab probe is split into separate lazy-create and reparent paths.

docs/performance.md documents both tracers, captured trace sessions, and the analysis approach.

Not intended for upstream merge; depends on vogella/eclipse.platform#4 for the shared StartupTrace class. Supersedes #13.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a StartupTrace utility to measure and record the duration of various Eclipse workbench initialization phases. It instruments several key registries and services, such as Workbench, ActionSetRegistry, and ViewRegistry, to capture performance data that is dumped to a CSV file upon JVM shutdown. The review feedback suggests adding a null check for the user.home system property to prevent a potential NullPointerException and improving the CSV escaping logic to correctly handle carriage return characters.

return;
}
try {
Path dir = Path.of(System.getProperty("user.home"), ".eclipse"); //$NON-NLS-1$ //$NON-NLS-2$
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The user.home system property is not guaranteed to be non-null in all environments. If it is null, Path.of(null, ".eclipse") will throw a NullPointerException. It is safer to check for null before proceeding.

Suggested change
Path dir = Path.of(System.getProperty("user.home"), ".eclipse"); //$NON-NLS-1$ //$NON-NLS-2$
String userHome = System.getProperty("user.home"); //$NON-NLS-1$
if (userHome == null) {
return;
}
Path dir = Path.of(userHome, ".eclipse"); //$NON-NLS-1$

if (s == null) {
return ""; //$NON-NLS-1$
}
if (s.indexOf(',') < 0 && s.indexOf('"') < 0 && s.indexOf('\n') < 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The CSV escaping logic should also check for the carriage return character (\r). If a string contains \r but none of the other trigger characters, it will be returned unquoted, which can break the CSV structure in many parsers.

Suggested change
if (s.indexOf(',') < 0 && s.indexOf('"') < 0 && s.indexOf('\n') < 0) {
if (s.indexOf(',') < 0 && s.indexOf('"') < 0 && s.indexOf('\n') < 0 && s.indexOf('\r') < 0) {

@vogella vogella force-pushed the startup-trace-instrumentation branch 3 times, most recently from 80ad9db to 6eaa1a7 Compare April 21, 2026 16:13
@vogella vogella force-pushed the startup-trace-instrumentation branch from 9e65761 to dfa878f Compare May 18, 2026 13:48
@vogella vogella changed the title Add opt-in StartupTrace to measure Workbench startup bottlenecks Add opt-in startup and renderer performance tracing May 18, 2026
Three layers of tracing emit CSV summaries on JVM shutdown, so we can
measure where Workbench startup, renderer execution, and runtime UI
events actually spend time.

StartupTrace (opt-in via -Declipse.startup.trace=true) reuses the
shared StartupTrace from org.eclipse.core.internal.runtime so workbench
and platform bundles share one ~/.eclipse/startup-trace.csv and one
runId. Instrumentation points cover Workbench.init phases, E4
application bootstrap, ResourceHandler, ModelAssembler,
IDEApplication.start, and the first-touch of context functions in
WorkbenchPlugin (PerspectiveRegistry, ViewRegistry, ActionSetRegistry,
IntroRegistry, PreferenceManager, ThemeRegistry, WorkingSetManager,
WorkingSetRegistry, EditorRegistry). With the property unset the cost
is one static-final boolean read per call site.

The same StartupTrace channel also captures runtime UI hotspots:
- DisplayEventProbe installs SWT.PreEvent/SWT.PostEvent listeners on
  the workbench Display and records any event whose dispatch exceeds
  16 ms, keyed by SWT event type (Paint, Selection, MouseDown, etc.).
- WorkbenchLabelProvider.getText/getImage are bracketed so cumulative
  label-provider cost shows up per viewer refresh.
- AbstractCSSEngine.applyStyles records the outermost call (depth
  counter avoids inflating the CSV with every recursive child).

RendererPerfTracer is always active in this debug build and writes to
~/renderer-perf-trace.csv (configurable via
-Declipse.renderer.perf.trace.file=<path>). It covers 14 hotspots
across AreaRenderer, MenuManagerRenderer, MenuManagerRendererFilter,
PerspectiveStackRenderer, SashRenderer, StackRenderer,
ToolBarManagerRenderer, ToolControlRenderer, ToolItemUpdater, and
WBWRenderer, with a persistent writer, shutdown hook, and daemon
flusher. The H10 showTab probe is split into separate lazy-create and
reparent paths.

docs/performance.md documents both tracers, the captured trace
sessions, and the analysis approach.

Not intended for upstream merge; depends on vogella/eclipse.platform#4
for org.eclipse.core.internal.runtime.StartupTrace.
@vogella vogella force-pushed the startup-trace-instrumentation branch from dfa878f to fb15507 Compare May 18, 2026 14:30
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.

1 participant