rails-profiler 0.44.9 → 0.44.11
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 +21 -0
- data/app/controllers/profiler/api/cluster_controller.rb +1 -0
- data/lib/profiler/cluster/master_client.rb +20 -0
- data/lib/profiler/profile_diff.rb +16 -7
- data/lib/profiler/railtie.rb +12 -1
- data/lib/profiler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '09e0c24dd672f0b760b41659e2e84dbb2ee21d6f193271fceeebb1c0034d44d8'
|
|
4
|
+
data.tar.gz: 577bac65e14c99522006a78f700ac63931c2c6b2f9d4670572274571722b5962
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0576b03a26c219dc6f6c984db4020b20163b0231fa98198577764c0885053df645a21b306a3af5fe2b05d2b029f303ad819ade2b5e496a959d1f01f0623e6a7e
|
|
7
|
+
data.tar.gz: e71ce16de91dc638b81760ff41fca3b8d49bc829f0982aa4222446c8a5103557c04b134dbb99d9f75513043ff7e26d1d953a7681de3fc83b0d3a5c3ce7d1b672
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,27 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.11] - 2026-10-22
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Compare:** metric status now correctly identifies improvements and regressions when baseline values are zero, classifying direction-aligned changes as improvements without requiring a percentage threshold.
|
|
29
|
+
|
|
30
|
+
## [0.44.10] - 2026-10-22
|
|
31
|
+
|
|
32
|
+
<!-- stamped -->
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **Cluster:** the master now logs a warning when a process with `cluster_master=true` forks, and
|
|
37
|
+
when a heartbeat is received for a slave not seen in the current worker, to help detect the
|
|
38
|
+
misconfiguration of running multiple master workers without a shared registry.
|
|
39
|
+
- **Documentation:** `DECISIONS.md` now correctly states that the gem provides shared storage
|
|
40
|
+
backends (file, SQLite, Redis); the decision to keep the slave registry single-process is based
|
|
41
|
+
on avoiding per-heartbeat writes, not on the lack of storage options.
|
|
42
|
+
|
|
22
43
|
## [0.44.9] - 2026-10-22
|
|
23
44
|
|
|
24
45
|
<!-- stamped -->
|
|
@@ -27,6 +27,7 @@ module Profiler
|
|
|
27
27
|
name = params[:name].to_s
|
|
28
28
|
entry = Profiler.slave_registry.heartbeat(name)
|
|
29
29
|
if entry.nil?
|
|
30
|
+
Profiler.log_warn("Cluster: received heartbeat for unknown slave #{name.inspect} (possible multi-worker misconfiguration)")
|
|
30
31
|
render json: { error: "Unknown slave - please re-register" }, status: :not_found
|
|
31
32
|
else
|
|
32
33
|
render json: { ok: true }
|
|
@@ -20,6 +20,15 @@ module Profiler
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Fork hook for a pure master (cluster_master=true, not a slave): logs a warning when forking.
|
|
24
|
+
module PureMasterForkHook
|
|
25
|
+
def _fork
|
|
26
|
+
pid = super
|
|
27
|
+
Profiler.log_warn("Cluster: master process forked: each worker maintains a separate slave registry") if pid.zero?
|
|
28
|
+
pid
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
23
32
|
# A master that does not answer must cost the heartbeat thread a few seconds, not a minute.
|
|
24
33
|
OPEN_TIMEOUT = 3
|
|
25
34
|
READ_TIMEOUT = 5
|
|
@@ -35,6 +44,13 @@ module Profiler
|
|
|
35
44
|
@fork_hook_installed = true
|
|
36
45
|
end
|
|
37
46
|
|
|
47
|
+
def install_pure_master_fork_hook!
|
|
48
|
+
return false if @pure_master_fork_hook_installed || !Process.respond_to?(:_fork)
|
|
49
|
+
|
|
50
|
+
Process.singleton_class.prepend(PureMasterForkHook)
|
|
51
|
+
@pure_master_fork_hook_installed = true
|
|
52
|
+
end
|
|
53
|
+
|
|
38
54
|
def restart_after_fork
|
|
39
55
|
current&.restart_after_fork
|
|
40
56
|
rescue => e
|
|
@@ -57,6 +73,10 @@ module Profiler
|
|
|
57
73
|
def restart_after_fork
|
|
58
74
|
return if @started.nil? || @thread&.alive?
|
|
59
75
|
|
|
76
|
+
if Profiler.configuration.cluster_master?
|
|
77
|
+
log_warn("master process forked: each worker maintains a separate slave registry")
|
|
78
|
+
end
|
|
79
|
+
|
|
60
80
|
@registered = false
|
|
61
81
|
@failed = false
|
|
62
82
|
start_heartbeat_thread
|
|
@@ -103,16 +103,25 @@ module Profiler
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def compute_status(delta, delta_pct, direction, threshold_pct)
|
|
106
|
-
change_pct = delta_pct&.abs || 0
|
|
107
|
-
|
|
108
106
|
if delta == 0
|
|
109
107
|
:neutral
|
|
110
|
-
elsif
|
|
111
|
-
:
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
elsif delta_pct.nil?
|
|
109
|
+
# Baseline is zero: apply direction logic directly without threshold
|
|
110
|
+
if (direction == :lower && delta < 0) || (direction == :higher && delta > 0)
|
|
111
|
+
:improved
|
|
112
|
+
else
|
|
113
|
+
:regression
|
|
114
|
+
end
|
|
114
115
|
else
|
|
115
|
-
:
|
|
116
|
+
# Baseline is non-zero: apply threshold
|
|
117
|
+
change_pct = delta_pct.abs
|
|
118
|
+
if change_pct <= threshold_pct
|
|
119
|
+
:neutral
|
|
120
|
+
elsif (direction == :lower && delta < 0) || (direction == :higher && delta > 0)
|
|
121
|
+
:improved
|
|
122
|
+
else
|
|
123
|
+
:regression
|
|
124
|
+
end
|
|
116
125
|
end
|
|
117
126
|
end
|
|
118
127
|
|
data/lib/profiler/railtie.rb
CHANGED
|
@@ -133,9 +133,20 @@ module Profiler
|
|
|
133
133
|
Profiler::Cluster::Security.warn_about_configuration(Rails.logger)
|
|
134
134
|
require_relative "peers"
|
|
135
135
|
Profiler::Peers.warn_about_configuration(Rails.logger)
|
|
136
|
-
next unless Profiler.configuration.slave?
|
|
137
136
|
|
|
138
137
|
require_relative "cluster/master_client"
|
|
138
|
+
|
|
139
|
+
cluster_master = Profiler.configuration.cluster_master?
|
|
140
|
+
is_slave = Profiler.configuration.slave?
|
|
141
|
+
|
|
142
|
+
# Install fork hook for pure masters (cluster_master=true, not a slave).
|
|
143
|
+
# If also a slave, MasterClient.start will install the fork hook and handle warnings.
|
|
144
|
+
if cluster_master && !is_slave
|
|
145
|
+
Profiler::Cluster::MasterClient.install_pure_master_fork_hook!
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
next unless is_slave
|
|
149
|
+
|
|
139
150
|
Profiler::Cluster::MasterClient.new.start
|
|
140
151
|
end
|
|
141
152
|
end
|
data/lib/profiler/version.rb
CHANGED