Add opt-in startup and renderer performance tracing#15
Conversation
There was a problem hiding this comment.
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$ |
There was a problem hiding this comment.
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.
| 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) { |
There was a problem hiding this comment.
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.
| 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) { |
80ad9db to
6eaa1a7
Compare
9e65761 to
dfa878f
Compare
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.
dfa878f to
fb15507
Compare
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=trueand reuses the shared class fromorg.eclipse.core.internal.runtime(introduced by vogella/eclipse.platform#4), so workbench and platform bundles share one~/.eclipse/startup-trace.csvand onerunId. 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.mddocuments both tracers, captured trace sessions, and the analysis approach.Not intended for upstream merge; depends on vogella/eclipse.platform#4 for the shared
StartupTraceclass. Supersedes #13.