SeaORM gives a SQLite pool one connection unless told otherwise, and connect() did not say, so every request, every scan write and every read went through it in turn. Twenty-five people browsing in the load tests (#133) got 50 requests a second out of 12 cores, the fastest answers in 3-30ms and the medians ten times that. SQLite now gets eight. In WAL readers run beside the one writer. Every transaction here writes first, so it takes the write lock or waits out the busy timeout for it; SQLite refuses at once only a transaction holding a snapshot a write has moved past, and none here does. Db::memory switches its file to WAL too, as Db::open does, so the tests share it as the daemon does. A test holds a write open and reads beside it, and fails with one connection. The same browsing: a feed's items at p95 10ms where it was 133, a search 22 where 119, the feed list 89 where 242. The load tests' SQLite budgets are tightened to match; the Rust tests take 2.8s where they took 7.5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
1.1 KiB
JavaScript
20 lines
1.1 KiB
JavaScript
// What the load tests share. Each virtual user is a listener of its own, signed in by name with
|
|
// the header the scratch daemon trusts from 127.0.0.1, as production trusts Cloudflare Access's.
|
|
export const BASE = __ENV.BASE;
|
|
export const USERS = Number(__ENV.USERS || 100);
|
|
export const FEEDS = Number(__ENV.FEEDS || 1500);
|
|
// Each generated feed has this many items; see run.js.
|
|
export const ITEMS = 20;
|
|
|
|
export const as = (name, tag) => ({
|
|
headers: { 'X-Load-User': name, 'Content-Type': 'application/json' },
|
|
tags: { name: tag },
|
|
});
|
|
/// The listener this virtual user is, one of the hundred run.js seeded, thirty feeds each.
|
|
export const me = () => `load-${(__VU - 1) % USERS}`;
|
|
export const pick = a => a[Math.floor(Math.random() * a.length)];
|
|
/// A p95 budget, in ms, for whichever database the daemon is on (run.js --postgres): SQLite reads
|
|
/// a file beside the daemon, Postgres answers over the network, and each is quicker at something.
|
|
export const p95 = (sqlite, postgres) => [`p(95)<${__ENV.DB === 'postgres' ? postgres : sqlite}`];
|
|
export const feedId = n => `gen-${String(n).padStart(4, '0')}`;
|