rails-profiler 0.44.9 → 0.44.12
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 +29 -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 +20 -8
- 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: 31af1f16fda6ca926b1dd3d4e13992e235b3006b8c81a238ce06d2e003a7793c
|
|
4
|
+
data.tar.gz: 2ac428bf14f9c80cd5bd12729bacb4989ca0d29607bf6a98611877bcfe0924a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80c65e06fb80613fc6f688dff701c16a91ed43428851c9217d6b986e0d0ea0836bd40ec10a0b72efe7086db6778bcbd303789cd4e75d61c83184e3eb2b767dc2
|
|
7
|
+
data.tar.gz: 7ccd51df55f9698ee0264d9fe2dac70be0f365e07d7db37181f3ba545b25ca7c4029fad969b0b43456551b8b4e13e641331fe4a343f186dd768962e0b5253307
|
data/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,35 @@ every commit of every tag interval is accounted for one way or the other.
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.44.12] - 2026-10-23
|
|
23
|
+
|
|
24
|
+
<!-- stamped -->
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **Compare:** metric diff now correctly distinguishes between absent collectors (no measurement to compare) and zero baselines (measured at zero), ensuring absent collectors remain neutral instead of incorrectly classified as improvements or regressions.
|
|
29
|
+
|
|
30
|
+
## [0.44.11] - 2026-10-22
|
|
31
|
+
|
|
32
|
+
<!-- stamped -->
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **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.
|
|
37
|
+
|
|
38
|
+
## [0.44.10] - 2026-10-22
|
|
39
|
+
|
|
40
|
+
<!-- stamped -->
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- **Cluster:** the master now logs a warning when a process with `cluster_master=true` forks, and
|
|
45
|
+
when a heartbeat is received for a slave not seen in the current worker, to help detect the
|
|
46
|
+
misconfiguration of running multiple master workers without a shared registry.
|
|
47
|
+
- **Documentation:** `DECISIONS.md` now correctly states that the gem provides shared storage
|
|
48
|
+
backends (file, SQLite, Redis); the decision to keep the slave registry single-process is based
|
|
49
|
+
on avoiding per-heartbeat writes, not on the lack of storage options.
|
|
50
|
+
|
|
22
51
|
## [0.44.9] - 2026-10-22
|
|
23
52
|
|
|
24
53
|
<!-- 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
|
|
@@ -97,22 +97,34 @@ module Profiler
|
|
|
97
97
|
delta = (b || 0) - (a || 0)
|
|
98
98
|
delta_pct = (a && a != 0) ? (delta / a * 100).round(1) : nil
|
|
99
99
|
|
|
100
|
-
status = compute_status(delta, delta_pct, direction, threshold_pct)
|
|
100
|
+
status = compute_status(delta, delta_pct, direction, threshold_pct, val_a: val_a)
|
|
101
101
|
|
|
102
102
|
{ value_a: val_a, value_b: val_b, delta: delta.round(4), delta_pct: delta_pct, status: status }
|
|
103
103
|
end
|
|
104
104
|
|
|
105
|
-
def compute_status(delta, delta_pct, direction, threshold_pct)
|
|
106
|
-
change_pct = delta_pct&.abs || 0
|
|
107
|
-
|
|
105
|
+
def compute_status(delta, delta_pct, direction, threshold_pct, val_a: nil)
|
|
108
106
|
if delta == 0
|
|
109
107
|
:neutral
|
|
110
|
-
elsif
|
|
108
|
+
elsif val_a.nil?
|
|
109
|
+
# Collector absent in baseline profile: no measurement to compare, stay neutral
|
|
111
110
|
:neutral
|
|
112
|
-
elsif
|
|
113
|
-
:
|
|
111
|
+
elsif delta_pct.nil?
|
|
112
|
+
# Collector present but baseline is zero: apply direction logic directly without threshold
|
|
113
|
+
if (direction == :lower && delta < 0) || (direction == :higher && delta > 0)
|
|
114
|
+
:improved
|
|
115
|
+
else
|
|
116
|
+
:regression
|
|
117
|
+
end
|
|
114
118
|
else
|
|
115
|
-
:
|
|
119
|
+
# Baseline is non-zero: apply threshold
|
|
120
|
+
change_pct = delta_pct.abs
|
|
121
|
+
if change_pct <= threshold_pct
|
|
122
|
+
:neutral
|
|
123
|
+
elsif (direction == :lower && delta < 0) || (direction == :higher && delta > 0)
|
|
124
|
+
:improved
|
|
125
|
+
else
|
|
126
|
+
:regression
|
|
127
|
+
end
|
|
116
128
|
end
|
|
117
129
|
end
|
|
118
130
|
|
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