From 1eb87677290372f451c405c037e8a7dbb892730f Mon Sep 17 00:00:00 2001 From: Dan Mayer Date: Thu, 13 Feb 2025 12:43:10 -0700 Subject: [PATCH] address feedback --- .github/workflows/benchmarks.yml | 2 +- .github/workflows/profile.yml | 7 +++++++ bin/benchmark | 14 +++++++------- bin/profile | 14 +++++++------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 6ed90a1f..02f386c5 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -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 diff --git a/.github/workflows/profile.yml b/.github/workflows/profile.yml index e4e59004..a85f03d1 100644 --- a/.github/workflows/profile.yml +++ b/.github/workflows/profile.yml @@ -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: @@ -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 diff --git a/bin/benchmark b/bin/benchmark index 130b7ef4..2c8bc38f 100755 --- a/bin/benchmark +++ b/bin/benchmark @@ -2,13 +2,12 @@ # 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' @@ -16,14 +15,15 @@ gemfile do 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 @@ -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 @@ -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 diff --git a/bin/profile b/bin/profile index 048c95e6..9d88d3dd 100755 --- a/bin/profile +++ b/bin/profile @@ -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' @@ -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 @@ -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?}" @@ -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