Răsfoiți Sursa

docs: price the runs_kept raise honestly - the bytes were measured, the per-append cost was not

trimOldest runs on EVERY append with offset = keep over a function_id
filter and a started_at sort, and no index is declared on function_id. So
tenfold keep is tenfold rows held and a correspondingly larger scan per
run, on a box with one vCPU where one tenant's load already degrades
every other tenant proportionally.

The arithmetic says a few ms against a pure DB read measured at 8-35 ms,
at most once a minute per cron function. That is an estimate, this file is
full of warnings about reasoning straight to a magnitude with nothing
counted in between, so the comment says outright that it was not measured
and names the measurement to take. The retention raise stands on the bytes
being cheap, which WAS measured at ~711 a row, and not on this.

Filed as SV-13: index function_id, which makes the trim cost track the
matching rows rather than the collection.
fszontagh 1 lună în urmă
părinte
comite
a5085c1857
1 a modificat fișierele cu 18 adăugiri și 0 ștergeri
  1. 18 0
      src/config.hpp

+ 18 - 0
src/config.hpp

@@ -45,6 +45,24 @@ struct Config {
     /// honoured and clamped to the retained count, because rows beyond it were
     /// trimmed on write and do not exist to return. Raising THIS is the remedy;
     /// there was never anything to fix in the handler.
+    ///
+    /// THE COST THIS RAISES IS NOT THE BYTES, AND IT IS STATED HERE BECAUSE IT
+    /// WAS REASONED ABOUT RATHER THAN MEASURED. `trimOldest` runs on EVERY
+    /// append with `offset = keep` over a `function_id` filter and a sort on
+    /// `started_at`, and **no index is declared on `function_id`** - so each
+    /// append scans the project's whole run log, sorts the matching rows and
+    /// skips `keep` of them. Tenfold `keep` is therefore roughly tenfold rows
+    /// held (~900 to ~9000 for 18 functions) and a correspondingly larger scan
+    /// per run, on a box with ONE vCPU where one tenant's load already degrades
+    /// every other tenant proportionally.
+    ///
+    /// The arithmetic says this is small - a few ms against a pure DB read
+    /// measured at 8-35 ms, and at most once a minute per cron function - but
+    /// that is an estimate and this file is full of warnings about exactly this
+    /// shape, so: it has not been measured, and the measurement to take is the
+    /// append latency of a run on a project whose log holds the new ceiling.
+    /// The structural fix is an index on `function_id`, which would make the
+    /// trim cost track the matching rows instead of the collection.
     uint32_t functionRunsKept = 500;
     /// Shared secret presented to the runners. Prefer SVAPI_RUNNER_TOKEN in
     /// vectorapi.env over config.json, which is a conffile and tends to be