Skip to content

cache_obj inline misc metadata#306

Merged
1a1a11a merged 1 commit intodevelopfrom
jason/cahceobj
Mar 15, 2026
Merged

cache_obj inline misc metadata#306
1a1a11a merged 1 commit intodevelopfrom
jason/cahceobj

Conversation

@1a1a11a
Copy link
Copy Markdown
Owner

@1a1a11a 1a1a11a commented Mar 14, 2026

move misc metadata inline

@1a1a11a 1a1a11a requested a review from haochengxia as a code owner March 14, 2026 18:39
Copilot AI review requested due to automatic review settings March 14, 2026 18:39
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on an internal refactoring of the cache_obj data structure within the libCacheSim library. The primary goal is to streamline access to critical metadata, specifically next_access_vtime and freq, by moving them directly into the cache_obj struct. This change removes an extra layer of nesting, making the code cleaner and potentially more efficient. The modifications are propagated throughout the codebase, updating all relevant cache eviction policies and helper functions to use the new direct access pattern.

Highlights

  • Data Structure Refactoring: The cache_obj structure has been refactored to directly include next_access_vtime and freq fields, eliminating the nested misc_metadata_t struct.
  • Code Simplification: References to these metadata fields across various cache eviction algorithms and utility functions have been updated to directly access cache_obj->next_access_vtime and cache_obj->freq, simplifying the code.
  • Potential Performance Improvement: Inlining these frequently accessed fields may lead to minor performance improvements by reducing memory access indirection.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • libCacheSim/cache/cache.c
    • Updated cache_find_base and cache_insert_base functions to directly access inlined metadata fields.
  • libCacheSim/cache/eviction/ARC.c
    • Modified ARC eviction functions to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/ARCv0.c
    • Refactored ARCv0 eviction logic to directly access the inlined freq member.
    • Removed redundant frequency initialization in ARCv0_insert.
  • libCacheSim/cache/eviction/FIFO_Merge.c
    • Updated FIFO_Merge_find and FIFO_Merge_insert functions to remove misc.next_access_vtime and FIFO_Merge.freq assignments.
    • Adjusted belady_metric to use the inlined next_access_vtime.
  • libCacheSim/cache/eviction/FIFO_Reinsertion.c
    • Modified FIFO_Reinsertion_find and FIFO_Reinsertion_insert functions to remove misc.next_access_vtime assignments.
    • Updated belady_metric to use the inlined next_access_vtime.
  • libCacheSim/cache/eviction/GLCache/obj.h
    • Updated GLCache object handling functions to directly access the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/GLCache/segment.c
    • Adjusted count_n_obj_reuse to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/LRU.c
    • Updated LRU eviction function to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/LRUProb.c
    • Removed redundant updates to freq and next_access_vtime in LRU_Prob_find.
  • libCacheSim/cache/eviction/LeCaR.c
    • Modified LeCaR eviction functions to directly access the inlined next_access_vtime member for belady metric calculations.
  • libCacheSim/cache/eviction/QDLP.c
    • Updated QDLP functions to directly access the inlined freq member.
  • libCacheSim/cache/eviction/S3FIFOd.c
    • Modified S3FIFOd functions to directly access the inlined freq member.
  • libCacheSim/cache/eviction/S3FIFOv0.c
    • Adjusted S3FIFOv0 eviction function to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/WTinyLFU.c
    • Updated WTinyLFU eviction function to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/belady/FIFO_Belady.c
    • Modified FIFO_Belady eviction function to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/belady/LRU_Belady.c
    • Modified LRU_Belady eviction function to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/belady/Sieve_Belady.c
    • Updated Sieve_Belady eviction function to use the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/cpp/GDSF.cpp
    • Adjusted GDSF functions to directly access the inlined freq member and updated related comments.
  • libCacheSim/cache/eviction/fifo/SFIFOv0.c
    • Modified SFIFOv0 functions to directly access the inlined next_access_vtime member.
  • libCacheSim/cache/eviction/other/S3LRU.c
    • Updated S3LRU functions to use the inlined next_access_vtime member.
  • libCacheSim/include/libCacheSim/cache.h
    • Modified record_eviction_age function to use the inlined freq member.
  • libCacheSim/include/libCacheSim/cacheObj.h
    • Removed the misc_metadata_t struct definition.
    • Inlined next_access_vtime and freq members directly into the cache_obj struct.
    • Removed the misc member from the cache_obj struct.
    • Updated copy_cache_obj_to_request to reflect the direct access of next_access_vtime.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the cache_obj_t structure to inline miscellaneous metadata fields (next_access_vtime and freq), removing the nested misc struct. The changes are applied consistently across numerous files. While most of the refactoring is correct, I've identified two critical issues where the changes seem to have unintentionally altered the logic of specific eviction policies. One issue in ARCv0.c could lead to a NULL return from an insert function, and another in FIFO_Merge.c breaks the frequency counting mechanism for that policy. Please review the detailed comments for fixes.

