legionio 1.4.113 → 1.4.114

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bc29dbdc043d80b9a773952e27947a051447a879614c525559cc713589563d7
4
- data.tar.gz: 52849bf4f620389d528cec4a5100078d2ba84f61df813adaf92ee8b496ebc4cd
3
+ metadata.gz: '033549b7666e088a8ac6fae313d91767f35c04a607ba20feca1726a5090cc828'
4
+ data.tar.gz: 5020e3bbfb01cc909730d239ce80236b6ba787ea56b9329dd8872047e84ffd9f
5
5
  SHA512:
6
- metadata.gz: 32739ecd25c674deba1e604f4bbcb747c598cfcb471df7cfa79471747b109410449bcb20427bf68b7af812c926c93985fe7086367c3ab08ed851c53ac06f2b39
7
- data.tar.gz: 4dc74a77ffc8652c40273ede520207b71ccdde127275fffebb8f386e8a27a11f0fbe1985cda6bf3e619e0a1d0a2827a894c8f8505e8c0833aa72bce66805877e
6
+ metadata.gz: bb44c0c2f7f6545a26df93eb103c0876f7786256b19d6354c5b6268f3df34696925afd2225535260f862dba3475f797fd027f073609785af985b9d87e9abb011
7
+ data.tar.gz: ad9f7cc79fa61dc15c304e29daf07953b8a63f87dbe78e0f438d68c82c1bcb030fafbf8ced1facb18dd668857544b7637fcd736a8a23ccf52ad0a54d273c17ee
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Legion Changelog
2
2
 
3
+ ## [1.4.114] - 2026-03-22
4
+
5
+ ### Changed
6
+ - Parallelize extension loading using Concurrent::Promises thread pool (4 workers)
7
+ - Use Concurrent::Array for thread-safe pending_actors during parallel load
8
+ - ~4x faster boot: extensions load concurrently instead of serially
9
+
3
10
  ## [1.4.112] - 2026-03-21
4
11
 
5
12
  ### Added
@@ -20,7 +20,7 @@ module Legion
20
20
  @subscription_tasks = []
21
21
  @local_tasks = []
22
22
  @actors = []
23
- @pending_actors = []
23
+ @pending_actors = Concurrent::Array.new
24
24
 
25
25
  find_extensions
26
26
  load_extensions
@@ -52,7 +52,8 @@ module Legion
52
52
  def load_extensions
53
53
  @extensions ||= []
54
54
  @loaded_extensions ||= []
55
- @extensions.each do |entry|
55
+
56
+ eligible = @extensions.filter_map do |entry|
56
57
  gem_name = entry[:gem_name]
57
58
  ext_name = entry[:require_path].split('/').last
58
59
 
@@ -65,14 +66,11 @@ module Legion
65
66
  end
66
67
 
67
68
  Catalog.register(gem_name)
68
- unless load_extension(entry)
69
- Legion::Logging.warn("#{gem_name} failed to load")
70
- next
71
- end
72
- Catalog.transition(gem_name, :loaded)
73
- register_in_registry(gem_name: gem_name, version: entry[:version])
74
- @loaded_extensions.push(gem_name)
69
+ entry
75
70
  end
71
+
72
+ load_extensions_parallel(eligible)
73
+
76
74
  Legion::Logging.info(
77
75
  "#{@extensions.count} extensions loaded with " \
78
76
  "subscription:#{@subscription_tasks.count}," \
@@ -83,6 +81,32 @@ module Legion
83
81
  )
84
82
  end
85
83
 
84
+ def load_extensions_parallel(eligible)
85
+ return if eligible.empty?
86
+
87
+ pool_size = [4, eligible.count].min
88
+ executor = Concurrent::FixedThreadPool.new(pool_size)
89
+
90
+ futures = eligible.map do |entry|
91
+ Concurrent::Promises.future_on(executor, entry) { |e| load_extension(e) ? e : nil }
92
+ end
93
+
94
+ results = futures.map(&:value)
95
+
96
+ executor.shutdown
97
+ executor.wait_for_termination(30)
98
+
99
+ results.each_with_index do |result, idx|
100
+ if result
101
+ Catalog.transition(result[:gem_name], :loaded)
102
+ register_in_registry(gem_name: result[:gem_name], version: result[:version])
103
+ @loaded_extensions.push(result[:gem_name])
104
+ else
105
+ Legion::Logging.warn("#{eligible[idx][:gem_name]} failed to load")
106
+ end
107
+ end
108
+ end
109
+
86
110
  def load_extension(entry) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/MethodLength
87
111
  ensure_namespace(entry[:const_path]) if entry[:segments].length > 1
88
112
  return unless gem_load(entry)
@@ -177,7 +201,7 @@ module Legion
177
201
 
178
202
  Legion::Logging.info "Hooking #{@pending_actors.size} deferred actors"
179
203
  @pending_actors.each { |actor| hook_actor(**actor) }
180
- @pending_actors = []
204
+ @pending_actors.clear
181
205
  Legion::Logging.info(
182
206
  "Actors hooked: subscription:#{@subscription_tasks.count}," \
183
207
  "every:#{@timer_tasks.count}," \
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Legion
4
- VERSION = '1.4.113'
4
+ VERSION = '1.4.114'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legionio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.113
4
+ version: 1.4.114
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity