atomic-ruby 0.3.1 → 0.3.2
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 +4 -0
- data/README.md +41 -22
- data/lib/atomic-ruby/atomic_ruby.bundle +0 -0
- data/lib/atomic-ruby/atomic_thread_pool.rb +7 -5
- data/lib/atomic-ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e47f4b67bd3d4dcaecbd560ed61b8dc4c86c24882b52279a5d0e92fd6de666a
|
4
|
+
data.tar.gz: 2fb299af89ccc871b7c8b3d6ef18f15924e98b90ad196143c0ea9fa3cac76419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb201628eedea540bea2a8436daf0bb9f9db3cf2f0cd1caa5d27a54af840b992474cf4e08496a52c16f963ab311cd14f3796977f6777140c648e38cd283a6679
|
7
|
+
data.tar.gz: fe346ae21ffa67e8ed82048a1b79fe2eada3f101e2b812112eef689139f924e01b420b6e0d56f37ca2c795e597bd86631e79f8d93fa5d32f50a77ef7eb1f9734
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -169,6 +169,7 @@ results = []
|
|
169
169
|
results << result
|
170
170
|
end
|
171
171
|
|
172
|
+
puts "\n"
|
172
173
|
puts "ruby version: #{RUBY_DESCRIPTION}"
|
173
174
|
puts "concurrent-ruby version: #{Concurrent::VERSION}"
|
174
175
|
puts "atomic-ruby version: #{AtomicRuby::VERSION}"
|
@@ -189,7 +190,7 @@ puts "Atomic Ruby Atomic Bank Account: #{results[2].real.round(6)} seconds"
|
|
189
190
|
|
190
191
|
ruby version: ruby 3.4.4 (2025-05-14 revision a38531fd3f) +YJIT +PRISM [arm64-darwin24]
|
191
192
|
concurrent-ruby version: 1.3.5
|
192
|
-
atomic-ruby version: 0.3.
|
193
|
+
atomic-ruby version: 0.3.2
|
193
194
|
|
194
195
|
Balances:
|
195
196
|
Synchronized Bank Account Balance: 975
|
@@ -197,9 +198,9 @@ Concurrent Ruby Atomic Bank Account Balance: 975
|
|
197
198
|
Atomic Ruby Atomic Bank Account Balance: 975
|
198
199
|
|
199
200
|
Benchmark Results:
|
200
|
-
Synchronized Bank Account: 5.
|
201
|
-
Concurrent Ruby Atomic Bank Account: 5.
|
202
|
-
Atomic Ruby Atomic Bank Account: 5.
|
201
|
+
Synchronized Bank Account: 5.130792 seconds
|
202
|
+
Concurrent Ruby Atomic Bank Account: 5.121400 seconds
|
203
|
+
Atomic Ruby Atomic Bank Account: 5.119191 seconds
|
203
204
|
```
|
204
205
|
|
205
206
|
</details>
|
@@ -215,6 +216,23 @@ require "benchmark/ips"
|
|
215
216
|
require "concurrent-ruby"
|
216
217
|
require_relative "../lib/atomic-ruby"
|
217
218
|
|
219
|
+
module Benchmark
|
220
|
+
module IPS
|
221
|
+
class Job
|
222
|
+
class StreamReport
|
223
|
+
def start_warming
|
224
|
+
@out.puts "\n"
|
225
|
+
@out.puts "ruby version: #{RUBY_DESCRIPTION}"
|
226
|
+
@out.puts "concurrent-ruby version: #{Concurrent::VERSION}"
|
227
|
+
@out.puts "atomic-ruby version: #{AtomicRuby::VERSION}"
|
228
|
+
@out.puts "\n"
|
229
|
+
@out.puts "Warming up --------------------------------------"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
218
236
|
Benchmark.ips do |x|
|
219
237
|
x.report("Synchronized Boolean Toggle") do
|
220
238
|
boolean = false
|
@@ -261,26 +279,29 @@ end
|
|
261
279
|
```
|
262
280
|
> bundle exec rake compile && bundle exec ruby examples/atomic_boolean_benchmark.rb
|
263
281
|
|
264
|
-
ruby 3.4.4 (2025-05-14 revision a38531fd3f) +YJIT +PRISM [arm64-darwin24]
|
282
|
+
ruby version: ruby 3.4.4 (2025-05-14 revision a38531fd3f) +YJIT +PRISM [arm64-darwin24]
|
283
|
+
concurrent-ruby version: 1.3.5
|
284
|
+
atomic-ruby version: 0.3.2
|
285
|
+
|
265
286
|
Warming up --------------------------------------
|
266
287
|
Synchronized Boolean Toggle
|
267
|
-
|
288
|
+
87.000 i/100ms
|
268
289
|
Concurrent Ruby Atomic Boolean Toggle
|
269
|
-
|
290
|
+
81.000 i/100ms
|
270
291
|
Atomic Ruby Atomic Boolean Toggle
|
271
|
-
|
292
|
+
92.000 i/100ms
|
272
293
|
Calculating -------------------------------------
|
273
294
|
Synchronized Boolean Toggle
|
274
|
-
|
295
|
+
969.205 (± 5.8%) i/s (1.03 ms/i) - 4.872k in 5.043520s
|
275
296
|
Concurrent Ruby Atomic Boolean Toggle
|
276
|
-
|
297
|
+
885.546 (± 5.2%) i/s (1.13 ms/i) - 4.455k in 5.044282s
|
277
298
|
Atomic Ruby Atomic Boolean Toggle
|
278
|
-
|
299
|
+
1.154k (± 5.3%) i/s (866.65 μs/i) - 5.796k in 5.037272s
|
279
300
|
|
280
301
|
Comparison:
|
281
|
-
Atomic Ruby Atomic Boolean Toggle:
|
282
|
-
Synchronized Boolean Toggle:
|
283
|
-
Concurrent Ruby Atomic Boolean Toggle:
|
302
|
+
Atomic Ruby Atomic Boolean Toggle: 1153.9 i/s
|
303
|
+
Synchronized Boolean Toggle: 969.2 i/s - 1.19x slower
|
304
|
+
Concurrent Ruby Atomic Boolean Toggle: 885.5 i/s - 1.30x slower
|
284
305
|
```
|
285
306
|
|
286
307
|
</details>
|
@@ -315,17 +336,15 @@ results = []
|
|
315
336
|
pool << -> { 1_000_000.times.map(&:itself).sum }
|
316
337
|
end
|
317
338
|
|
318
|
-
# concurrent-ruby does not wait for threads to die on shutdown
|
319
|
-
threads = if idx == 0
|
320
|
-
pool.instance_variable_get(:@pool).map { |worker| worker.instance_variable_get(:@thread) }
|
321
|
-
end
|
322
339
|
pool.shutdown
|
323
|
-
threads
|
340
|
+
# concurrent-ruby's #shutdown does not wait for threads to terminate
|
341
|
+
pool.wait_for_termination if idx == 0
|
324
342
|
end
|
325
343
|
|
326
344
|
results << result
|
327
345
|
end
|
328
346
|
|
347
|
+
puts "\n"
|
329
348
|
puts "ruby version: #{RUBY_DESCRIPTION}"
|
330
349
|
puts "concurrent-ruby version: #{Concurrent::VERSION}"
|
331
350
|
puts "atomic-ruby version: #{AtomicRuby::VERSION}"
|
@@ -340,11 +359,11 @@ puts "Atomic Ruby Atomic Thread Pool: #{results[1].real.round(6)} seconds"
|
|
340
359
|
|
341
360
|
ruby version: ruby 3.4.4 (2025-05-14 revision a38531fd3f) +YJIT +PRISM [arm64-darwin24]
|
342
361
|
concurrent-ruby version: 1.3.5
|
343
|
-
atomic-ruby version: 0.3.
|
362
|
+
atomic-ruby version: 0.3.2
|
344
363
|
|
345
364
|
Benchmark Results:
|
346
|
-
Concurrent Ruby Thread Pool: 5.
|
347
|
-
Atomic Ruby Atomic Thread Pool: 4.
|
365
|
+
Concurrent Ruby Thread Pool: 5.032940 seconds
|
366
|
+
Atomic Ruby Atomic Thread Pool: 4.508259 seconds
|
348
367
|
```
|
349
368
|
|
350
369
|
</details>
|
Binary file
|
@@ -23,11 +23,13 @@ module AtomicRuby
|
|
23
23
|
raise UnsupportedWorkTypeError, "expected work to be a `Proc`, got #{work.class}"
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
@queue.swap do |current_queue|
|
27
|
+
if @stopping.true?
|
28
|
+
raise InvalidWorkQueueingError, "cannot queue work during or after pool shutdown"
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
+
current_queue += [work]
|
32
|
+
end
|
31
33
|
true
|
32
34
|
end
|
33
35
|
|
@@ -80,7 +82,7 @@ module AtomicRuby
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
83
|
-
|
85
|
+
Thread.pass until @started_threads.value == @size
|
84
86
|
end
|
85
87
|
end
|
86
88
|
end
|
data/lib/atomic-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomic-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Young
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
|
-
rubygems_version: 3.
|
53
|
+
rubygems_version: 3.7.0.dev
|
54
54
|
specification_version: 4
|
55
55
|
summary: Atomic primitives for Ruby
|
56
56
|
test_files: []
|