activesupport-minimizer 0.1.2 → 0.2.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
- data/CHANGELOG.md +4 -0
- data/README.md +34 -5
- data/lib/as_minimizer/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: 31636aeda8a4735600af514ddc5baf5e8fab14e491f893b402f3bf073c89b105
|
|
4
|
+
data.tar.gz: 2281325cd2c192462987066dcef9bb331cd560b2f18e764fdf1a2b9fb586094f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3b531206671b29e479b83d5c2009ca3126a29479de0e5a5b06afb0fddc8d1a01368b6ed2657a996cf6a155eeee2423518f97e755929e83ce9babb9712b7c888e
|
|
7
|
+
data.tar.gz: 2147719958aacc0b70fd371b9d34bc79167f80873e753bb6399b825e4c0b3087ca368154b59d1c3412987710b7a93037fb1d7d5c1ae4d1e7ee1b51aa74cac229
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2026-10-20)
|
|
4
|
+
|
|
5
|
+
- README: the callback checks come first; unrolled callbacks are experimental (no faster in production, ~20 MB more per worker). No code changes.
|
|
6
|
+
|
|
3
7
|
## 0.1.2 (2026-10-18)
|
|
4
8
|
|
|
5
9
|
- Rails main: the controller terminator (now `AbstractController::Callbacks::TERMINATOR`, a lambda in 8.1) is recognized again, so a before_action is a plain call followed by `performed?` instead of a lambda passed to the terminator: one block less per callback to compile, one allocation less per call.
|
data/README.md
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
# activesupport-minimizer
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
`
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Finds callback problems Rails only reports when the chain runs, and,
|
|
4
|
+
experimentally, runs `ActiveSupport::Callbacks` chains as generated methods.
|
|
5
|
+
Part of [rails-minify](../rails-minify), whose `bin/rails minify:check` runs
|
|
6
|
+
the checks in CI.
|
|
7
|
+
|
|
8
|
+
## Checks
|
|
9
|
+
|
|
10
|
+
`AsMinimizer::Check`, for any class using `define_callbacks` (controllers,
|
|
11
|
+
models, validations, Active Job):
|
|
12
|
+
|
|
13
|
+
* `callback_targets`: callbacks naming a method that doesn't exist. Rails
|
|
14
|
+
registers callbacks by name and finds out when the chain runs: for a
|
|
15
|
+
controller, a 500 on every action the filter covers.
|
|
16
|
+
* `long_chains(limit: 5)`: chains with more than `limit` of the app's own
|
|
17
|
+
callbacks (Rails' and gems' don't count; controllers per action).
|
|
18
|
+
Callbacks inherited from `exclude` (default `ApplicationController`) don't
|
|
19
|
+
count either; a base class over the limit is reported once, with the
|
|
20
|
+
classes that inherit it.
|
|
21
|
+
* `callback_loops`: model callbacks that call `save`, `update`, `touch`, ...
|
|
22
|
+
on the record they run for, which runs the chain again (found with Prism),
|
|
23
|
+
with the guard if there is one.
|
|
24
|
+
|
|
25
|
+
## Experimental: unrolled callbacks
|
|
26
|
+
|
|
27
|
+
Off unless set. Faster per call in benchmarks; in production it made pages no
|
|
28
|
+
faster and cost ~20 MB per worker, because each worker generates the methods
|
|
29
|
+
as chains first run (see [Numbers](#numbers)).
|
|
7
30
|
|
|
8
31
|
```ruby
|
|
9
32
|
# config/environments/production.rb
|
|
@@ -47,7 +70,7 @@ after a halt when the chain says so. Symbols, procs of any arity, objects
|
|
|
47
70
|
with `raise_on_missing_callback_actions` on they are checked at runtime
|
|
48
71
|
instead, as Rails does. A chain that changes gets a new method.
|
|
49
72
|
|
|
50
|
-
|
|
73
|
+
### Debugging
|
|
51
74
|
|
|
52
75
|
Backtraces name the chain and the line in it:
|
|
53
76
|
|
|
@@ -78,3 +101,9 @@ A controller action behind 9 callbacks: 12.6 µs of callback overhead → 4.0 µ
|
|
|
78
101
|
(6.4 → 2.3 µs with YJIT).
|
|
79
102
|
|
|
80
103
|
[Japan Voyage](https://japanvoyage.jp)'s test suite (4317 runs) gives the same results with it on.
|
|
104
|
+
|
|
105
|
+
In production there (Falcon, 6 workers, half of them unrolling, the same
|
|
106
|
+
traffic for an hour, October 2026): no faster, ~20 MB more per worker. That
|
|
107
|
+
was before the app was preloaded; generating the methods at boot, before the
|
|
108
|
+
fork, for the loaded classes would be the next thing to try, and then mostly
|
|
109
|
+
for memory.
|
data/lib/as_minimizer/version.rb
CHANGED