Skip to content

update_replacement_state is not called for misses at fill time #598

Open

Description

@Quangmire

Describe the bug
The documentation describes update_replacement_state as:

This function has different behavior depending on whether replacement_cache_fill() is defined. If it is defined, this function is called when a tag check completes, whether the check is a hit or a miss. If it is not defined, this function is called on hits and when a miss is filled (that is, with the same timing as replacement_cache_fill()).

However, when replacement_cache_fill is absent, it doesn't look like update_replacement_state is called for misses at fill time. This occurs for DRRIP which doesn't have replacement_cache_fill.

To Reproduce
Steps to reproduce the behavior:

  1. Configure champsim_config.json to have DRRIP as a replacement policy.
  2. Modify DRRIP to log misses.
  3. Compile
  4. Run

Expected behavior
update_replacement_state is called at cache fills

Output
If applicable, add the output from ChampSim to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Compiler [e.g. GCC, LLVM]
  • Version [e.g. 22]

Additional context
The issue appears to be at cache.h:515.

It calls impl_update_replacement_state, but since that just checks for hits and whether the replacement policy has replacement_cache_fill, nothing happens.

Activity

  1. maccoymerrell commented on Feb 21, 2025

    @maccoymerrell
    Contributor

    I believe this is being done since update_replacement_state() would be called when the replacement state needs to update itself.
    Since replacement_cache_fill is not defined (we aren't tracking fills), we must be assuming that update_replacement_state() doesn't need called on fills.

    It would make some sense the way it is, but I wonder if the original intent was to do the opposite (not call update_replacement_state for fills if replacement_cache_fill() was defined).

    I think this was brought up in another issue (and there may be an open PR).

  2. maccoymerrell commented on Feb 21, 2025

    @maccoymerrell
    Contributor

    Issue #570
    PR #571

  3. ngober commented on Feb 21, 2025

    @ngober
    Collaborator

    The intent of the change in #434 was to retain the existing behavior of update_state(), where it was called on fills and on hits. If cache_fill() was defined, we would instead call it on fills and update_state() on hits or misses.

    It looks like #571 has gone dormant. I think it's important to see the tests for this, as mentioned in that thread. I thought we had a test for this behavior here. Is it not working as expected?

  4. maccoymerrell commented on Feb 21, 2025

    @maccoymerrell
    Contributor

    @ngober
    From what I can tell, that test only shows that the interface is either the same as the previous call or not called at all. I am guessing it is actually the latter instead of the former.

    Is there a place where the update_interface_discerner is reset? That might solve this problem.

  5. ngober commented on Feb 21, 2025

    @ngober
    Collaborator

    I think you're right. Resetting update_interface_discerner might expose a bug. I wonder if the state is being preserved between test sections.

  6. seemakurthi-anand commented on Apr 1, 2026

    @seemakurthi-anand

    Hi,
    @Quangmire , @maccoymerrell As you have updated DRRIP , SHIP for proper set sampling and also properly defined update_replacement_state and replacement_cache_fill fns #603 . I think SRRIP policy also should have both repl_cache_fill and update_replacement_state otherwise when repl_cache_fill not defined for SRRIP then only hits will call update_repl_st not misses, so rrpv array updation won't be properly done.

  7. maccoymerrell commented on Apr 1, 2026

    @maccoymerrell
    Contributor

    That behavior is being changed alongside the runtime config module rework. Hooks should always be invoked, without conditionality of other hooks being defined.
    Under that system, update_replacement_state should be called for hits and misses.

  8. seemakurthi-anand commented on Apr 1, 2026

    @seemakurthi-anand

    Where can I find the updated code, is it part of some develop branch or it is yet to be commited to repo?

  9. maccoymerrell commented on Apr 1, 2026

    @maccoymerrell
    Contributor

    #564
    Hits and misses on cache access will be caught by update_replacement_state. Fills are logged exclusively through cache_fill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions