8000 Performance: smaller items · Issue #296 · alexbeeken/skrongle-mini · GitHub
[go: up one dir, main page]

Skip to content

Performance: smaller items #296

Backlog
Backlog

Description

@alexbeeken

Each is small. Ordered by likely gain. Those marked measure need a number from the Pi before the change is worth making.

  • Size checks read whole course contents on every save. LENGTH(CAST(content AS BLOB)) in account_bytes, size_after and list_files (src/courses.rs:1137, :1122, :1081) pulls every file through the 2 MB page cache; list_files also reports characters as bytes. Use octet_length(). Measure with the vm count in SKRONGLE_SQL_TRACE.
  • Course export builds a full serde_json::Value tree on the worker (src/routes/courses/files.rs:173-184). The files are already JSON text: write them into the envelope verbatim, inside off_worker.
  • Freed memory goes back to the OS only at boot. release_boot_memory() (src/main.rs:606) calls malloc_trim(0) once. Call it after each off_worker build and in the hourly housekeeping. Measure VmRSS after 30 autosaves of a 2 MB course.
  • A second rendered copy of every viewed lesson (src/content.rs:663, html_content) is kept beside the sections' HTML and grows after boot. Render per view, or build the page from the sections.
  • Blocking threads die after 10 idle seconds, so on a quiet box each request starts and ends a thread. Try .thread_keep_alive(300 s), or one dedicated database thread. Measure page latency on the Pi both ways; scripts/pi-budget.sh:211-213 relies on the current behaviour.
  • The start-up dummy hash (src/main.rs:516) could be a constant string: one hash and 8 MiB less at boot.
  • t() clones a String per lookup (src/i18n.rs:318) and js_json() copies the cached text (:388). The languages live for the whole run: return &'static str and the Arc.
  • SQL text is built with format! on every call before the statement cache is consulted: session_sql() (src/auth.rs:391), src/mastery.rs:205,221, src/progress.rs:196, src/guide.rs:55. Make them constants.
  • /lessons builds a row for every lesson (src/routes/pages.rs:645-656), then shows 12. Build rows after choosing the unit and page.
  • course_picture (src/routes/mod.rs:547-559) hashes the SVG per request for its ETag and copies the body. Compute the ETag when the store is built.
  • The AI client is built per call (src/ai.rs:1217), so every lesson pays a new TLS handshake. One per job. The generator also holds a whole-course copy (before) for the entire run (src/ai/queue.rs:262).
  • routes/manage/progress.rs:102-109 runs three queries per opened course in a loop. One grouped query.
  • docs/course-format.md (48 KB) is in the binary twice (src/ai.rs:51 and the docs embed), and i18n/README.md and the test course's AUTHORING.md are embedded and never used.
  • No vacuum. The file never shrinks after MB-sized courses are deleted. It only matters with the Undo copies.

Left as they are, on purpose: no compression of HTML or JSON (one slow worker, usually a LAN).

From the code review of 24 November 2026. Line numbers are as of 0.5.0 (2547b36).

Activity

  1. added
    review
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0