[storage] Every persist rewrites and fsyncs each unchanged thread.json in the Workspace
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 77/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- database, performance
Research direction
Start with writeThreads in apps/nanocore/src/storage/workspace-file-records.ts and compare its behavior with writeOwnedDescriptiveJson, which already skips unchanged turn.json files. Add a test that persists a change to one Thread and verifies other thread.json files are not replaced. Done means unchanged files are skipped while record bytes and loading behavior stay the same; measure write counts for a Workspace with many Threads.
Written by the indexing model from the issue text.
Description
Problem
Each persist call in FsStore writes every thread.json file in the Workspace again, even when the Thread did not change. writeThreads in apps/nanocore/src/storage/workspace-file-records.ts calls writeJsonAtomic for each Thread without a comparison, while the Turn writer writeOwnedDescriptiveJson already skips an unchanged turn.json. writeJsonAtomic uses writeFileAtomic, so each write also does a file fsync and a parent directory fsync. About 21 store operations call persist, so the cost of every Workspace mutation grows with the number of Threads in that Workspace.
Suggested fix
Skip a thread.json write when the new bytes are identical to the bytes on disk, in the same way as writeOwnedDescriptiveJson does for turn.json. Add a test that persists a change to one Thread and checks that the other Threads' thread.json files are not replaced. This does not change record bytes or the loader. It does not fix any crash window: the RC4 directory publication fix covers the Turn creation window, and createTurn still changes the Thread preview. Measure the write count on a Workspace with many Threads before and after the change.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 6h 31m
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lingkaix/openkit
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
All issues in lingkaix/openkit
Similar issues
-
area:ui effort:S enhancement priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
QuantumNous/new-api#7839 ·
Maintainers usually reply within 1 day
-
good first issue maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
dark-princezz/stellar-hooks#1010 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
interledger/rhyza#352 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day