Skip to content

faster-redis: native Zig connection pool and hot-path buffer reuse #78

@justrach

Description

@justrach

Move pooling from Python wrappers into the Zig extension so free-threaded workloads stop paying Python queue/checkout overhead.

Progress:

  • added native pool handle support in zig/src/main.zig
  • added pooled execute / pooled pipeline entrypoints
  • added per-connection reusable write buffers in Zig pack paths
  • fixed RESP array lifetime cleanup while touching the hot path
  • Python PooledRedis now uses the native pool instead of queue.LifoQueue
  • refined pool selection from blind round-robin to sticky thread-affine slot assignment
  • added cheaper Python response fast-path handling for the hottest command families (GET, SET, MSET, common bool-like replies)
  • removed the useless recursive Python list walk in _dec
  • added a thread-bound pooled client view so worker threads stop routing every operation back through the shared PooledRedis dispatcher

Validation:

  • PYTHONPATH=. /Users/rachpradhan/turboAPI/faster-redis/.venv314t/bin/python -m unittest tests.test_client_fallback tests.test_native_shadow tests.test_parity_harness passes
  • isolated local Redis benchmark now shows pooled reads and writes at or above TLS on the tested thread counts

Latest benchmark snapshots against isolated Redis on port 6381:

  • 16 threads, pool 16: GET 2.80x vs redis-py, SET 1.20x; TLS is 2.59x on GET and 1.43x on SET
  • 32 threads, pool 32: GET 2.61x vs redis-py, SET 2.22x; TLS is 2.52x on GET and 2.20x on SET

Takeaway:

  • thread-bound pooled client views were the missing piece for read-heavy scaling
  • the remaining difference versus TLS is now gone on the tested pool/thread matches
  • pooled design now keeps the shared native pool architecture while matching or slightly beating TLS in these benchmark shapes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions