⚡ Bolt: [Cache annotations as raw bytes instead of parsed dict] - #600
⚡ Bolt: [Cache annotations as raw bytes instead of parsed dict]#600sheepdestroyer wants to merge 4 commits into
Conversation
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Reviewer's GuideReworks annotation caching to retain raw JSON bytes and parse them with Sequence diagram for raw-byte annotation cache readssequenceDiagram
participant Caller
participant Reader as _read_annotations_async
participant File as AnnotationFile
participant Cache as _annotations_cache
participant Parser as orjson.loads
Caller->>Reader: _read_annotations_async(path)
Reader->>File: stat(path)
alt cache miss or mtime changed
Reader->>File: open(path, rb)
File-->>Reader: content bytes
Reader->>Cache: store mtime and content
else cache hit
Reader->>Cache: read cached content
Cache-->>Reader: content bytes
end
Reader->>Parser: orjson.loads(content)
Parser-->>Reader: fresh annotation dict
Reader-->>Caller: annotation dict
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
Co-authored-by: sheepdestroyer <1377479+sheepdestroyer@users.noreply.github.com>
💡 What: Changed
_read_annotations_asyncto cache the raw bytes of the annotations file rather than a parsed dictionary. Replacedcopy.deepcopy()withorjson.loads(cached_bytes).🎯 Why: In Python,
copy.deepcopy()on large dictionaries is extremely slow. By caching the raw bytes and parsing them viaorjson.loadson every read, we create a fresh dictionary much faster than deep copying an existing one. This improves performance for endpoints reading annotations.📊 Impact: Expected to reduce the time spent retrieving cached annotations significantly (e.g. 4.1s to 0.6s in benchmarks for 1000 items), improving endpoint response times for dashboard interactions.
🔬 Measurement: I ran a local benchmark script comparing 1000 iterations of
copy.deepcopy()againstorjson.loads(raw_bytes). The benchmark showed a speedup from ~4.13s to ~0.67s. Additionally, the test suite passes confirming functionality remains unchanged.PR created automatically by Jules for task 3458818378623777530 started by @sheepdestroyer
Summary by Sourcery
Speed up cached annotation retrieval while preserving independent results for callers.
Enhancements:
Tests: