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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bb3bd538359f52f42e0b8e2f591c3ea3b4b3cabf2740ce4ce5d51fbd810817c
4
- data.tar.gz: 598f2c2e3897cef1e12d3bcdcd02d95a760ac695c202084c08a83dae1346a4b1
3
+ metadata.gz: 31636aeda8a4735600af514ddc5baf5e8fab14e491f893b402f3bf073c89b105
4
+ data.tar.gz: 2281325cd2c192462987066dcef9bb331cd560b2f18e764fdf1a2b9fb586094f
5
5
  SHA512:
6
- metadata.gz: f183c2881281f4687a85312464e95e954383507e4d7bc1d3fe2cd4263b99c977a827b3e16b9b7059621ffede37536f357e84858d2c7a5aeb1467b2710c5b41d4
7
- data.tar.gz: a0b386f48da881a5df8a74afdcaa7491afb12f0e16cffbb5ee143d10193ab0e64a033f6d9fe6f12cc4d864a5da71a054c77bd4607384382792c0f6d262885991
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
- Runs `ActiveSupport::Callbacks` chains as generated methods: controller
4
- `before_action`/`around_action`/`after_action`, model `before_save`,
5
- `after_commit`, validations, `after_initialize`, Active Job callbacks — any
6
- class using `define_callbacks`. Part of [rails-minify](../rails-minify).
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
- ## Debugging
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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AsMinimizer
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport-minimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampo Kuokkanen