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

Increase the IO_THREADS_MAX_NUM. #1220

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,6 @@ void loadServerConfigFromString(char *config) {
if (server.config_hz < CONFIG_MIN_HZ) server.config_hz = CONFIG_MIN_HZ;
if (server.config_hz > CONFIG_MAX_HZ) server.config_hz = CONFIG_MAX_HZ;

/* To ensure backward compatibility when io_threads_num is according to the previous maximum of 128. */
if (server.io_threads_num > IO_THREADS_MAX_NUM) server.io_threads_num = IO_THREADS_MAX_NUM;

sdsfreesplitres(lines, totlines);
reading_config_file = 0;
return;
Expand Down Expand Up @@ -3193,8 +3190,8 @@ standardConfig static_configs[] = {

/* Integer configs */
createIntConfig("databases", NULL, IMMUTABLE_CONFIG, 1, INT_MAX, server.dbnum, 16, INTEGER_CONFIG, NULL, NULL),
createIntConfig("port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.port, 6379, INTEGER_CONFIG, NULL, updatePort), /* TCP port. */
createIntConfig("io-threads", NULL, DEBUG_CONFIG | IMMUTABLE_CONFIG, 1, 128, server.io_threads_num, 1, INTEGER_CONFIG, NULL, NULL), /* Single threaded by default */
createIntConfig("port", NULL, MODIFIABLE_CONFIG, 0, 65535, server.port, 6379, INTEGER_CONFIG, NULL, updatePort), /* TCP port. */
createIntConfig("io-threads", NULL, DEBUG_CONFIG | IMMUTABLE_CONFIG, 1, IO_THREADS_MAX_NUM, server.io_threads_num, 1, INTEGER_CONFIG, NULL, NULL), /* Single threaded by default */
createIntConfig("events-per-io-thread", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.events_per_io_thread, 2, INTEGER_CONFIG, NULL, NULL),
createIntConfig("prefetch-batch-max-size", NULL, MODIFIABLE_CONFIG, 0, 128, server.prefetch_batch_max_size, 16, INTEGER_CONFIG, NULL, NULL),
createIntConfig("auto-aof-rewrite-percentage", NULL, MODIFIABLE_CONFIG, 0, INT_MAX, server.aof_rewrite_perc, 100, INTEGER_CONFIG, NULL, NULL),
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void setcpuaffinity(const char *cpulist);
#define HAVE_FADVISE
#endif

#define IO_THREADS_MAX_NUM 16
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was the number 16 decided earlier for users to avoid shooting themselves in the foot i.e. performance will start deteriorating beyond that count?

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, we use 3 bits in an robj to store which thread allocated an robj, so it can be passed back to be freed by the same thread.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, we can't blindly increase this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not. :) Can you look it up?

There was some discussion related to the PR #763.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems i was wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was the number 16 decided earlier for users to avoid shooting themselves in the foot i.e. performance will start deteriorating beyond that count?

@hpatro Per my testing before, we will observe a significant performance degradation when the io-threads number greater than online CPUs, this issue still exists with the new valkey async IO, the spinning io-threads preempt CPU from main thread. It should have no relationship with the 16 number. I remember @madolson suggested to trust the operators :). redis/redis#13003

The number 16 @uriyage responded in https://github.com/valkey-io/valkey-private/pull/6#discussion_r1597652783 before, he couldn't observe any improvement beyond 8-10 threads anyway. Not sure if he tested the larger payloads (in MBs).

Copy link
Member

@madolson madolson Oct 25, 2024

Choose a reason for hiding this comment

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

The work to limit the number of IO threads was so that we could send free requests to the same thread that allocated as was mentioned. For various reasons we decided to not commit to that as part of the V1, but I believe it's on one of the follow items: #761.

I do believe in trusting operators/admins. (Never trust application developers though, they shoot themselves in the foot). We should definitely be "sane" by default, but give power users the operational tools to do advanced things.

However, it goes from 4 bits to 8 bits, which I think is probably OK.

#define IO_THREADS_MAX_NUM 256

#ifndef CACHE_LINE_SIZE
#if defined(__aarch64__) && defined(__APPLE__)
Expand Down
Loading