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

rust build cmd #55

Closed
wants to merge 2 commits into from
Closed

rust build cmd #55

wants to merge 2 commits into from

Conversation

bisho
Copy link
Member

@bisho bisho commented Nov 7, 2023

  • Add benchmark tool
  • Add NonConsistentHashPoolProvider
  • Copy prebuilt default flags
  • Use namedtuples instead of tuples
  • Do not use context manager for connection pool borrowing
  • Refactor response flag parsing
  • Implement response heading parsing in rust
  • Build cmd in rust

bisho added 2 commits November 7, 2023 11:17
## Motivation / Description
There was nothing else to optimize in python, but Rust can parse
the string and build a ResponseFlags object in 22-50ns depending
on the number of flags.

While the interface between rust and python will never reach ns
performance, it helps indeed finding the header in the
response buffer.

Initial (before all optimizations):
multithreaded: Overall: 110779.55 RPS / 9.03 us/req
singlethreaded: Overall: 111545.63 RPS / 8.96 us/req

Python optimized:
multithreaded: Overall: 193340.40 RPS / 5.17 us/req
singlethreaded: Overall: 193036.56 RPS / 5.18 us/req

Using rust for header parsing:
multithreaded: Overall: 245898.34 RPS / 4.07 us/req
singlethreaded: Overall: 246165.19 RPS / 4.06 us/req
## Motivation / Description
The second cpu-intensive part of the request processing is building
the cmd.

Also instead of building dicts of flags we can use a single
flags object, which also simplifies the API of the lower
commands.

I chose to still built a single flags object, but we could
explore building one flags object per meta-command, as the
flags that they support differ, and it could lead to a more
type-safe low-level implementation.

## Performance:
* Initial:
multithreaded: Overall: 110779.55 RPS / 9.03 us/req
singlethreaded: Overall: 111545.63 RPS / 8.96 us/req

* Rust only for response parsing
multithreaded: Overall: 245898.34 RPS / 4.07 us/req
singlethreaded: Overall: 246165.19 RPS / 4.06 us/req

* Now (rust also for build_cmd)
multithreaded: Overall: 319587.03 RPS / 3.13 us/req
singlethreaded: Overall: 323101.77 RPS / 3.10 us/req
@bisho bisho changed the base branch from main to rust_parse_header November 7, 2023 22:03
@bisho bisho closed this Nov 7, 2023
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