-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize IO thread offload for modified argv (#1360)
### Improve expired commands performance with IO threads #### Background In our IO threads architecture, IO threads allocate client argv's and later when we free it after processCommand we offload its free to the IO threads. With jemalloc, it's crucial that the same thread that allocates memory also frees it. For some commands we modify the client's argv in the main thread during command processing (for example in `SET EX` command we rewrite the command to use absolute time for replication propagation). #### Current issues 1. When commands are rewritten (e.g., expire commands), we store the original argv in `c->original_argv`. However, we're currently: - Freeing new argv (allocated by main thread) in IO threads - Freeing original argv (allocated by IO threads) in main thread 2. Currently, `c->original_argv` points to new array with old objects, while `c->argv` has old array with new objects, making memory free management complicated. #### Changes 1. Refactored argv modification handling code to ensure consistency - both array and objects are now either all new or all old 2. Moved original_argv cleanup to happen in resetClient after argv cleanup 3. Modified IO threads code to properly handle original argv cleanup when argv are modified. #### Performance Impact Benchmark with `SET EX` commands (650 clients, 512 byte value, 8 IO threads): - New implementation: **729,548 ops/sec** - Old implementation: **633,243 ops/sec** Representing a **~15%** performance improvement due to more efficient memory handling. --------- Signed-off-by: Uri Yagelnik <[email protected]> Signed-off-by: ranshid <[email protected]> Co-authored-by: ranshid <[email protected]>
- Loading branch information
Showing
9 changed files
with
235 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.