Skip to content

⚡ Remove unused heap logic from VRAMAwareCache#81

Closed
SuarezPM wants to merge 4 commits into
mainfrom
perf-vram-aware-cache-remove-heap-12314248908657311996
Closed

⚡ Remove unused heap logic from VRAMAwareCache#81
SuarezPM wants to merge 4 commits into
mainfrom
perf-vram-aware-cache-remove-heap-12314248908657311996

Conversation

@SuarezPM

@SuarezPM SuarezPM commented Jun 4, 2026

Copy link
Copy Markdown
Owner

💡 What: Removed self._heap, the _reheap method, and heapq.heappush calls from VRAMAwareCache.
🎯 Why: The cache never actually queried or popped from the heap, meaning it was maintaining a data structure (with an $O(N)$ re-heaping penalty during evictions) that was completely unused. Eviction logic relies entirely on analyzing self._store.
📊 Measured Improvement: In a local benchmark isolating _apply_eviction_policy with 1,000,000 cache items, the execution time for an eviction cycle dropped from ~0.81s to ~0.11s.


PR created automatically by Jules for task 12314248908657311996 started by @SuarezPM

Removes the unused `self._heap` and associated `_reheap` logic from
`VRAMAwareCache`. Eviction in this class determines items to remove
by iterating or sorting `self._store.values()`, bypassing the heap
completely. Re-heaping on every eviction was adding an O(N) overhead
for no functional benefit.

Measured performance improvement in benchmark scenario (1,000,000 entries
triggering a single eviction) drops `_apply_eviction_policy` time from
0.81s down to 0.11s.

Co-authored-by: SuarezPM <110942776+SuarezPM@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 3 commits June 4, 2026 03:39
Removes the unused `self._heap` and associated `_reheap` logic from
`VRAMAwareCache`. Eviction in this class determines items to remove
by iterating or sorting `self._store.values()`, bypassing the heap
completely. Re-heaping on every eviction was adding an O(N) overhead
for no functional benefit.

Measured performance improvement in benchmark scenario (1,000,000 entries
triggering a single eviction) drops `_apply_eviction_policy` time from
0.81s down to 0.11s.

Signed-off-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

Co-authored-by: SuarezPM <110942776+SuarezPM@users.noreply.github.com>
Removes the unused `self._heap` and associated `_reheap` logic from
`VRAMAwareCache`. Eviction in this class determines items to remove
by iterating or sorting `self._store.values()`, bypassing the heap
completely. Re-heaping on every eviction was adding an O(N) overhead
for no functional benefit.

Measured performance improvement in benchmark scenario (1,000,000 entries
triggering a single eviction) drops `_apply_eviction_policy` time from
0.81s down to 0.11s.

Signed-off-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

Co-authored-by: SuarezPM <110942776+SuarezPM@users.noreply.github.com>
Removes the unused `self._heap` and associated `_reheap` logic from
`VRAMAwareCache`. Eviction in this class determines items to remove
by iterating or sorting `self._store.values()`, bypassing the heap
completely. Re-heaping on every eviction was adding an O(N) overhead
for no functional benefit.

Measured performance improvement in benchmark scenario (1,000,000 entries
triggering a single eviction) drops `_apply_eviction_policy` time from
0.81s down to 0.11s.

Signed-off-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

Co-authored-by: SuarezPM <110942776+SuarezPM@users.noreply.github.com>
SuarezPM added a commit that referenced this pull request Jun 4, 2026
Applies Jules PR #81 (uv.lock/log churn dropped).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Pablo <suarezpm@csnat.unt.edu.ar>
@SuarezPM

SuarezPM commented Jun 4, 2026

Copy link
Copy Markdown
Owner Author

Applied to main in d52c868 (remove dead heap state from VRAMAwareCache). Thanks!

@SuarezPM SuarezPM closed this Jun 4, 2026
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