Skip to content

Improving lookup for specification pre-loading at startup#174

Merged
jyoo980 merged 3 commits intomainfrom
yoo/improve-startup-cache-lookup
Apr 24, 2026
Merged

Improving lookup for specification pre-loading at startup#174
jyoo980 merged 3 commits intomainfrom
yoo/improve-startup-cache-lookup

Conversation

@jyoo980
Copy link
Copy Markdown
Collaborator

@jyoo980 jyoo980 commented Apr 24, 2026

Due to DiskCache limitations, the lookup for setting previously-verified specifications from the verification result cache took O(n * m), where n is the number of functions in the graph, and m is the number of cached specifications (failing and passing).

This took considerable time even with n = 36 and m = 1617.

It now takes O(m) + O(n).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Warning

Rate limit exceeded

@jyoo980 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 16 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 16 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2f13ac9c-9484-461a-be65-691ea996f7ee

📥 Commits

Reviewing files that changed from the base of the PR and between 20c0e87 and c62aa4a.

📒 Files selected for processing (2)
  • main.py
  • util/cache_util.py
📝 Walkthrough

Walkthrough

The PR changes verifier cache lookup to build a per-function index once via get_vresult_index(VERIFIER_CACHE) and pass that index into _get_cached_vresult_with_status. _get_cached_vresult_with_status now selects candidate results from cached_vresults[function] and applies existing status-priority filtering instead of iterating all cache keys for each lookup. A new util.cache_util.get_vresult_index is added and re-exported from util.__init__.

Possibly related PRs

Suggested reviewers

  • mernst
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yoo/improve-startup-cache-lookup

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@main.py`:
- Around line 540-547: The loop over cached_vresults[function] contains a
redundant condition comparing function != vresult.get_function(); remove that
check so the loop simply filters by vresult.status in statuses and then updates
highest_priority_vresult by comparing vresult_priority indices. Update the loop
in the block that iterates cached_vresults[function] (referencing
cached_vresults, vresult.get_function(), vresult.status, vresult_priority, and
highest_priority_vresult) to drop the extra function comparison and keep only
the status-based filtering and priority selection.
- Line 513: Change the parameter type of cached_vresults on
_get_cached_vresult_with_status from defaultdict[...] to a broader type (e.g.,
dict[CFunction, list[VerificationResult]] or Mapping[CFunction,
list[VerificationResult]]) and stop relying on indexing; use
cached_vresults.get(function, []) when reading entries. Update the function
signature to the chosen broader type and adjust any internal access to use .get
so the helper no longer depends on defaultdict's default-factory behavior,
making it testable with plain dicts or mappings.

In `@util/cache_util.py`:
- Around line 28-30: Replace the fragile subscript lookup vresult_cache[vinput]
with a safe get to avoid KeyError races: iterate over vresult_cache.iterkeys()
as before but call vresult_cache.get(vinput) and keep the existing walrus/truthy
check to skip missing entries; ensure you still append to function_to_vresults
using vresult.get_function() so behavior stays identical when the value exists.
- Around line 22-23: The docstring for the return/type description of
defaultdict[CFunction, list[VerificationResult]] is missing a trailing period;
update the text "Default value for keys is an empty list" in util/cache_util.py
(the docstring describing the defaultdict return/type) to end with a period so
it matches the punctuation style of the rest of the docstring.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2ae394db-2cb4-49f6-9b20-25dabafd2e1e

📥 Commits

Reviewing files that changed from the base of the PR and between b02c9c7 and 9597737.

📒 Files selected for processing (3)
  • main.py
  • util/__init__.py
  • util/cache_util.py

Comment thread main.py Outdated
Comment thread main.py Outdated
Comment thread util/cache_util.py Outdated
Comment thread util/cache_util.py
@jyoo980 jyoo980 merged commit ca458d1 into main Apr 24, 2026
5 checks passed
@jyoo980 jyoo980 deleted the yoo/improve-startup-cache-lookup branch April 24, 2026 19:57
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