async 2.21.3 → 2.23.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
- checksums.yaml.gz.sig +0 -0
- data/lib/async/barrier.md +1 -1
- data/lib/async/clock.rb +9 -0
- data/lib/async/condition.md +1 -1
- data/lib/async/scheduler.rb +24 -8
- data/lib/async/version.rb +1 -1
- data/lib/metrics/provider/async/task.rb +3 -0
- data/readme.md +6 -1
- data/releases.md +25 -1
- data.tar.gz.sig +0 -0
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dedd26d802fb259e0eff2223a86a54f42b46753ab43014b091a83b97610346a0
|
4
|
+
data.tar.gz: 682ab4c4b3798df642e3937b902f4a0d0762ce0dfd91f5c2430205775b2bbe8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d45d3a428c1403b999be51a831e44206ed1636bbfd7603cee7c4e71d03ec2e2e3941b329deb30b18aa4b1021f0b0360726898017ee48933a2262ebaf6c1980df
|
7
|
+
data.tar.gz: da44d07b913e0efff2aff07ff545f5996806601b33ca69b707c5e462d0858ad85e613b5ad6b8d4d53cdd21dd1d80852acf5b71b7359b3b26c2ab10437730873c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/async/barrier.md
CHANGED
data/lib/async/clock.rb
CHANGED
data/lib/async/condition.md
CHANGED
data/lib/async/scheduler.rb
CHANGED
@@ -15,9 +15,17 @@ require "console"
|
|
15
15
|
require "resolv"
|
16
16
|
|
17
17
|
module Async
|
18
|
+
begin
|
19
|
+
require "fiber/profiler"
|
20
|
+
Profiler = Fiber::Profiler
|
21
|
+
rescue LoadError
|
22
|
+
# Fiber::Profiler is not available.
|
23
|
+
Profiler = nil
|
24
|
+
end
|
25
|
+
|
18
26
|
# Handles scheduling of fibers. Implements the fiber scheduler interface.
|
19
27
|
class Scheduler < Node
|
20
|
-
|
28
|
+
WORKER_POOL = ENV.fetch("ASYNC_SCHEDULER_WORKER_POOL", nil).then do |value|
|
21
29
|
value == "true" ? true : nil
|
22
30
|
end
|
23
31
|
|
@@ -42,10 +50,12 @@ module Async
|
|
42
50
|
# @public Since *Async v1*.
|
43
51
|
# @parameter parent [Node | Nil] The parent node to use for task hierarchy.
|
44
52
|
# @parameter selector [IO::Event::Selector] The selector to use for event handling.
|
45
|
-
def initialize(parent = nil, selector: nil, worker_pool:
|
53
|
+
def initialize(parent = nil, selector: nil, profiler: Profiler&.default, worker_pool: WORKER_POOL)
|
46
54
|
super(parent)
|
47
55
|
|
48
56
|
@selector = selector || ::IO::Event::Selector.new(Fiber.current)
|
57
|
+
@profiler = profiler
|
58
|
+
|
49
59
|
@interrupted = false
|
50
60
|
|
51
61
|
@blocked = 0
|
@@ -492,13 +502,19 @@ module Async
|
|
492
502
|
def run(...)
|
493
503
|
Kernel.raise ClosedError if @selector.nil?
|
494
504
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
505
|
+
begin
|
506
|
+
@profiler&.start
|
507
|
+
|
508
|
+
initial_task = self.async(...) if block_given?
|
509
|
+
|
510
|
+
self.run_loop do
|
511
|
+
run_once
|
512
|
+
end
|
513
|
+
|
514
|
+
return initial_task
|
515
|
+
ensure
|
516
|
+
@profiler&.stop
|
499
517
|
end
|
500
|
-
|
501
|
-
return initial_task
|
502
518
|
end
|
503
519
|
|
504
520
|
# Start an asynchronous task within the specified reactor. The task will be executed until the first blocking call, at which point it will yield and and this method will return.
|
data/lib/async/version.rb
CHANGED
@@ -8,10 +8,13 @@ require "metrics/provider"
|
|
8
8
|
|
9
9
|
Metrics::Provider(Async::Task) do
|
10
10
|
ASYNC_TASK_SCHEDULED = Metrics.metric("async.task.scheduled", :counter, description: "The number of tasks scheduled.")
|
11
|
+
ASYNC_TASK_FINISHED = Metrics.metric("async.task.finished", :counter, description: "The number of tasks finished.")
|
11
12
|
|
12
13
|
def schedule(&block)
|
13
14
|
ASYNC_TASK_SCHEDULED.emit(1)
|
14
15
|
|
15
16
|
super(&block)
|
17
|
+
ensure
|
18
|
+
ASYNC_TASK_FINISHED.emit(1)
|
16
19
|
end
|
17
20
|
end
|
data/readme.md
CHANGED
@@ -24,7 +24,7 @@ Please see the [project documentation](https://socketry.github.io/async/) for mo
|
|
24
24
|
|
25
25
|
- [Asynchronous Tasks](https://socketry.github.io/async/guides/asynchronous-tasks/index) - This guide explains how asynchronous tasks work and how to use them.
|
26
26
|
|
27
|
-
- [
|
27
|
+
- [Scheduler](https://socketry.github.io/async/guides/scheduler/index) - This guide gives an overview of how the scheduler is implemented.
|
28
28
|
|
29
29
|
- [Compatibility](https://socketry.github.io/async/guides/compatibility/index) - This guide gives an overview of the compatibility of Async with Ruby and other frameworks.
|
30
30
|
|
@@ -36,6 +36,11 @@ Please see the [project documentation](https://socketry.github.io/async/) for mo
|
|
36
36
|
|
37
37
|
Please see the [project releases](https://socketry.github.io/async/releases/index) for all releases.
|
38
38
|
|
39
|
+
### v2.23.0
|
40
|
+
|
41
|
+
- Rename `ASYNC_SCHEDULER_DEFAULT_WORKER_POOL` to `ASYNC_SCHEDULER_WORKER_POOL`.
|
42
|
+
- [Fiber Stall Profiler](https://socketry.github.io/async/releases/index#fiber-stall-profiler)
|
43
|
+
|
39
44
|
### v2.21.1
|
40
45
|
|
41
46
|
- [Worker Pool](https://socketry.github.io/async/releases/index#worker-pool)
|
data/releases.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Releases
|
2
2
|
|
3
|
+
## v2.23.0
|
4
|
+
|
5
|
+
- Rename `ASYNC_SCHEDULER_DEFAULT_WORKER_POOL` to `ASYNC_SCHEDULER_WORKER_POOL`.
|
6
|
+
|
7
|
+
### Fiber Stall Profiler
|
8
|
+
|
9
|
+
After several iterations of experimentation, we are officially introducing the fiber stall profiler, implemented using the optional `fiber-profiler` gem. This gem is not included by default, but can be added to your project:
|
10
|
+
|
11
|
+
``` bash
|
12
|
+
$ bundle add fiber-profiler
|
13
|
+
```
|
14
|
+
|
15
|
+
After adding the gem, you can enable the fiber stall profiler by setting the `FIBER_PROFILER_CAPTURE=true` environment variable:
|
16
|
+
|
17
|
+
``` bash
|
18
|
+
$ FIBER_PROFILER_CAPTURE=true bundle exec ruby -rasync -e 'Async{Fiber.blocking{sleep 0.1}}'
|
19
|
+
Fiber stalled for 0.105 seconds
|
20
|
+
-e:1 in c-call '#<Class:Fiber>#blocking' (0.105s)
|
21
|
+
-e:1 in c-call 'Kernel#sleep' (0.105s)
|
22
|
+
Skipped 1 calls that were too short to be meaningful.
|
23
|
+
```
|
24
|
+
|
25
|
+
The fiber profiler will help you find problems with your code that cause the event loop to stall, which can be a common source of performance issues in asynchronous code.
|
26
|
+
|
3
27
|
## v2.21.1
|
4
28
|
|
5
29
|
### Worker Pool
|
@@ -8,7 +32,7 @@ Ruby 3.4 will feature a new fiber scheduler hook, `blocking_operation_wait` whic
|
|
8
32
|
|
9
33
|
The Async scheduler optionally supports this feature using a worker pool, by using the following environment variable:
|
10
34
|
|
11
|
-
|
35
|
+
ASYNC_SCHEDULER_WORKER_POOL=true
|
12
36
|
|
13
37
|
This will cause the scheduler to use a worker pool for general blocking operations, rather than blocking the event loop.
|
14
38
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -62,7 +62,7 @@ cert_chain:
|
|
62
62
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
63
63
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
64
64
|
-----END CERTIFICATE-----
|
65
|
-
date: 2025-
|
65
|
+
date: 2025-02-13 00:00:00.000000000 Z
|
66
66
|
dependencies:
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: console
|
@@ -98,14 +98,14 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '1.
|
101
|
+
version: '1.9'
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
106
|
- - "~>"
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version: '1.
|
108
|
+
version: '1.9'
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: traces
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|