Performance trace, load test and chapter read-ahead
A switchable trace (DATA/perf/trace.on or PERF_TRACE=1) records every request's phases (stat, open, first read, disk vs network wait), browser resource timings, page-turn waits and flow stalls, a cold storage probe, event-loop lag, scans and scraper calls as JSONL. tools/perf-report.js says which phase slow loads spend their time in; tools/perf-bench.js simulates readers. READ_AHEAD (default on) reads an opened chapter's pages, then the next chapter's, into the OS cache so a NAS's cold reads stop reaching the browser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ea8a5b40e7
commit
896726a51b
16 files changed
+893
-8
No files matched your search
@@ -74,6 +74,9 @@
|
||||
D = payload;
|
||||
}
|
||||
catch (e) { canvas.textContent = ''; canvas.append(h('p', { class: 'loading' }, e.message + ' · ', h('a', { href: './' }, 'Library'))); return; }
|
||||
// Timings for the server's performance trace, only while an admin has it switched on.
|
||||
const perf = D.perf && window.PerfTrace ? PerfTrace.start('read') : null;
|
||||
let perfFlow = null;
|
||||
|
||||
// An already-open chapter also closes when a window ends or an unlock expires.
|
||||
const checkReadingAccess = async () => {
|
||||
@@ -250,11 +253,13 @@
|
||||
if (mode === 'flow') {
|
||||
els = list.map(p => canvas.appendChild(pageEl(p, true)));
|
||||
endEl = canvas.appendChild(endCard());
|
||||
if (perf) { if (perfFlow) perfFlow.disconnect(); perfFlow = perf.watchFlow(stage, els); }
|
||||
} else if (atEnd) {
|
||||
endEl = canvas.appendChild(endCard());
|
||||
} else {
|
||||
shown = mode === 'page' ? [cur] : spreads[spreadIdx];
|
||||
els = shown.map(k => canvas.appendChild(pageEl(list[k])));
|
||||
if (perf) perf.view(els.map(el => el.firstChild), { mode, page: list[shown[0]].i });
|
||||
// The pages on screen get the bandwidth first, then the next ones are fetched.
|
||||
const token = ++buildToken, waiting = els.map(el => el.firstChild).filter(img => !img.complete);
|
||||
Promise.all(waiting.map(img => new Promise(done => {
|
||||
|
||||
Reference in new issue
Block a user