Skip to content

Add batch multi-get execution for improved performance#83

Open
bisho wants to merge 1 commit into
mainfrom
03-16-adopt_multi_get
Open

Add batch multi-get execution for improved performance#83
bisho wants to merge 1 commit into
mainfrom
03-16-adopt_multi_get

Conversation

@bisho
Copy link
Copy Markdown
Member

@bisho bisho commented Mar 17, 2026

Optimize multi-get operations by using batch socket API

This change improves the performance of multi-get operations by implementing a dedicated _exec_multi_get_on_pool method that uses the socket's meta_multiget batch API instead of executing individual get commands in a loop.

Changes:

  • Added _exec_multi_get_on_pool method to handle META_GET commands efficiently using the batch API
  • Modified exec_multi_on_pool to route META_GET commands to the new optimized path
  • Updated test mocks to use meta_multiget instead of individual send_meta_get/get_response calls
  • Enhanced test coverage to verify proper flag passing and batch operation behavior

This optimization reduces the number of socket operations and improves throughput for multi-get requests while maintaining the same error handling and response processing behavior.

Performance

Common config: server 127.0.0.1:11211, 10 threads, 1.00M requests (4 runs × 25,000 ops × 10 threads), 200 key space, GC disabled, 160/200 keys populated (95% small 80-250B, 5% large 100KB)                                                                                

  ┌───────────────┬────────┬─────────┬──────────────────────┬──────────────────────┬──────────────────────┬──────────────────────┐                                                                                                                                                                
  │               │        │         │    Socket in Rust    │    meta_* in Rust    │   key-enc in Rust    │   multiget in Rust   │
  │   Operation   │        │ BEFORE  ├──────────┬───────────┼──────────┬───────────┼──────────┬───────────┼──────────┬───────────┤                                                                                                                                                                
  │               │        │         │  Result  │  Speedup  │  Result  │  Speedup  │  Result  │  Speedup  │  Result  │  Speedup  │                                                                                                                                                                
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                
  │               │ RPS    │  46,600 │   76,652 │           │  110,287 │           │  112,054 │           │  111,638 │           │                                                                                                                                                                
  │  SET          ├────────┼─────────┼──────────┤   1.65x   ├──────────┤   2.37x   ├──────────┤   2.40x   ├──────────┤   2.40x   │                                                                                                                                                                
  │               │ us/req │   21.46 │    13.05 │           │     9.07 │           │     8.92 │           │     8.96 │           │                                                                                                                                                                
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                
  │               │ RPS    │  46,135 │   81,401 │           │  116,382 │           │  118,682 │           │  118,351 │           │                                                                                                                                                                
  │  GET          ├────────┼─────────┼──────────┤   1.76x   ├──────────┤   2.52x   ├──────────┤   2.57x   ├──────────┤   2.57x   │                                                                                                                                                                
  │               │ us/req │   21.68 │    12.28 │           │     8.59 │           │     8.43 │           │     8.45 │           │                                                                                                                                                                
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                
  │               │ RPS    │   2,677 │    3,626 │           │    3,560 │           │    3,567 │           │   14,118 │           │                                                                                                                                                                
  │  MULTI_GET(5) ├────────┼─────────┼──────────┤   1.35x   ├──────────┤   1.33x   ├──────────┤   1.33x   ├──────────┤   5.27x   │                                                                                                                                                                
  │               │ us/req │  373.52 │   275.81 │           │   280.86 │           │   280.31 │           │    70.83 │           │                                                                                                                                                                
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                
  │               │ RPS    │  48,080 │   82,886 │           │  123,053 │           │  125,639 │           │  127,131 │           │                                                                                                                                                                
  │  DELETE       ├────────┼─────────┼──────────┤   1.72x   ├──────────┤   2.56x   ├──────────┤   2.61x   ├──────────┤   2.64x   │                                                                                                                                                                
  │               │ us/req │   20.80 │    12.06 │           │     8.13 │           │     7.96 │           │     7.87 │           │                                                                                                                                                                
  └───────────────┴────────┴─────────┴──────────┴───────────┴──────────┴───────────┴──────────┴───────────┴──────────┴───────────┘

Copy link
Copy Markdown
Member Author

bisho commented Mar 17, 2026

@bisho bisho marked this pull request as ready for review March 17, 2026 08:58
@bisho bisho requested a review from a team March 17, 2026 09:47
@bisho bisho force-pushed the 03-16-adopt_multi_get branch from 807fe5b to da0b273 Compare March 25, 2026 09:18
@bisho bisho force-pushed the 03-16-adopt_key_encoding_directly_in_socket branch 2 times, most recently from 1d8d11b to 35c7d13 Compare March 25, 2026 09:21
@bisho bisho force-pushed the 03-16-adopt_multi_get branch from da0b273 to 4df6369 Compare March 25, 2026 09:21
@bisho bisho force-pushed the 03-16-adopt_key_encoding_directly_in_socket branch from 35c7d13 to 285cfef Compare March 25, 2026 12:38
@bisho bisho force-pushed the 03-16-adopt_multi_get branch 2 times, most recently from 0c460b0 to 04ea778 Compare March 25, 2026 13:21
@bisho bisho force-pushed the 03-16-adopt_key_encoding_directly_in_socket branch 2 times, most recently from 98f1e1f to 6e3b2d9 Compare March 26, 2026 13:19
@bisho bisho force-pushed the 03-16-adopt_multi_get branch 2 times, most recently from 0ef4f76 to d254c4e Compare March 26, 2026 14:11
@bisho bisho force-pushed the 03-16-adopt_key_encoding_directly_in_socket branch 2 times, most recently from 6ed12d6 to 51da0e9 Compare March 26, 2026 15:13
@bisho bisho force-pushed the 03-16-adopt_multi_get branch from d254c4e to 499b564 Compare March 26, 2026 15:13
@bisho bisho force-pushed the 03-16-adopt_key_encoding_directly_in_socket branch from 51da0e9 to 6ceea8d Compare March 26, 2026 15:27
@bisho bisho force-pushed the 03-16-adopt_multi_get branch from 499b564 to 235e27f Compare March 26, 2026 15:27
@bisho bisho changed the base branch from 03-16-adopt_key_encoding_directly_in_socket to graphite-base/83 March 26, 2026 15:38
@bisho bisho force-pushed the graphite-base/83 branch from 6ceea8d to 82cafeb Compare March 26, 2026 15:39
@bisho bisho force-pushed the 03-16-adopt_multi_get branch from 235e27f to 987f239 Compare March 26, 2026 15:39
@graphite-app graphite-app Bot changed the base branch from graphite-base/83 to main March 26, 2026 15:40
@bisho bisho force-pushed the 03-16-adopt_multi_get branch from 987f239 to 496bf20 Compare March 26, 2026 15:40
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.

1 participant