Skip to content

Count a project's tasks from an index - #97

Merged
emanuele-em merged 1 commit into
mainfrom
tasks-by-project-status
Nov 30, 2026
Merged

emanuele-em merged 1 commit into
mainfrom
tasks-by-project-status

Conversation

@emanuele-em

Copy link
Copy Markdown
Owner

Each project's open and total task counts read every row of its tasks: tasks_by_project holds only project_id, so SQLite looks up each task to check its status. The query runs for list_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_project with 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 on tasks for projects, as before.

Size

The project query on measure.py's board, with 3,000 tasks, in the sqlite3 shell:

Before After
SQLite memory 1.26 MB 0.19 MB
File reads 290 43

measure.py on macOS, release builds, median of 5 rounds:

main this PR
Database with 3,000 tasks 1.37 MB 1.39 MB (+20 KB)
Empty database 99.5 KB 99.5 KB
Board with 3,000 tasks loaded 13.47 MB 13.27 MB
kanzo mcp after a session 8.42 MB 8.45 MB
/api/board with 3,000 tasks 3.9 ms 3.8 ms
Binary same same

macOS gives freed memory back, so kanzo mcp shows 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_FROM stays 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_index checks that both counts use the covering index.

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test pass

  • A 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)

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.
@github-actions

Copy link
Copy Markdown

Resources

If merged, memory: kanzo mcp after a session −1.02 MB; storage: database with 3,000 tasks +20.5 KB.

Agents

main this PR change
Tool list, read every session 3.9 KB 3.9 KB same
Instructions, read every session 496 B 496 B same
Reply to list_projects 73 B 73 B same
Reply to list_tasks (8) 316 B 316 B same
Reply to get_task 433 B 433 B same
Reply to next_task 450 B 450 B same
Reply to add_comment 37 B 37 B same
Reply to update_task 55 B 55 B same
Reply to create_task 42 B 42 B same

Program

main this PR change
Binary 5.66 MB 5.66 MB +128 B (+0.0%)
Crates in Cargo.lock 183 183 same

Memory

main this PR change
Idle board 6.98 MB 7.17 MB +188.4 KB (+2.7%)
Board with 3,000 tasks loaded 12.99 MB 13.12 MB +122.9 KB (+0.9%)
Peak of the board 13.10 MB 13.12 MB +12.3 KB (+0.1%)
kanzo mcp after a session 9.27 MB 8.24 MB −1.02 MB (−11.1%)
Threads when idle 1 1 same

Speed

main this PR change
Start 1.2 ms 1.2 ms same
/api/board with 3,000 tasks 5.2 ms 5.1 ms same

Storage

main this PR change
Empty database 99.5 KB 99.5 KB same
Database with 3,000 tasks 1.37 MB 1.39 MB +20.5 KB (+1.5%)
/api/board reply with 3,000 tasks 1.08 MB 1.08 MB same
Board page (HTML, JS, logo) 174.2 KB 174.2 KB same

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 ANTHROPIC_API_KEY secret to count tokens.

@emanuele-em
emanuele-em merged commit 27d698c into main Nov 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant