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

Refactor debug configuration options for clarity and consistency #690

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

Conversation

PingXie
Copy link
Member

@PingXie PingXie commented Jun 25, 2024

No description provided.

PingXie and others added 10 commits June 2, 2024 12:30
Also make `enable-debug-assert` an immutable config

Signed-off-by: Ping Xie <[email protected]>
Signed-off-by: Ping Xie <[email protected]>
to avoid restarting Valkey server during the test.

The `DEBUG RESTART` procedure was not always reliable, as sometimes
the server would fail to restart, leading to flaky tests.

Signed-off-by: Ping Xie <[email protected]>
…ca versions.

Added logic to iterate through the list of replicas and check for any replicas
running a version older than 8.0.0. Older replicas do not support the CLUSTER
SETSLOT command on replicas. If such a replica is found, the replication is
skipped and falls back to the old (non-replicated) behavior.

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

codecov bot commented Jun 25, 2024

Codecov Report

Attention: Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.19%. Comparing base (4d3d6c0) to head (3afa1c2).
Report is 4 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #690      +/-   ##
============================================
- Coverage     70.21%   70.19%   -0.02%     
============================================
  Files           110      110              
  Lines         60100    60104       +4     
============================================
- Hits          42202    42193       -9     
- Misses        17898    17911      +13     
Files Coverage Δ
src/aof.c 80.05% <100.00%> (+0.07%) ⬆️
src/cluster_legacy.c 85.84% <100.00%> (-0.26%) ⬇️
src/config.c 78.06% <100.00%> (ø)
src/logreqres.c 72.72% <ø> (ø)
src/networking.c 85.42% <ø> (ø)
src/rdb.c 75.60% <100.00%> (-0.15%) ⬇️
src/server.c 88.54% <100.00%> (ø)
src/server.h 100.00% <ø> (ø)
src/valkey-check-rdb.c 64.21% <100.00%> (ø)
src/debug.c 53.40% <85.71%> (ø)

... and 9 files with indirect coverage changes

@PingXie PingXie changed the title Rename enable_debug_assert to debug_assert_enabled for consistency Refactor debug configuration options for clarity and consistency Jun 25, 2024
src/config.c Show resolved Hide resolved
src/config.c Show resolved Hide resolved
Comment on lines +1881 to +1887
char *logfile; /* Path of log file */
int syslog_enabled; /* Is syslog enabled? */
char *syslog_ident; /* Syslog ident */
int syslog_facility; /* Syslog facility */
int crashlog_enabled; /* Enable signal handler for crashlog.
* disable for clean core dumps. */
int memcheck_enabled; /* Enable memory check on crash. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unsure why these got modified.

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 know why :). It is clang-format aligning trailing comments. let me try out the LEAVE option and if it works I can add to this pr too

Copy link
Member

@madolson madolson Jul 1, 2024

Choose a reason for hiding this comment

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

Did this end up working for you? I was trying the LEAVE option and getting some very weird results that I couldn't really understand. It felt like it was just randomly indenting. What was worse is the results were different for clang-19 and clang-18.

Copy link
Member Author

Choose a reason for hiding this comment

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

LEAVE didn't work for me. I noticed differences between clang-19 and clang-18 too but didn't dig further.

Copy link
Member

Choose a reason for hiding this comment

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

Sigh. The constantly shifting comment indentation is annoying but probably something to figure out after the release candidates.

Comment on lines +2104 to +2126
char *debug_req_res_logfile; /* Path of log file for logging all requests and their replies.
* If NULL, no logging will be performed */
unsigned int debug_client_default_resp;
#endif
int debug_assert_enabled; /* Is debug assert enabled? */
int debug_rdb_key_save_delay; /* Delay in microseconds between keys while
* writing aof or rdb. (for testings). negative
* value means fractions of microseconds (on average). */
int debug_key_load_delay; /* Delay in microseconds between keys while
* loading aof or rdb. (for testings). negative
* value means fractions of microseconds (on average). */
int debug_aof_disable_auto_gc; /* If disable automatically deleting HISTORY type AOFs?
* default no. (for testings). */
int debug_use_exit_on_panic; /* Use exit() on panic and assert rather than
* abort(). useful for Valgrind. */
int debug_cluster_drop_packet_filter; /* Debug flag to enable dropping specific packet types. */
int debug_watchdog_period; /* Software watchdog period in ms. 0 = off */
mstime_t debug_cluster_ping_interval; /* Debug config for setting how often cluster nodes send ping messages. */
off_t debug_loading_process_events_interval_bytes;
struct {
uint32_t debug_cluster_close_link_on_packet_drop : 1; /* Debug flag: close link on packet drop */
uint32_t debug_pause_cron : 1; /* Debug flag: pause cron tasks */
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we prefix each field with debug_ or should we place them within a struct debug_fields?

Copy link
Member Author

Choose a reason for hiding this comment

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

should we place them within a struct debug_fields?

good question. I actually am in slight favor of a flat set of debug_ fields so I get to type less. thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I use an IDE 😅, I'm fine with either.

Copy link
Member

Choose a reason for hiding this comment

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

So, hot take, I think we should leave the configs where they are in the struct and keep the debug_ prefix. My general understand of why we group similar fields together is they are accessed together, and improves cache line hits. It's probably too small to measure, but it seems like the right type of mentality we should be following. I'm also not sure what is the benefit of grouping debug configs together.

Copy link
Member Author

Choose a reason for hiding this comment

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

cache line aside, it is also cleaner to group debug_ settings and since we already change the names, where they belong isn't that an issue IMO. Let's keep them?

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep them?

I'm fine keeping the debug_ prefix. The only thing I don't like now is realizing we inconsistently use the term debug. (Sometimes it means debug command, sometimes it's for debugging purposes, sometimes it's for testing). I don't feel strongly though.

I would still rather put debug flags logically near the system they are a part of, instead of grouping all debug configs together. The only exception I see for grouping stuff together is if we were to group a large number of single bit values together to have a more pact cache line.

Copy link
Contributor

@zuiderkwast zuiderkwast Jul 9, 2024

Choose a reason for hiding this comment

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

We can move all the boolean-like debug vars together and make them 1-bit. That saves memory and improves cache locality since we have more vars in fewer cache lines. We can't if they're configs?

When do we start using bool for all the bool configs?

I'm not sure about rename them since it affects many places where they're accessed. It seems unnecessary (unless the names are really bad).

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.

4 participants