dsh-carrick-optimize
A small DSH plugin that warms session discovery so the history sidebar is ready before the first request.
DSH's session/list walks every project and session directory, opens each log header, decompresses it, and stats the file. On a corpus with ~1,200 sessions that costs about a second per call, and the browser waits for it before rendering history. This plugin moves that scan to boot and caches the result.
What it does
- Prewarms
ctx.sessionPersistence.list()after startup and serves it from a stale-while-revalidate cache. - Invalidates on
session/createdandsession/disposed, so new sessions do not wait for the TTL. - Optionally prewarms the most recently updated N sessions into the session-query observation cache.
- Leaves live-session merging to
sessionQuery, so running sessions and their titles stay fresh. - Restores the original method and clears its timer on unload.
Measured on DSH 0.2.1-rc.3 with 801 sessions: first session/list 306–376ms → 47–94ms.
Install
dsh plugin --profile web add git+https://github.com/Carrick-K7/dsh-carrick-optimize.git#v0.1.0
# restart DSH
Or from a packed tarball:
dsh plugin --profile web add file:/path/to/dsh-carrick-optimize-0.1.0.tgz
The package's cordis.patch.yml inserts:
- insert:
- id: carrick-optimize
name: dsh-carrick-optimize
Config
Override the entry in the profile patch:
- id: carrick-optimize
config:
listTtlMs: 60000
prewarmList: true
prewarmDelayMs: 500
prewarmSessions: 2
| Key | Default | Meaning |
|---|---|---|
enabled |
true |
Disable the plugin |
listTtlMs |
60000 |
Cache window before background revalidation |
prewarmList |
true |
Warm the listing at boot |
prewarmDelayMs |
500 |
Delay before boot prewarm |
prewarmSessions |
2 |
Recent sessions to decode; 0 disables |
prewarmMaxSessionBytes |
24 MiB | Skip larger single logs |
prewarmTotalBytes |
48 MiB | Total compressed-byte budget |
Scope
- This speeds up the history list and the first open of prewarmed sessions. It does not make an arbitrary cold session instant: DSH's concatenated Zstandard log needs a full decode, and pagination/projection need the full event array.
- Plugin bundle loading is not affected.
/pluginsalready servesCache-Control: public, max-age=31536000, immutable.
Development
npm test
npm run check
Compatibility
Targets DSH 0.2.1-rc.3 (Cordis 4). It patches ctx.sessionPersistence.list, an internal service; revalidate after DSH upgrades. If the service is missing or already patched, the plugin stays idle and logs a warning.
License
MIT
No comments yet. Be the first to write one.