Comment thread libCacheSim/cache/eviction/ARCv0.c Outdated
Comment thread libCacheSim/cache/eviction/FIFO_Merge.c
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors cache_obj_t by inlining previously nested “misc” metadata fields directly into the object struct, and updates eviction algorithms and helpers to use the new field locations.

Changes:

  • Remove misc_metadata_t / cache_obj_t.misc and add next_access_vtime + freq directly to cache_obj_t.
  • Update core cache helpers (cache_find_base, cache_insert_base, copy_cache_obj_to_request) and eviction policies to use obj->next_access_vtime / obj->freq.
  • Adjust debug/metric logging to reference the new fields.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libCacheSim/include/libCacheSim/cacheObj.h Inline next_access_vtime/freq into cache_obj_t; update request-copy helper accordingly.
libCacheSim/include/libCacheSim/cache.h Update eviction-age logging to use obj->freq.
libCacheSim/cache/eviction/other/S3LRU.c Update demotion tracking prints to use obj->next_access_vtime.
libCacheSim/cache/eviction/fifo/SFIFOv0.c Update SFIFOv0 to set/use obj->next_access_vtime directly.
libCacheSim/cache/eviction/cpp/GDSF.cpp Update GDSF priority calculation to use obj->freq; keep insert-time freq initialization.
libCacheSim/cache/eviction/belady/Sieve_Belady.c Update Belady checks to use obj->next_access_vtime.
libCacheSim/cache/eviction/belady/LRU_Belady.c Update Belady checks to use obj->next_access_vtime.
libCacheSim/cache/eviction/belady/FIFO_Belady.c Update Belady checks to use obj->next_access_vtime.
libCacheSim/cache/eviction/WTinyLFU.c Update demotion tracking prints to use obj->next_access_vtime.
libCacheSim/cache/eviction/S3FIFOv0.c Update demotion tracking prints to use obj->next_access_vtime.
libCacheSim/cache/eviction/S3FIFOd.c Update thresholding/asserts to use obj->freq.
libCacheSim/cache/eviction/QDLP.c Update thresholding/asserts to use obj->freq.
libCacheSim/cache/eviction/LeCaR.c Update Belady metric calculation to use obj->next_access_vtime.
libCacheSim/cache/eviction/LRUProb.c Remove redundant misc updates on hit (now covered by shared paths).
libCacheSim/cache/eviction/LRU.c Update demotion tracking print to use obj->next_access_vtime.
libCacheSim/cache/eviction/GLCache/segment.c Update reuse counting to use obj.next_access_vtime.
libCacheSim/cache/eviction/GLCache/obj.h Update GLCache oracle scoring and hit/init updates to use obj->next_access_vtime.
libCacheSim/cache/eviction/FIFO_Reinsertion.c Update Belady metric to use obj->next_access_vtime; remove redundant per-hit/insert misc updates.
libCacheSim/cache/eviction/FIFO_Merge.c Update Belady metric to use obj->next_access_vtime; remove redundant misc updates (but currently breaks FIFO_Merge freq tracking—see comments).
libCacheSim/cache/eviction/ARCv0.c Update ARCv0 to use obj->freq (but currently returns NULL on one insert path—see comments).
libCacheSim/cache/eviction/ARC.c Update demotion tracking prints/updates to use obj->next_access_vtime.
libCacheSim/cache/cache.c Update shared base find/insert paths to maintain obj->next_access_vtime and obj->freq directly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread libCacheSim/cache/eviction/FIFO_Merge.c
Comment thread libCacheSim/cache/eviction/ARCv0.c Outdated
@1a1a11a 1a1a11a merged commit 6ec428d into develop Mar 15, 2026
7 checks passed
@1a1a11a 1a1a11a deleted the jason/cahceobj branch March 15, 2026 00:17
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