duel-memcached 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +6 -2
- data/lib/duel/memcached/version.rb +1 -1
- data/lib/duel/memcached.rb +48 -17
- data/sig/duel/memcached.rbs +13 -5
- metadata +43 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d9e1b7247b20136bad2746f274600f4008625eb657f36356bea149596d12760
|
|
4
|
+
data.tar.gz: 50b03080f96bea9b09bd6f27c3f5070f8b7160a7b33e9378ac0ed64ff9ea91d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 159c60fba77f9657fc64a70892fa1038ac19599a2e0403cfa05236ac143516b061b77b0e63a2fb40efe161a2623c7b0ae1b6d851b2b659af42b1762fd3d22724
|
|
7
|
+
data.tar.gz: c7f7f71269263f3129618c32ffda0e6671d8cba7bee5910ca97569786baba8ea9292efce302ca3674e66b2ed9bac0b5bb713180ec09342bb191f083fb29eae8f
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-11-16
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `tcp: true` starts each worker's server on a port of 127.0.0.1's
|
|
15
|
+
alone, its server `127.0.0.1:PORT`, rather than a Unix socket: the
|
|
16
|
+
default on Windows, whose builds of memcached have no Unix socket.
|
|
17
|
+
|
|
10
18
|
## [0.1.8] - 2026-11-12
|
|
11
19
|
|
|
12
20
|
No changes of its own: released in step with the other Duel gems.
|
|
@@ -80,7 +88,8 @@ the MIT license. It needs Ruby 3.4 or later, Duel 0.1, and `memcached`
|
|
|
80
88
|
`Duel::Memcached.sum` takes that reply.
|
|
81
89
|
|
|
82
90
|
|
|
83
|
-
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-memcached-v0.
|
|
91
|
+
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-memcached-v0.2.0...HEAD
|
|
92
|
+
[0.2.0]: https://github.com/sferik/duel-ruby/compare/duel-memcached-v0.1.8...duel-memcached-v0.2.0
|
|
84
93
|
[0.1.8]: https://github.com/sferik/duel-ruby/compare/duel-memcached-v0.1.7...duel-memcached-v0.1.8
|
|
85
94
|
[0.1.7]: https://github.com/sferik/duel-ruby/compare/duel-memcached-v0.1.6...duel-memcached-v0.1.7
|
|
86
95
|
[0.1.6]: https://github.com/sferik/duel-ruby/compare/duel-memcached-v0.1.5...duel-memcached-v0.1.6
|
data/README.md
CHANGED
|
@@ -45,7 +45,10 @@ Duel.configure { |c| c.use :memcached }
|
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Each worker's server listens only on a Unix socket in the worker's own
|
|
48
|
-
directory
|
|
48
|
+
directory (or with `tcp: true`, on a port of 127.0.0.1's alone, as it
|
|
49
|
+
does by default on Windows, whose builds of memcached have no Unix
|
|
50
|
+
socket), with 32 MB of memory and one thread. The socket's path (or
|
|
51
|
+
`127.0.0.1:PORT`) is in
|
|
49
52
|
`DUEL_MEMCACHED_SERVERS`, and in `MEMCACHE_SERVERS` too, so a client that
|
|
50
53
|
reads that (Dalli does) finds it and nothing reaches another memcached.
|
|
51
54
|
Benchmarks can call `Duel::Memcached.servers` and
|
|
@@ -75,7 +78,8 @@ c.use :memcached,
|
|
|
75
78
|
server: "/opt/memcached/bin/memcached", # the program (default: DUEL_MEMCACHED_SERVER, or memcached)
|
|
76
79
|
args: ["-m", "256"], # more of its options (they win)
|
|
77
80
|
env: %w[CACHE_SERVERS], # variables given its socket besides DUEL_MEMCACHED_SERVERS (default: MEMCACHE_SERVERS)
|
|
78
|
-
cpu: true
|
|
81
|
+
cpu: true, # judge memcached_cpu too
|
|
82
|
+
tcp: true # on a port of 127.0.0.1's, its server 127.0.0.1:PORT (default: on Windows only)
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
The metrics come from the server's `stats`, read over a connection of
|
data/lib/duel/memcached.rb
CHANGED
|
@@ -23,9 +23,11 @@ module Duel
|
|
|
23
23
|
# Duel::Memcached.flush in setup (or untimed blocks): while a benchmark
|
|
24
24
|
# is measured, it fails.
|
|
25
25
|
#
|
|
26
|
-
# The server listens only on a Unix socket in the worker's directory
|
|
27
|
-
# with
|
|
28
|
-
#
|
|
26
|
+
# The server listens only on a Unix socket in the worker's directory
|
|
27
|
+
# (or with +tcp+, on a port of 127.0.0.1's alone: by default on Windows,
|
|
28
|
+
# whose builds of memcached have no Unix socket), with one thread (so
|
|
29
|
+
# its statistics are up to date when they're read); the socket's path
|
|
30
|
+
# (or 127.0.0.1:PORT) is in DUEL_MEMCACHED_SERVERS, and in
|
|
29
31
|
# MEMCACHE_SERVERS too (unless +env+ names others), so a client that
|
|
30
32
|
# reads that (Dalli does) finds it.
|
|
31
33
|
module Memcached
|
|
@@ -38,12 +40,20 @@ module Duel
|
|
|
38
40
|
# metrics, memcached_cpu too with +cpu+. Returns the plugin's own
|
|
39
41
|
# connection to it, a worker's (see Config#in_worker, and in tests,
|
|
40
42
|
# Duel::Testing.in_worker).
|
|
41
|
-
def self.configure(config, server: ENV.fetch("DUEL_MEMCACHED_SERVER", "memcached"), args: [], env: %w[MEMCACHE_SERVERS], cpu: false
|
|
43
|
+
def self.configure(config, server: ENV.fetch("DUEL_MEMCACHED_SERVER", "memcached"), args: [], env: %w[MEMCACHE_SERVERS], cpu: false,
|
|
44
|
+
tcp: !Duel.unix_sockets?)
|
|
42
45
|
config.prepare(:worker) do |w|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
if tcp
|
|
47
|
+
port = w.port
|
|
48
|
+
listen = ["-l", "127.0.0.1", "-p", port.to_s]
|
|
49
|
+
address = "127.0.0.1:#{port}"
|
|
50
|
+
else
|
|
51
|
+
address = w.path("memcached.sock")
|
|
52
|
+
listen = ["-s", address]
|
|
53
|
+
end
|
|
54
|
+
w.spawn(*[server, *listen, "-m", "32", "-t", "1"] + args)
|
|
55
|
+
w.wait_until { Connection.ready?(address) }
|
|
56
|
+
([SERVERS] + env).to_h { |name| [name, address] }
|
|
47
57
|
end
|
|
48
58
|
connection = config.in_worker { |w| Connection.new(servers).tap { |memcached| w.at_stop { memcached.close } } }
|
|
49
59
|
config.metric(METRICS) { stats(connection.value) }.costly
|
|
@@ -117,7 +127,8 @@ module Duel
|
|
|
117
127
|
value
|
|
118
128
|
end
|
|
119
129
|
|
|
120
|
-
# For benchmarks: the worker's server (its socket's path
|
|
130
|
+
# For benchmarks: the worker's server (its socket's path, or
|
|
131
|
+
# 127.0.0.1:PORT).
|
|
121
132
|
def self.servers = ENV.fetch(SERVERS)
|
|
122
133
|
|
|
123
134
|
# Empties it, over a connection of its own (opened and closed: a Unix
|
|
@@ -147,20 +158,40 @@ module Duel
|
|
|
147
158
|
# The most read at a time: a whole stats reply (some 2.5KB) at once.
|
|
148
159
|
READ = 65_536
|
|
149
160
|
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
# A socket to the server at +server+: a Unix socket's path, or
|
|
162
|
+
# HOST:PORT, without TCP's delay before a small write (a command),
|
|
163
|
+
# whose reply would wait for it.
|
|
164
|
+
def self.socket(server)
|
|
165
|
+
address = address(server)
|
|
166
|
+
return UNIXSocket.new(server) unless address
|
|
167
|
+
|
|
168
|
+
host, port = address
|
|
169
|
+
# (RBS's setsockopt takes an Integer for the value, but Ruby's
|
|
170
|
+
# takes true too.)
|
|
171
|
+
TCPSocket.new(host, port).tap { |socket| socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true) } # steep:ignore ArgumentTypeMismatch
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# The host and port of a HOST:PORT server, or nil (a Unix socket's
|
|
175
|
+
# path).
|
|
176
|
+
def self.address(server)
|
|
177
|
+
match = %r{\A([^:/]+):(\d+)\z}.match(server) or return
|
|
178
|
+
[match[1], Integer(match[2])]
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def self.ready?(server)
|
|
182
|
+
connection = socket(server)
|
|
152
183
|
begin
|
|
153
|
-
|
|
154
|
-
|
|
184
|
+
connection.write("version\r\n")
|
|
185
|
+
connection.gets.to_s.start_with?("VERSION ")
|
|
155
186
|
ensure
|
|
156
|
-
|
|
187
|
+
connection.close
|
|
157
188
|
end
|
|
158
|
-
rescue SystemCallError, IOError # (JRuby's refusal is an IOError)
|
|
189
|
+
rescue SystemCallError, IOError # (JRuby's refusal on a Unix socket is an IOError)
|
|
159
190
|
false
|
|
160
191
|
end
|
|
161
192
|
|
|
162
|
-
def initialize(
|
|
163
|
-
@socket =
|
|
193
|
+
def initialize(server)
|
|
194
|
+
@socket = Connection.socket(server)
|
|
164
195
|
@sent = @received = @own = 0
|
|
165
196
|
@reply = +""
|
|
166
197
|
@chunk = +""
|
data/sig/duel/memcached.rbs
CHANGED
|
@@ -23,9 +23,10 @@ module Duel
|
|
|
23
23
|
# Configures Duel for the plugin (c.use :memcached): the server
|
|
24
24
|
# (+server+ is the program, +args+ more of its options, +env+ the
|
|
25
25
|
# variables besides DUEL_MEMCACHED_SERVERS given its socket's path)
|
|
26
|
-
# and its metrics, memcached_cpu too with +cpu
|
|
26
|
+
# and its metrics, memcached_cpu too with +cpu+, on a port of
|
|
27
|
+
# 127.0.0.1's with +tcp+ (by default on Windows). Returns the plugin's
|
|
27
28
|
# own connection to it, a worker's.
|
|
28
|
-
def self.configure: (Config config, ?server: String, ?args: Array[String], ?env: Array[String], ?cpu: bool) -> InWorker[Connection]
|
|
29
|
+
def self.configure: (Config config, ?server: String, ?args: Array[String], ?env: Array[String], ?cpu: bool, ?tcp: bool) -> InWorker[Connection]
|
|
29
30
|
|
|
30
31
|
# What the worker's server has done so far (but memcached_cpu), read
|
|
31
32
|
# over +connection+ (the plugin's own). It allocates only its Hash.
|
|
@@ -50,7 +51,7 @@ module Duel
|
|
|
50
51
|
|
|
51
52
|
# The least a connection needs to read a server's statistics.
|
|
52
53
|
class Connection
|
|
53
|
-
@socket: UNIXSocket
|
|
54
|
+
@socket: UNIXSocket | TCPSocket
|
|
54
55
|
@sent: Integer
|
|
55
56
|
@received: Integer
|
|
56
57
|
@reply: String
|
|
@@ -62,9 +63,16 @@ module Duel
|
|
|
62
63
|
# The most read at a time.
|
|
63
64
|
READ: Integer
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
# A socket to the server at +server+ (a Unix socket's path, or
|
|
67
|
+
# HOST:PORT).
|
|
68
|
+
def self.socket: (String server) -> (UNIXSocket | TCPSocket)
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
# The host and port of a HOST:PORT server, or nil.
|
|
71
|
+
def self.address: (String server) -> [String, Integer]?
|
|
72
|
+
|
|
73
|
+
def self.ready?: (String server) -> bool
|
|
74
|
+
|
|
75
|
+
def initialize: (String server) -> void
|
|
68
76
|
|
|
69
77
|
# The server's statistics, by name.
|
|
70
78
|
def stats: () -> Hash[String, String]
|
metadata
CHANGED
|
@@ -1,65 +1,68 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: duel-memcached
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Erik Berlin
|
|
7
|
+
- Erik Berlin
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: duel
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "0.2"
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ~>
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: "0.2"
|
|
28
|
+
description: "A Duel plugin: each worker gets a memcached server of its own, and every benchmark is judged on the memcached operations, misses and bytes it took too."
|
|
28
29
|
email:
|
|
29
|
-
- sferik@gmail.com
|
|
30
|
+
- sferik@gmail.com
|
|
30
31
|
executables: []
|
|
31
32
|
extensions: []
|
|
32
33
|
extra_rdoc_files: []
|
|
33
34
|
files:
|
|
34
|
-
- CHANGELOG.md
|
|
35
|
-
- LICENSE
|
|
36
|
-
- README.md
|
|
37
|
-
- lib/duel/memcached.rb
|
|
38
|
-
- lib/duel/memcached/version.rb
|
|
39
|
-
- sig/duel/memcached.rbs
|
|
40
|
-
homepage: https://github.com/sferik/duel-ruby/tree/main/plugins/memcached
|
|
35
|
+
- CHANGELOG.md
|
|
36
|
+
- LICENSE
|
|
37
|
+
- README.md
|
|
38
|
+
- lib/duel/memcached.rb
|
|
39
|
+
- lib/duel/memcached/version.rb
|
|
40
|
+
- sig/duel/memcached.rbs
|
|
41
|
+
homepage: "https://github.com/sferik/duel-ruby/tree/main/plugins/memcached"
|
|
41
42
|
licenses:
|
|
42
|
-
- MIT
|
|
43
|
+
- MIT
|
|
43
44
|
metadata:
|
|
44
|
-
source_code_uri: https://github.com/sferik/duel-ruby/tree/main/plugins/memcached
|
|
45
|
-
changelog_uri: https://github.com/sferik/duel-ruby/blob/main/plugins/memcached/CHANGELOG.md
|
|
46
|
-
bug_tracker_uri: https://github.com/sferik/duel-ruby/issues
|
|
47
|
-
rubygems_mfa_required:
|
|
45
|
+
source_code_uri: "https://github.com/sferik/duel-ruby/tree/main/plugins/memcached"
|
|
46
|
+
changelog_uri: "https://github.com/sferik/duel-ruby/blob/main/plugins/memcached/CHANGELOG.md"
|
|
47
|
+
bug_tracker_uri: "https://github.com/sferik/duel-ruby/issues"
|
|
48
|
+
rubygems_mfa_required: "true"
|
|
48
49
|
rdoc_options: []
|
|
49
50
|
require_paths:
|
|
50
|
-
- lib
|
|
51
|
+
- lib
|
|
51
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
53
|
requirements:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
-
|
|
55
|
+
- ">="
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: "3.4"
|
|
56
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
59
|
requirements:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
-
|
|
61
|
+
- ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: "0"
|
|
61
64
|
requirements: []
|
|
62
|
-
rubygems_version: 4.0
|
|
65
|
+
rubygems_version: 4.1.0
|
|
63
66
|
specification_version: 4
|
|
64
|
-
summary: A memcached server for each Duel worker, and what it did for each benchmark
|
|
67
|
+
summary: "A memcached server for each Duel worker, and what it did for each benchmark"
|
|
65
68
|
test_files: []
|