async 2.22.0 → 2.23.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef8aa467e82d3ddcd2c24a823ffba2e2b9e1680d005fade667ef36c882588dd1
4
- data.tar.gz: c2df7e4669fe9d2f0bb8d6c6f7de673d1a89e41d8ffc99bf702f79cefbce7a3e
3
+ metadata.gz: dedd26d802fb259e0eff2223a86a54f42b46753ab43014b091a83b97610346a0
4
+ data.tar.gz: 682ab4c4b3798df642e3937b902f4a0d0762ce0dfd91f5c2430205775b2bbe8a
5
5
  SHA512:
6
- metadata.gz: 2a98aaf33872cafab28e41acf187425926a3e0423ee5017bfd42fef66e64f55ad0ec6d6d1a053987813a3f190471e4521bac7c8895fb1ee352b8e984cf1dd326
7
- data.tar.gz: 64205b564a8de8aeb22d0ae6834ea9dfd114439336e7bd076de489da0e045f002a9d90f51f72414c36ed006a599cd536d27ff852b5f8f9541f3c656c3d9e7035
6
+ metadata.gz: d45d3a428c1403b999be51a831e44206ed1636bbfd7603cee7c4e71d03ec2e2e3941b329deb30b18aa4b1021f0b0360726898017ee48933a2262ebaf6c1980df
7
+ data.tar.gz: da44d07b913e0efff2aff07ff545f5996806601b33ca69b707c5e462d0858ad85e613b5ad6b8d4d53cdd21dd1d80852acf5b71b7359b3b26c2ab10437730873c
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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
- DEFAULT_WORKER_POOL = ENV.fetch("ASYNC_SCHEDULER_DEFAULT_WORKER_POOL", nil).then do |value|
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: DEFAULT_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
- initial_task = self.async(...) if block_given?
496
-
497
- self.run_loop do
498
- run_once
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
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
5
 
6
6
  module Async
7
- VERSION = "2.22.0"
7
+ VERSION = "2.23.0"
8
8
  end
@@ -14,8 +14,6 @@ Metrics::Provider(Async::Task) do
14
14
  ASYNC_TASK_SCHEDULED.emit(1)
15
15
 
16
16
  super(&block)
17
- rescue => error
18
- raise
19
17
  ensure
20
18
  ASYNC_TASK_FINISHED.emit(1)
21
19
  end
data/readme.md CHANGED
@@ -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
- ASYNC_SCHEDULER_DEFAULT_WORKER_POOL=true
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.22.0
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-02-07 00:00:00.000000000 Z
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.7'
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.7'
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