Skip to content

Conversation

@JimB123
Copy link
Member

@JimB123 JimB123 commented Dec 12, 2025

Addresses: #2908

This decouples the low-level LRU/LFU code from the high-level server.h file.

  • LRU/LFU specific config values were removed from server.h and relocated to lrulfu.h
  • A new LRULFU API was created to update the time (and policy) rather than accessing globals from server.

This doesn't address the root of the original test failure in that server.h may compile with different offsets (due to off_t) based on the include order. See: #2908 (comment)

@JimB123 JimB123 force-pushed the lrulfu-decouple branch 2 times, most recently from 1f82e64 to d38ef8d Compare December 12, 2025 21:20
@sarthakaggarwal97 sarthakaggarwal97 added the run-extra-tests Run extra tests on this PR (Runs all tests from daily except valgrind and RESP) label Dec 12, 2025
@JimB123 JimB123 marked this pull request as ready for review December 12, 2025 21:27
@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.47%. Comparing base (5940dbf) to head (bf8c568).
⚠️ Report is 4 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #2928      +/-   ##
============================================
+ Coverage     72.45%   72.47%   +0.02%     
============================================
  Files           129      129              
  Lines         70524    70537      +13     
============================================
+ Hits          51095    51123      +28     
+ Misses        19429    19414      -15     
Files with missing lines Coverage Δ
src/config.c 78.44% <ø> (ø)
src/lrulfu.c 100.00% <100.00%> (ø)
src/server.c 88.44% <100.00%> (+<0.01%) ⬆️
src/server.h 100.00% <ø> (ø)

... and 16 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@rjd15372 rjd15372 left a comment

Choose a reason for hiding this comment

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

Apart from my two comments, everything else looks good.

Copy link
Contributor

@sarthakaggarwal97 sarthakaggarwal97 left a comment

Choose a reason for hiding this comment

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

Minor comments from my end. LGTM otherwise. Thank you @JimB123!

src/config.c Outdated
createIntConfig("active-defrag-cycle-us", NULL, MODIFIABLE_CONFIG, 0, 100000, server.active_defrag_cycle_us, 500, INTEGER_CONFIG, NULL, updateDefragConfiguration),
createIntConfig("lfu-log-factor", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.lfu_log_factor, 10, INTEGER_CONFIG, NULL, NULL),
createIntConfig("lfu-decay-time", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.lfu_decay_time, 1, INTEGER_CONFIG, NULL, NULL),
createIntConfig("lfu-log-factor", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, config_lfu_log_factor, 10, INTEGER_CONFIG, NULL, NULL),
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure if it's an issue, but it looks like we are deviating from the current code structure where we do not have these configs as a part of server. Also config_ prefix is probably not required.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm assuming that existing code simply followed the pattern that all config was tossed into the global server. object. I don't think there's any reason that this needs to be the case. Requiring all configs to be added to this global structure impacts the ability to create modularity.

If we think this is important, the correct way to do this would be to remove all configuration values from server. and create a simple structure (in it's own header file) which just contains configuration. That would avoid the need to pull in (the enormous) server.h for a simple config.

The config_ prefix is just for readability within this module, that the global is intended as a configuration value (rather than modified through some other means). However, based on this feedback, I changed the prefix to lfu_, matching the prefix on the LFU functions.

Signed-off-by: Jim Brunner <brunnerj@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-extra-tests Run extra tests on this PR (Runs all tests from daily except valgrind and RESP)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants