Repository navigation
Keep parsed names between searches; a cached open lists what the first did - #590
Conversation
…the first did * parse_store keeps name -> parse in parsed_names.json in the profile folder (beside the search cache's folder, so the cache never evicts it): 8,000 names at most, least recently used dropped first, thrown away when the add-on's code changes, written on a background thread, and every failure soft. On the 23-search corpus first opens go from 23.3 s to 9.5 s on the Mac. * A cached open lists exactly what the first open listed: list-group recovery counts only groups names state, a recovered group reaches the name's other spellings in the same pass, and the leading spelling's pinned title is set on its own rows too. The corpus test now checks it. * release_index reuses a grouping when the same rows with the same parses and pass are grouped again, in the new list's order and with its own size labels, and the upload join skips sizes held by one release. Cached opens 2,637 -> 2,359 ms, same output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Code coverage overviewLanguages: Python Python / code-coverage/pytest
View coverage of the 7 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4f105fadd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| keep = sorted(_NAMES.items(), key=lambda item: item[1][0], reverse=True) | ||
| keep = keep[:MAX_NAMES] |
There was a problem hiding this comment.
Track recency within a day before evicting parsed names
Once 8,000 names have been used on the same UTC day, newly parsed names are immediately evicted: _today() assigns them all the same value, and this stable sort retains the earlier dictionary entries before the newly appended ones. Consequently, later searches repeatedly parse their names instead of benefiting from the persistent cache, even when those searches are more recent than the retained entries. For example, with MAX_NAMES=2 and a fixed day, parsing and saving A/B followed by C twice retains A/B and invokes the parser for C both times. Use a finer-grained timestamp or an access-order tie-breaker so recently used names survive eviction.
Useful? React with 👍 / 👎.
* The store keeps names in order of use, the most recent last, and trims the oldest: a full store kept the old names and dropped the day's new ones. * Each write goes through a temporary file of its own, serialized on the background thread, and an older snapshot never replaces a newer one. * The path is resolved when the write is queued, a RuntimeError from the profile lookup fails soft, and the code fingerprint moved to its own module (code_stamp) so the store does not import the search cache. * The grouping reuse in release_index holds a lock: lists are filtered on worker threads too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| break | ||
| time.sleep(0.01) | ||
|
|
||
| _path, (_stamp, entries), _number = write.call_args.args |
| break | ||
| time.sleep(0.01) | ||
|
|
||
| _path, (_stamp, entries), _number = write.call_args.args |
| if tmp_path is not None: | ||
| try: | ||
| os.remove(tmp_path) | ||
| except OSError: |
* A hit always marks the store for writing, so a run of repeat searches keeps its names ahead of the next run's new ones. * The write counters keep counting after forget(), so a writer still running from before cannot outrank later writes. * Temporary files left by a write cut short are removed after an hour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| if tmp_path is not None: | ||
| try: | ||
| os.remove(tmp_path) | ||
| except OSError: |
Summary
Release names parsed in one search are kept for the next, so a first open of a search seen before (after its cache entry expired, or the next episode of a show) parses only new names. Also: a cached open now lists exactly what the first open listed, and a list is grouped once per open.
Measured on the 23-search corpus (
tests/grouping_corpus.py), development machine:Changes
flowchart TD A[Row from a search] --> B{Name in parsed_names.json?} B -- yes --> C[Copy of the stored parse] B -- no --> D[Parse the name] --> E[Keep it for next time] C --> F[Spellings, list groups, payloads, NFO] E --> F F --> G[release_index.build once per open] G --> H[Copy counts and ranking] G --> I[Picker rows] G --> J[NZBGet backups] classDef step fill:#1E1E2E,stroke:#4A9EFF,color:#FFFFFF classDef ask fill:#151520,stroke:#FBBF24,color:#FFFFFF classDef done fill:#151520,stroke:#34D399,color:#FFFFFF class A,C,D,E,F,G step class B ask class H,I,J doneparse_store.py:name -> parse_title_metadata(name)inparsed_names.jsonin the profile folder, beside (not inside) the search cache's folder. At most 8,000 names (about 5 MB), least recently used dropped first; the file carries the code fingerprint the search cache already uses and is thrown away when the add-on changes. Written on a daemon thread; an unreadable file or folder means parsing as before. Only what a name parses to is stored, never what later steps add._recover_list_groupscounts only groups names state (not ones it orfilter_payloadadded on an earlier pass); a recovered group reaches the name's other spellings in the same pass; the leading spelling's pinned identity title is set on its own rows too.tests/test_grouping_corpus.pynow checks every search.release_index.buildreuses its grouping when the same rows, parses and metadata pass are grouped again (ranking, picker, backups), put in the new list's order with that grouping's NOGRP labels; the upload join skips sizes held by one release.Testing
just testpasses (5,198 passed, 2 skipped)just lintpasses, and the Python 3.8 compile gateCHANGELOG.mdanddocs-site/how-it-works/search-pipeline.mdThe corpus picker rows change from 6,535 to 6,534: one Godzilla Minus One name now gets its recovered group on the first open, as it already did on a cached one.
🤖 Generated with Claude Code