perf: avoid Pydantic serialization round-trip and cache timezone config#134
Open
xzq-xu wants to merge 1 commit intoHKUDS:mainfrom
Open
perf: avoid Pydantic serialization round-trip and cache timezone config#134xzq-xu wants to merge 1 commit intoHKUDS:mainfrom
xzq-xu wants to merge 1 commit intoHKUDS:mainfrom
Conversation
collector.py: replace json.loads(model.model_dump_json(...)) with model.model_dump(mode="json", ...) for tasks and event messages. Eliminates a redundant serialize-to-string + parse-back-to-dict cycle on every task and message in the board snapshot. timefmt.py: cache the configured timezone by config file mtime so format_timestamp() only reads ~/.clawteam/config.json once per config change instead of on every call. The board renderer can format dozens of timestamps per frame; this removes repeated disk I/O from the hot path while still picking up config edits immediately. Made-with: Cursor
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.
Summary
collector.py: Replacejson.loads(model.model_dump_json(...))withmodel.model_dump(mode="json", ...)for tasks and event messages. This eliminates a redundant serialize→string→parse→dict cycle on every task and every message when building the board snapshot.timefmt.py: Cache the configured timezone byconfig.jsonfile mtime soformat_timestamp()only hits disk once per config change instead of on every call. The board renderer formats dozens of timestamps per refresh; this removes repeatedload_config()I/O from the hot path while still picking up config edits immediately.Changes
clawteam/board/collector.pyjson.loads(t.model_dump_json(...))→t.model_dump(mode="json", ...)(2 call sites: tasks + messages)clawteam/timefmt.py_get_timezone()with mtime-based cache;format_timestamp()delegates to itTest plan
uv run pytest tests/test_board.py tests/test_timefmt.py -v— 17/17 passeduv run pytest -q— full suite 545 passed, 0 failuresuv run ruff check— all checks passedMade with Cursor