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

fix: improve command execution speed #97

Merged
merged 1 commit into from
Dec 4, 2023
Merged

fix: improve command execution speed #97

merged 1 commit into from
Dec 4, 2023

Conversation

tanmaykm
Copy link
Member

@tanmaykm tanmaykm commented Nov 29, 2023

Command execution speed gets a significant speed boost by avoiding multiple small writes to the socket connection. Using an IOBuffer to collect the command args and do a single socket write. Also turned off nagle and turned on quickack on sockets, suitable for the typically short and quick exchanges needed here.

fixes: #92

@tanmaykm
Copy link
Member Author

Benchmarked with the same test code as mentioned in #92. Prior to this change a single invocation of redis_list took ~45 seconds on my machine. With this change:

julia> @benchmark redis_list()
BenchmarkTools.Trial: 72 samples with 1 evaluation.
 Range (min  max):  41.156 ms  91.646 ms  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     69.845 ms              ┊ GC (median):    0.00%
 Time  (mean ± σ):   69.447 ms ± 10.831 ms  ┊ GC (mean ± σ):  0.12% ± 0.68%

                                 ▁▁█ ▃▁▁▁                      
  ▄▄▆▁▄▄▁▁▁▁▁▁▁▆▁▁▁▁▁▁▁▁▄▁▄▁▄▁▁▇▆███▄████▄▁▄▄▇▇▁▆▄▆▄▁▁▆▁▁▁▄▁▇ ▁
  41.2 ms         Histogram: frequency by time        88.7 ms <

 Memory estimate: 1.47 MiB, allocs estimate: 30083.

julia> @benchmark jedis_list()  # Jedis for comparison
BenchmarkTools.Trial: 71 samples with 1 evaluation.
 Range (min  max):  42.976 ms  98.741 ms  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     70.391 ms              ┊ GC (median):    0.00%
 Time  (mean ± σ):   70.957 ms ± 15.015 ms  ┊ GC (mean ± σ):  0.12% ± 0.79%

   ▁ ▁                   ▁ ▁▃ ▆█ ▃   ▁              ▁          
  ▄█▄█▇▇▁▁▁▁▄▁▁▁▄▁▁▁▄▁▁▁▄█▁██▄██▇█▁▄▄█▁▇▁▁▁▇▇▁▁▇▄▄▇▁█▁▄▇▁▇▁▁▄ ▁
  43 ms           Histogram: frequency by time        98.1 ms <

 Memory estimate: 1.72 MiB, allocs estimate: 42083.

Command execution speed gets a significant speed boost by avoiding multiple small writes to the socket connection. Using an IOBuffer to collect the command args and do a single socket write.
Also turned off nagle and turned on quickack on sockets, suitable for the typically short and quick exchanges needed here.
Copy link

codecov bot commented Nov 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cd48768) 73.59% compared to head (c358351) 73.88%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #97      +/-   ##
==========================================
+ Coverage   73.59%   73.88%   +0.29%     
==========================================
  Files           6        6              
  Lines         356      360       +4     
==========================================
+ Hits          262      266       +4     
  Misses         94       94              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tanmaykm
Copy link
Member Author

@jkaye2012 hope this looks good to merge?

@jkaye2012
Copy link
Collaborator

jkaye2012 commented Nov 30, 2023 via email

@jkaye2012 jkaye2012 merged commit c175a76 into master Dec 4, 2023
5 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.

Slow command execution
2 participants