Skip to content

Replace command building with direct socket method calls#81

Merged
bisho merged 1 commit into
mainfrom
03-12-adopt_meta__and_send_meta__api_from_memcachesocket
Mar 26, 2026
Merged

Replace command building with direct socket method calls#81
bisho merged 1 commit into
mainfrom
03-12-adopt_meta__and_send_meta__api_from_memcachesocket

Conversation

@bisho
Copy link
Copy Markdown
Member

@bisho bisho commented Mar 13, 2026

Refactor DefaultExecutor to use MemcacheSocket meta_* methods directly

This PR refactors the DefaultExecutor class to use the new blocking meta_* methods from MemcacheSocket instead of manually building commands and handling send/receive operations separately.

Changes Made

  • Replaced command building with direct method calls: Removed _build_cmd() method and updated exec_on_pool() to use _conn_exec_cmd() which calls conn.meta_get(), conn.meta_set(), etc. directly
  • Consolidated response processing: Extracted common response processing logic into _process_response() method to handle deserialization and error handling consistently
  • Updated pipelining methods: Modified _conn_send_cmd() to use conn.send_meta_*() methods and simplified _conn_recv_response() to reuse the common response processing logic
  • Enhanced test coverage: Added comprehensive wire-format tests using a new WireSocket fixture that captures actual bytes sent over the socket, replacing mock-based assertions with real wire protocol verification

Benefits

  • Cleaner separation of concerns: The executor now focuses on high-level operations while delegating protocol details to the socket layer
  • Reduced code duplication: Common response processing logic is centralized
  • Better test coverage: Wire-format tests ensure protocol correctness and catch regressions in the actual bytes sent
  • Improved maintainability: Less manual command construction and response parsing

The changes maintain full backward compatibility while making the codebase more robust and easier to maintain.

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    │
  │   Operation   │        │ BEFORE  ├──────────┬───────────┼──────────┬───────────┤                                                                                                                                                                                                              
  │               │        │         │  Result  │  Speedup  │  Result  │  Speedup  │                                                                                                                                                                                                              
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                                                              
  │               │ RPS    │  46,600 │   76,652 │           │  110,287 │           │                                                                                                                                                                                                              
  │  SET          ├────────┼─────────┼──────────┤   1.65x   ├──────────┤   2.37x   │                                                                                                                                                                                                              
  │               │ us/req │   21.46 │    13.05 │           │     9.07 │           │                                                                                                                                                                                                              
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                                                              
  │               │ RPS    │  46,135 │   81,401 │           │  116,382 │           │                                                                                                                                                                                                              
  │  GET          ├────────┼─────────┼──────────┤   1.76x   ├──────────┤   2.52x   │                                                                                                                                                                                                              
  │               │ us/req │   21.68 │    12.28 │           │     8.59 │           │                                                                                                                                                                                                              
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                                                              
  │               │ RPS    │   2,677 │    3,626 │           │    3,560 │           │                                                                                                                                                                                                              
  │  MULTI_GET(5) ├────────┼─────────┼──────────┤   1.35x   ├──────────┤   1.33x   │                                                                                                                                                                                                              
  │               │ us/req │  373.52 │   275.81 │           │   280.86 │           │                                                                                                                                                                                                              
  ├───────────────┼────────┼─────────┼──────────┼───────────┼──────────┼───────────┤                                                                                                                                                                                                              
  │               │ RPS    │  48,080 │   82,886 │           │  123,053 │           │                                                                                                                                                                                                              
  │  DELETE       ├────────┼─────────┼──────────┤   1.72x   ├──────────┤   2.56x   │                                                                                                                                                                                                              
  │               │ us/req │   20.80 │    12.06 │           │     8.13 │           │                                                                                                                                                                                                              
  └───────────────┴────────┴─────────┴──────────┴───────────┴──────────┴───────────┘

Copy link
Copy Markdown
Member Author

bisho commented Mar 13, 2026

@bisho bisho marked this pull request as ready for review March 13, 2026 14:54
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from cdacfbd to b947f0b Compare March 16, 2026 16:12
@bisho bisho force-pushed the 03-11-adopt_socket_from_meta-memcache-sockey-py branch from 55bdd4c to 275397f Compare March 16, 2026 16:12
@bisho bisho requested a review from a team March 24, 2026 17:00
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from b947f0b to dee32d0 Compare March 25, 2026 09:18
@bisho bisho force-pushed the 03-11-adopt_socket_from_meta-memcache-sockey-py branch 2 times, most recently from e9b01f1 to e462f68 Compare March 25, 2026 12:38
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from dee32d0 to 96943d7 Compare March 25, 2026 12:38
@bisho bisho force-pushed the 03-11-adopt_socket_from_meta-memcache-sockey-py branch from e462f68 to df722d9 Compare March 25, 2026 13:21
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from 96943d7 to e04597e Compare March 25, 2026 13:21
@bisho bisho force-pushed the 03-11-adopt_socket_from_meta-memcache-sockey-py branch from df722d9 to 5b095d3 Compare March 26, 2026 14:11
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from e04597e to 03324e8 Compare March 26, 2026 14:11
Copy link
Copy Markdown

@xmartinez xmartinez left a comment

Choose a reason for hiding this comment

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

LG! (Just one nit)

Comment thread src/meta_memcache/executors/default.py
Comment thread tests/conftest.py
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from 03324e8 to 314d081 Compare March 26, 2026 15:13
@bisho bisho force-pushed the 03-11-adopt_socket_from_meta-memcache-sockey-py branch from 5b095d3 to 0b04f55 Compare March 26, 2026 15:13
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from 314d081 to 7ba0963 Compare March 26, 2026 15:21
Copy link
Copy Markdown
Member Author

bisho commented Mar 26, 2026

Merge activity

  • Mar 26, 3:31 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Mar 26, 3:36 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 26, 3:37 PM UTC: @bisho merged this pull request with Graphite.

@bisho bisho changed the base branch from 03-11-adopt_socket_from_meta-memcache-sockey-py to graphite-base/81 March 26, 2026 15:33
@bisho bisho changed the base branch from graphite-base/81 to main March 26, 2026 15:35
@bisho bisho force-pushed the 03-12-adopt_meta__and_send_meta__api_from_memcachesocket branch from 7ba0963 to fe73264 Compare March 26, 2026 15:36
@bisho bisho merged commit a10ec62 into main Mar 26, 2026
3 checks passed
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