Commit 781a921
fix: eliminate repeated JSONL delta reconstruction that starves extension host (#565)
Root cause: the extension host's single-threaded event loop was blocked by
repeated synchronous split+JSON.parse+applyDelta loops on the same large
delta-based JSONL files across multiple analysis helpers, triggering the
VS Code unresponsive watchdog and crash-restart loop.
Three fixes:
1. usageAnalysis.ts: the delta-based JSONL early-return branch in
analyzeSessionUsage now computes model switching inline from the
already-reconstructed sessionState instead of calling
calculateModelSwitching (which re-read the file and called
getModelUsageFromSession for yet another re-read). The non-delta
JSONL and regular JSON paths now pass preloadedContent through to
calculateModelSwitching and trackEnhancedMetrics to avoid re-reads.
2. extension.ts: removed the hidden pre-warm of calculateUsageAnalysisStats
that ran even when the analysis panel was not open. This triggered
workspace customization scans and JSONL processing on every 5-minute
timer tick, amplifying the event-loop starvation on startup.
3. extension.ts: replaced hand-rolled synchronous applyDelta loops in the
session details and log viewer paths with reconstructJsonlStateAsync,
a new helper in tokenEstimation.ts that yields to the event loop every
500 lines to prevent blocking.
Co-authored-by: Rob Bos <rajbos@users.noreply.github.com>1 parent 04099a6 commit 781a921
File tree
3 files changed
+86
-36
lines changed- vscode-extension/src
3 files changed
+86
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
1074 | 1075 | | |
1075 | 1076 | | |
1076 | 1077 | | |
1077 | | - | |
1078 | | - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
1079 | 1082 | | |
1080 | 1083 | | |
1081 | 1084 | | |
| |||
2927 | 2930 | | |
2928 | 2931 | | |
2929 | 2932 | | |
2930 | | - | |
2931 | | - | |
2932 | | - | |
2933 | | - | |
2934 | | - | |
2935 | | - | |
2936 | | - | |
2937 | | - | |
2938 | | - | |
2939 | | - | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
2940 | 2936 | | |
2941 | 2937 | | |
2942 | 2938 | | |
| |||
3443 | 3439 | | |
3444 | 3440 | | |
3445 | 3441 | | |
3446 | | - | |
3447 | | - | |
3448 | | - | |
3449 | | - | |
3450 | | - | |
3451 | | - | |
3452 | | - | |
3453 | | - | |
3454 | | - | |
3455 | | - | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
3456 | 3445 | | |
3457 | 3446 | | |
3458 | 3447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
153 | 180 | | |
154 | 181 | | |
155 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | | - | |
| 559 | + | |
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
563 | | - | |
| 563 | + | |
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
| 596 | + | |
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
722 | | - | |
| 722 | + | |
723 | 723 | | |
724 | | - | |
| 724 | + | |
725 | 725 | | |
726 | 726 | | |
727 | 727 | | |
| |||
1280 | 1280 | | |
1281 | 1281 | | |
1282 | 1282 | | |
1283 | | - | |
1284 | | - | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
1285 | 1319 | | |
1286 | 1320 | | |
1287 | 1321 | | |
| |||
1439 | 1473 | | |
1440 | 1474 | | |
1441 | 1475 | | |
1442 | | - | |
| 1476 | + | |
1443 | 1477 | | |
1444 | 1478 | | |
1445 | 1479 | | |
| |||
1531 | 1565 | | |
1532 | 1566 | | |
1533 | 1567 | | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
1534 | 1574 | | |
1535 | 1575 | | |
1536 | 1576 | | |
1537 | 1577 | | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
1541 | | - | |
1542 | | - | |
1543 | | - | |
1544 | 1578 | | |
1545 | 1579 | | |
1546 | 1580 | | |
| |||
0 commit comments