Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce FORCE_DEFRAG compilation option to allow activedefrag run when allocator is not jemalloc #1303

Open
wants to merge 9 commits into
base: unstable
Choose a base branch
from

Conversation

ranshid
Copy link
Member

@ranshid ranshid commented Nov 14, 2024

Introduce compile time option to force activedefrag to run even when
jemalloc is not used as the allocator.
This is in order to be able to run tests with defrag enabled
while using memory instrumentation tools.

fixes: #1241

Introduce compile time option to force activedefrag to run even when
jemalloc is not used as the allocator.
This is in order to be able to run tests with defrag enabled
while using memory instrumantation tools.

Signed-off-by: ranshid <[email protected]>
Introduce compile time option to force activedefrag to run even when
jemalloc is not used as the allocator.
This is in order to be able to run tests with defrag enabled
while using memory instrumantation tools.

Signed-off-by: ranshid <[email protected]>
Signed-off-by: ranshid <[email protected]>
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.71%. Comparing base (32f7541) to head (4643d97).

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1303      +/-   ##
============================================
+ Coverage     70.69%   70.71%   +0.02%     
============================================
  Files           115      115              
  Lines         63153    63153              
============================================
+ Hits          44643    44661      +18     
+ Misses        18510    18492      -18     
Files with missing lines Coverage Δ
src/defrag.c 86.58% <ø> (+2.23%) ⬆️
src/zmalloc.c 84.66% <ø> (ø)

... and 11 files with indirect coverage changes

Signed-off-by: Ran Shidlansik <[email protected]>
@madolson
Copy link
Member

I think we'll want to merge this PR first btw, #1242, since it already exists. I think there will be some merge conflicts.

@@ -41,3 +41,4 @@ unset(BUILD_UNIT_TESTS CACHE)
unset(BUILD_TEST_MODULES CACHE)
unset(BUILD_EXAMPLE_MODULES CACHE)
unset(USE_TLS CACHE)
unset(FORCE_DEFRAG CACHE)
Copy link
Member

Choose a reason for hiding this comment

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

We should add this to some CI presumably. The daily ASAN probably?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I agree. maybe it can also be run as part of the CI, depending on the extra time it would take.

Copy link
Member

@madolson madolson left a comment

Choose a reason for hiding this comment

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

Mostly makes sense to me. Some ideas for clarity but nothing to really change the direction.

Comment on lines +26 to +27
message(STATUS "Forcing Active Defrag run on valkey-server")
target_compile_definitions(valkey-server PRIVATE FORCE_DEFRAG)
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer a slightly more verbose and descriptive name, like, "DEBUG_FORCE_DEFRAG" or something, to indicate this isn't really used for production.

@@ -755,6 +755,15 @@ void defragScanCallback(void *privdata, const dictEntry *de) {
* or not, a false detection can cause the defragmenter to waste a lot of CPU
* without the possibility of getting any results. */
float getAllocatorFragmentation(size_t *out_frag_bytes) {
Copy link
Member

Choose a reason for hiding this comment

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

Kind of feels like you should override computeDefragCycles instead, and have that should always set active_defrag_running to like 100%.

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 am fine with it (makes sense) I do not, however want to break tests which are checking the active_defrag_running, so maybe I can just use the active-defrag-cycle-max as the return value?
Alternatively we can have a tag to skip tests in case of DEBUG_FORCE_DEFRAG

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively we can have a tag to skip tests in case of DEBUG_FORCE_DEFRAG

This intuitively makes a bit more sense to me, since defrag shouldn't really work correctly since we are completely breaking defrag here.

Copy link
Member

@madolson madolson Nov 15, 2024

Choose a reason for hiding this comment

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

All of the tests already are checking for jemalloc memory to enable the defragmentation, so I think that the tests should all still be skipped anyways?

@@ -956,7 +966,7 @@ void activeDefragCycle(void) {
mstime_t latency;
int all_stages_finished = 0;
int quit = 0;

#if !defined(FORCE_DEFRAG)
Copy link
Member

@madolson madolson Nov 15, 2024

Choose a reason for hiding this comment

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

I still kind of think you should have to turn defrag on. I'm okay with overriding it so it always runs if you do, but it it's sort of counter intuitive to comment out this block of code.

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my initial thought as well but I went all the way :)
an alternative would be to make the active defrag config on by default when this compilation flag is on. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

an alternative would be to make the active defrag config on by default when this compilation flag is on. WDYT?

I'm okay with this, it makes sense to me.

@madolson
Copy link
Member

@ranshid Zvis change is now merged. Jim's is basically also ready to go so you should be able to resume updating this if you want.

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.

[NEW]Allow activedefrag to run when jemalloc is not used
2 participants