mirror of
https://github.com/TriliumNext/Trilium.git
synced 2026-10-12 02:09:59 +00:00
chore: move measurements out of comments
The throughput and benchmark figures in the sink, chunk-size, hash-backend and bulk-read comments restated what their commits already record, and a number in a comment goes stale the moment the code around it improves. The comments keep the constraint that still binds — what is slow, what must align, what runs per byte — and the commits keep the numbers. Raised by review (Greptile) on the PR. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
327ef2b1da
commit
58bc83898c
@@ -22,7 +22,7 @@ import org.json.JSONObject;
|
||||
*
|
||||
* <p>The Capacitor plugin bridge carries binary as base64 inside a JSON string, and the native
|
||||
* side re-parses that whole string per call ({@code MessageHandler} → {@code org.json}), which
|
||||
* caps file writes at roughly 13 MB/s. This listener receives raw {@code ArrayBuffer} messages
|
||||
* is far too slow for large files. This listener receives raw {@code ArrayBuffer} messages
|
||||
* instead — no base64, no JSON around the payload — and appends them to a file on an IO thread.
|
||||
*
|
||||
* <p>Protocol, driven by {@code capacitor_download.ts}: a JSON string {@code {"type":"open",
|
||||
|
||||
@@ -9,9 +9,9 @@ import { KEY_BYTES, TAG_BYTES } from "./format.js";
|
||||
/**
|
||||
* The browser backend: AES-256-GCM and randomness from WebCrypto, gzip from the platform's
|
||||
* `CompressionStream`, and the two primitives WebCrypto does not offer from elsewhere — scrypt
|
||||
* from `@noble/hashes`, incremental SHA-256 from `hash-wasm`. The hash is WASM rather than
|
||||
* `@noble`'s pure JS because it runs over every payload byte and paced a phone's backup at about
|
||||
* 32 MB/s; scrypt stays JS because it runs once per container. Runs under Node just as well,
|
||||
* from `@noble/hashes`, incremental SHA-256 from `hash-wasm`. The hash is WASM rather than pure
|
||||
* JS because it runs over every payload byte, where the JS penalty on a phone paces the whole
|
||||
* backup; scrypt stays JS because it runs once per container. Runs under Node just as well,
|
||||
* which is how the cross-backend tests exercise it.
|
||||
*
|
||||
* WebCrypto's `subtle` interface only exists in secure contexts (HTTPS, localhost, workers of
|
||||
|
||||
@@ -242,12 +242,10 @@ export class SqlService {
|
||||
|
||||
/**
|
||||
* Gets every row of a whole-table read as a positional array, the way {@link getRawRows} does,
|
||||
* but crossing between JavaScript and the database once instead of once per column.
|
||||
*
|
||||
* `@sqlite.org/sqlite-wasm` charges roughly 7µs per column a row exposes, so the Becca
|
||||
* load spends most of its time marshalling rather than querying. `json_group_array()`
|
||||
* hands the result set over as one value, which `JSON.parse()` turns into rows about ten
|
||||
* times faster; better-sqlite3 is marginally faster this way too.
|
||||
* but crossing between JavaScript and the database once instead of once per column: under
|
||||
* `@sqlite.org/sqlite-wasm` every column read is its own wasm round trip, so a wide
|
||||
* whole-table read spends most of its time marshalling. `json_group_array()` hands the
|
||||
* result set over as one value for `JSON.parse()`.
|
||||
*
|
||||
* Going through JSON puts two limits on `columns` that {@link getRawRows} does not have:
|
||||
* `json_array()` rejects a BLOB column, and an integer above `Number.MAX_SAFE_INTEGER`
|
||||
|
||||
Reference in New Issue
Block a user