Repository navigation
Count a project's tasks from an index - #97
Merged
Merged
Conversation
The open and total counts of each project read every task row, since tasks_by_project held only project_id. An index on (project_id, status) answers both counts by itself. It replaces tasks_by_project, which it also serves.
ResourcesIf merged, memory: kanzo mcp after a session −1.02 MB; storage: database with 3,000 tasks +20.5 KB. Agents
Program
Memory
Speed
Storage
Measured on GitHub's ubuntu-26.04 runner, median of 3 rounds with the builds taking turns. Changes in bold are past noise: 1% for sizes, 5% for memory, 15% for times. Agents' text is in bytes: add an |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each project's open and total task counts read every row of its tasks:
tasks_by_projectholds onlyproject_id, so SQLite looks up each task to check its status. The query runs forlist_projects, the board, and every lookup of a project by slug or repo. On a board with a 3,000-task project, that keeps about 1 MB of pages in memory during the call.This replaces
tasks_by_projectwith an index on(project_id, status). Both counts then come from the index alone. It still serves every lookup of a project's tasks, so the board keeps one index ontasksfor projects, as before.Size
The project query on
measure.py's board, with 3,000 tasks, in thesqlite3shell:measure.pyon macOS, release builds, median of 5 rounds:kanzo mcpafter a session/api/boardwith 3,000 tasksmacOS gives freed memory back, so
kanzo mcpshows no change there. On x86_64 Linux, glibc keeps it, which is where #96 showed +1 MB: the memory of this query landed in a different malloc arena. The Resources check here measures that case.Compatibility
A new index leaves older Kanzo versions working, so
COMPATIBLE_FROMstays as it is. An older Kanzo that opens a synced board uses the new index for its own queries.Tests
src/store.rs:task_counts_read_only_the_indexchecks that both counts use the covering index.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpassA board change was tried in a browser, in light and dark mode (no board change)
The README says what changed for users, if anything did (nothing changed for users)