Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
danmayer committed Feb 13, 2025
1 parent 7228467 commit 1eb8767
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
ruby-version: 3.4
bundler-cache: true # 'bundle install' and cache
- name: Run Benchmarks
run: RUBY_YJIT_ENABLE=1 BENCH_TARGET=all bundle exec bin/benchmark
7 changes: 7 additions & 0 deletions .github/workflows/profile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
bundler-cache: true # 'bundle install' and cache
- name: Run Profiles
run: RUBY_YJIT_ENABLE=1 BENCH_TARGET=all bundle exec bin/profile
# NOTE: to pull profile results, visit https://github.com/petergoldstein/dalli/actions/workflows/profile.yml
# click to view the run you are interested in (ex https://github.com/petergoldstein/dalli/actions/runs/13296952241)
# in the artifacts section, download the profile results
- name: Upload profile results
uses: actions/upload-artifact@v4
with:
Expand All @@ -36,3 +39,7 @@ jobs:
socket_get_multi_profile.json
client_set_multi_profile.json
socket_set_multi_profile.json
meta_client_get_multi_profile.json
meta_client_get_profile.json
meta_client_set_multi_profile.json
meta_client_set_profile.json
14 changes: 7 additions & 7 deletions bin/benchmark
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
# frozen_string_literal: true

# This helps benchmark current performance of Dalli
# as well as compare performance of optimizated and non-optimized calls like multi-set vs set
# as well as compare performance of optimized and non-optimized calls like multi-set vs set
#
# run with:
# bundle exec bin/benchmark
# RUBY_YJIT_ENABLE=1 BENCH_TARGET=get bundle exec bin/benchmark
require 'bundler/inline'
require 'json'

gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'logger'
end

require_relative '../lib/dalli'
require 'json'
require 'benchmark/ips'
require 'monitor'
require_relative '../lib/dalli'

##
# StringSerializer is a serializer that avoids the overhead of Marshal or JSON.
# NoopSerializer is a serializer that avoids the overhead of Marshal or JSON.
##
class StringSerializer
class NoopSerializer
def self.dump(value)
value
end
Expand All @@ -34,7 +34,7 @@ class StringSerializer
end

dalli_url = ENV['BENCH_CACHE_URL'] || '127.0.0.1:11211'
bench_target = ENV['BENCH_TARGET'] || 'set'
bench_target = ENV['BENCH_TARGET'] || 'all'
bench_time = (ENV['BENCH_TIME'] || 10).to_i
bench_warmup = (ENV['BENCH_WARMUP'] || 3).to_i
bench_payload_size = (ENV['BENCH_PAYLOAD_SIZE'] || 700_000).to_i
Expand All @@ -54,7 +54,7 @@ sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
# Benchmarks didn't see any performance gains from increasing the SO_RCVBUF buffer size
# sock.setsockopt(Socket::SOL_SOCKET, ::Socket::SO_RCVBUF, 1024 * 1024 * 8)
# Benchamrks did see an improvement in performance when increasing the SO_SNDBUF buffer size
# Benchmarks did see an improvement in performance when increasing the SO_SNDBUF buffer size
# sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, 1024 * 1024 * 8)

# ensure the clients are all connected and working
Expand Down
14 changes: 7 additions & 7 deletions bin/profile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# run with:
# RUBY_YJIT_ENABLE=1 bundle exec bin/profile
require 'bundler/inline'
require 'json'

gemfile do
source 'https://rubygems.org'
Expand All @@ -16,14 +15,15 @@ gemfile do
gem 'logger'
end

require_relative '../lib/dalli'
require 'json'
require 'benchmark/ips'
require 'vernier'
require_relative '../lib/dalli'

##
# StringSerializer is a serializer that avoids the overhead of Marshal or JSON.
# NoopSerializer is a serializer that avoids the overhead of Marshal or JSON.
##
class StringSerializer
class NoopSerializer
def self.dump(value)
value
end
Expand All @@ -34,8 +34,8 @@ class StringSerializer
end

dalli_url = ENV['BENCH_CACHE_URL'] || '127.0.0.1:11211'
bench_target = ENV['BENCH_TARGET'] || 'get'
bench_time = (ENV['BENCH_TIME'] || 10).to_i
bench_target = ENV['BENCH_TARGET'] || 'all'
bench_time = (ENV['BENCH_TIME'] || 8).to_i
bench_payload_size = (ENV['BENCH_PAYLOAD_SIZE'] || 700_000).to_i
TERMINATOR = "\r\n"
puts "yjit: #{RubyVM::YJIT.enabled?}"
Expand All @@ -50,7 +50,7 @@ sock.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
# Benchmarks didn't see any performance gains from increasing the SO_RCVBUF buffer size
# sock.setsockopt(Socket::SOL_SOCKET, ::Socket::SO_RCVBUF, 1024 * 1024 * 8)
# Benchamrks did see an improvement in performance when increasing the SO_SNDBUF buffer size
# Benchmarks did see an improvement in performance when increasing the SO_SNDBUF buffer size
# sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF, 1024 * 1024 * 8)

payload = 'B' * bench_payload_size
Expand Down

0 comments on commit 1eb8767

Please sign in to comment.