You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# GoldenDict-ng Startup Performance Optimization Record
2
+
3
+
## 1. Optimization Goal
4
+
Reduce interface stuttering during cold start, shorten the perceived time from clicking to displaying the main window, and lower the CPU and disk I/O peaks during the startup phase.
Decouple non-critical tasks from the `MainWindow` constructor and synchronous initialization flow. Utilize `QTimer::singleShot` to trigger these tasks in stages after the main event loop starts, achieving a "progressive startup."
|**ArticleInspector (Debugger)**| Sync creation in constructor |**Lazy creation**| Instantiated only when "Inspect Element" is triggered |
14
+
|**ScanPopup (Scan Progress)**| Sync trigger in constructor |**Delayed 1,000ms**| Avoids QWebEngine loading blocking main window display |
15
+
|**TrayIcon**| Sync init in constructor |**Delayed 1,000ms**| Reduces synchronous communication with system shell |
16
+
|**GlobalHotkeys**| Sync installation in constructor |**Delayed 2,000ms**| Moves system-level hotkey registration to background |
17
+
|**doDeferredInit (Deep Init)**| Sync execution at end of constructor |**Delayed 3,000ms**| Avoids peak I/O for file handles and abbreviation loading |
18
+
|**FullTextSearch (FTS Indexing)**| Sync start in `makeDictionaries`|**Delayed 5,000ms**| Ensures UI is idle before starting large-scale disk scanning |
19
+
|**New Release Check**| Immediate execution (0ms) |**Delayed 10,000ms**| Moves network requests and JSON parsing after stability |
For the `doDeferredInit` delay, existing dictionary class implementations (e.g., `DslDictionary`, `MdxDictionary`) already include `ensureInitDone()` protection logic.
25
+
-**Safety**: If a user performs a lookup or FTS search before the delay (3s) expires, the code will automatically trigger synchronous initialization, ensuring no loss of functionality.
26
+
-**Experience**: The delay is only to release system resources and does not cause functional deadlocks.
27
+
28
+
### 4.2 UI Responsiveness Priority
29
+
By delaying `ScanPopup` and `ArticleInspector` (both WebEngine-driven), we significantly reduce the peak frequency of VRAM and RAM allocation, allowing the main viewport (`ArticleView`) to complete its first-paint at the highest priority.
30
+
31
+
## 5. Expected Results
32
+
-**Perceived Speedup**: Main window display speed improved by 30% - 50%.
33
+
-**I/O Peak Shaving**: Smooths the disk I/O "spike" from massive dictionary loading into a sustained "low-load" process over several seconds.
34
+
-**Stability**: Reduces the probability of thread deadlocks or UI freezes caused by resource contention during critical startup moments.
0 commit comments