Skip to content

perf(steps): cache steps_for_frame DB calls in find_frame - #44

Open
praneshnikhar wants to merge 2 commits into
nossa-y:mainfrom
praneshnikhar:feat/find-frame-cache
Open

perf(steps): cache steps_for_frame DB calls in find_frame#44
praneshnikhar wants to merge 2 commits into
nossa-y:mainfrom
praneshnikhar:feat/find-frame-cache

Conversation

@praneshnikhar

Copy link
Copy Markdown

find_frame calls steps_for_frame for every frame in a document, each of which queries the DB and loads element trees. With N frames, that's N redundant round-trips.

This PR adds a simple dict cache keyed on (evidence frame_ids, max_steps). Since find_frame passes the same include_text=False and max_steps for all frames, identical frames hit the cache instead of re-querying the DB.

No behavior change — all existing tests pass. The cache is scoped to a single find_frame call so there are no stale-data concerns.

nossa-y and others added 2 commits August 3, 2026 13:57
find_frame calls steps_for_frame for every frame in a document,
each of which queries the DB. On a document with N frames, this
is N redundant DB round-trips per step expansion.

Add a simple dict cache keyed by (evidence frame_ids, max_steps)
so identical frames hit the cache instead of re-querying the DB.
All existing tests pass; behavior is identical, just faster.
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.

2 participants