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

Call makeObjectShared to normalize a shared object into a true shared object #1566

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

Conversation

enjoy-binbin
Copy link
Member

Currently, only int and shared.redacted call makeObjectShared for
shared objects.

Although this breaks the blame log, there is a few points i would
like to mention:

  1. For threading, our fork for some reasons calling decrRefCount in
    the threads for shared.command. Although this is not used in OSS
    code now, it may be a issue in the future.
  2. For cleanup, all shared objects's refcount should be the same.
  3. For CoW, probably can reduce CoW although it is very minor.

… object

Currently, only int and shared.redacted call makeObjectShared for
shared objects.

Although this breaks the blame log, there is a few points i would
like to mention:
1. For threading, our fork for some reasons calling decrRefCount in
   the threads for shared.command. Although this is not used in OSS
   code now, it may be a issue in the future.
2. For cleanup, all shared objects's refcount should be the same.
3. For CoW, probably can reduce CoW although it is very minor.

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

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 95.41985% with 6 lines in your changes missing coverage. Please review.

Project coverage is 70.98%. Comparing base (2a1a65b) to head (5c2fda5).
Report is 1 commits behind head on unstable.

Files with missing lines Patch % Lines
src/db.c 0.00% 3 Missing ⚠️
src/debug.c 0.00% 1 Missing ⚠️
src/functions.c 0.00% 1 Missing ⚠️
src/server.c 99.18% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1566      +/-   ##
============================================
+ Coverage     70.78%   70.98%   +0.19%     
============================================
  Files           120      120              
  Lines         65046    65071      +25     
============================================
+ Hits          46045    46189     +144     
+ Misses        19001    18882     -119     
Files with missing lines Coverage Δ
src/config.c 78.39% <100.00%> (ø)
src/script.c 87.69% <100.00%> (ø)
src/server.h 100.00% <ø> (ø)
src/debug.c 52.40% <0.00%> (ø)
src/functions.c 92.01% <0.00%> (ø)
src/server.c 87.68% <99.18%> (+0.06%) ⬆️
src/db.c 89.56% <0.00%> (ø)

... and 8 files with indirect coverage changes

@@ -1964,153 +1964,153 @@ void afterSleep(struct aeEventLoop *eventLoop, int numevents) {
* initializations can be moved back inside createSharedObjects() below. */
void createSharedObjectsWithCompat(void) {
const char *name = server.extended_redis_compat ? "Redis" : SERVER_TITLE;
if (shared.loadingerr) decrRefCount(shared.loadingerr);
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 struggling with this, not sure how to handle it yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a little sad that we need to store two versions of these strings and need to check the compat flag every time we return these strings. We have already planned to remove this compat config at some time.

If we can make extended-redis-compat a readonly config, we can initialize them only once, but that's not perfect. One of the purposes is that users can change them in runtime if they have some problem.

Another idea: These strings are changed only when the compat config is changed. Is it possible to wait for all threads to stop and then replace the shared objects and free the old ones? We do something similar for MODULE UNLOAD to make sure no module is accessing a command that is going to be removed:

void moduleUnregisterCommands(struct ValkeyModule *module) {
    /* Drain IO queue before modifying commands dictionary to prevent concurrent access while modifying it. */
    drainIOThreadsQueue();

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

lazyfree job does not fit in the I/O threads, unforunately

@zuiderkwast zuiderkwast requested a review from madolson January 15, 2025 09: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