Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
# Base and head are measured from identical checkouts so that only their code and dependencies differ.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
path: tmp/head
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
persist-credentials: false
Expand All @@ -112,15 +117,33 @@ jobs:
with:
ruby-version: 4.0
bundler-cache: true
- name: Install base and head dependencies
shell: bash
run: |
for side in base head; do
gemfile="$GITHUB_WORKSPACE/tmp/$side/$BUNDLE_GEMFILE"
if [ ! -f "$gemfile" ]; then
echo "::warning::Base has no $BUNDLE_GEMFILE; measuring base with head dependencies"
gemfile="$GITHUB_WORKSPACE/tmp/head/$BUNDLE_GEMFILE"
fi
BUNDLE_GEMFILE="$gemfile" bundle config set --local path "$GITHUB_WORKSPACE/vendor/bundle"
BUNDLE_GEMFILE="$gemfile" bundle config set --local deployment true
BUNDLE_GEMFILE="$gemfile" bundle install --jobs 4
echo "$(echo "$side" | tr '[:lower:]' '[:upper:]')_BUNDLE_GEMFILE=$gemfile" >> "$GITHUB_ENV"
done
- name: Compare performance against base
shell: bash
env:
PASSES: 5
# Timings shift more between processes than between passes, so favor more processes.
ROUNDS: 6
PASSES: 3
BASE_REF: ${{ steps.release.outputs.tag || github.event.pull_request.base.sha }}
run: |
for round in 1 2 3; do
VIEW_COMPONENT_LIB=tmp/base/lib bundle exec ruby performance/measure.rb "tmp/performance/base/$round.json"
bundle exec ruby performance/measure.rb "tmp/performance/head/$round.json"
for round in $(seq "$ROUNDS"); do
BUNDLE_GEMFILE="$BASE_BUNDLE_GEMFILE" VIEW_COMPONENT_LIB=tmp/base/lib \
bundle exec ruby performance/measure.rb "tmp/performance/base/$round.json"
BUNDLE_GEMFILE="$HEAD_BUNDLE_GEMFILE" VIEW_COMPONENT_LIB=tmp/head/lib \
bundle exec ruby performance/measure.rb "tmp/performance/head/$round.json"
done
{
printf 'Base: `%s`; head: `%s` (pull request merge commit).\n\n' "$BASE_REF" "$GITHUB_SHA"
Expand Down
52 changes: 26 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ GEM
cruise (0.3.0-x86_64-linux-gnu)
cruise (0.3.0-x86_64-linux-musl)
csv (3.3.7)
cuprite (0.22)
cuprite (1.0)
capybara (~> 3.0)
ferrum (~> 0.22.0)
ferrum (~> 1.0)
date (3.6.0)
diff-lcs (1.6.2)
drb (2.2.3)
Expand All @@ -147,11 +147,11 @@ GEM
rubocop (>= 1)
smart_properties
erubi (1.13.1)
ferrum (0.22.0)
addressable (~> 2.5)
ferrum (1.0.0)
addressable (~> 2.10)
base64 (~> 0.2)
concurrent-ruby (~> 1.1)
websocket-driver (~> 0.7)
concurrent-ruby (~> 1.3, >= 1.3.7)
websocket-driver (~> 0.9, >= 0.9.1)
ffi (1.17.4-aarch64-linux-gnu)
ffi (1.17.4-aarch64-linux-musl)
ffi (1.17.4-arm-linux-gnu)
Expand All @@ -160,21 +160,21 @@ GEM
ffi (1.17.4-x86_64-darwin)
ffi (1.17.4-x86_64-linux-gnu)
ffi (1.17.4-x86_64-linux-musl)
globalid (1.4.0)
globalid (1.5.0)
activesupport (>= 6.1)
haml (7.5.2)
prism (>= 1.1.0)
temple (>= 0.8.2)
thor
tilt
herb (0.11.2-aarch64-linux-gnu)
herb (0.11.2-aarch64-linux-musl)
herb (0.11.2-arm-linux-gnu)
herb (0.11.2-arm-linux-musl)
herb (0.11.2-arm64-darwin)
herb (0.11.2-x86_64-darwin)
herb (0.11.2-x86_64-linux-gnu)
herb (0.11.2-x86_64-linux-musl)
herb (0.11.3-aarch64-linux-gnu)
herb (0.11.3-aarch64-linux-musl)
herb (0.11.3-arm-linux-gnu)
herb (0.11.3-arm-linux-musl)
herb (0.11.3-arm64-darwin)
herb (0.11.3-x86_64-darwin)
herb (0.11.3-x86_64-linux-gnu)
herb (0.11.3-x86_64-linux-musl)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
io-console (0.9.5)
Expand Down Expand Up @@ -537,15 +537,15 @@ CHECKSUMS
cruise (0.3.0-x86_64-linux-gnu) sha256=a7bdd7c72307a450a9d37f3c7a90c118230ea6122663b32b8c8e52cad32adfa8
cruise (0.3.0-x86_64-linux-musl) sha256=54ed6809f1d476bf99a3043bc256cca0efed8bbc9df93a55f4e49eac2bbcb7f4
csv (3.3.7) sha256=15a3f16f6628da8664d455eb634e7f22031bcf53044923caf56975109e71b9f8
cuprite (0.22) sha256=0be36125d65f5fe06a4355413e5518fe81400cf6e5cced26f131295584296509
cuprite (1.0) sha256=f885cd18364a120374766da4a5fa19b33aaddd520728c1b907e9c8d4f0e7224d
date (3.6.0) sha256=18ac945c4e24ebd93534f8eab8c2fd8c5604b3e977105b3798d62a1e8d27b580
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
dry-initializer (3.2.0) sha256=37d59798f912dc0a1efe14a4db4a9306989007b302dcd5f25d0a2a20c166c4e3
erb (6.0.7) sha256=c5ca6dc25b0ef974a44dc8f59fe847577122483b1968a38dec305c60bf91ee92
erb_lint (0.9.0) sha256=dfb5e40ad839e8d1f0d56ca85ec9a7ac4c9cd966ec281138282f35b323ca7c31
erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9
ferrum (0.22.0) sha256=d7fe234ba6cc677e2b94c012ae98918e9233666e93ab2979ca6f983e00d9b92d
ferrum (1.0.0) sha256=9bbb859c5ba5d95995e99de71f0744d355f23e1cd7ba81a380988891d5e9d707
ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df
ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39
ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564
Expand All @@ -554,16 +554,16 @@ CHECKSUMS
ffi (1.17.4-x86_64-darwin) sha256=aa70390523cf3235096cf64962b709b4cfbd5c082a2cb2ae714eb0fe2ccda496
ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
globalid (1.4.0) sha256=037f12fbf1d9d7a014d501c2d5c77356fd4ddd96d7a7991d6700bba96706f427
globalid (1.5.0) sha256=2b38ddb12f0765feba4a38b71032d8917ee341aaec0931f5d362eb5b192de4a3
haml (7.5.2) sha256=fcef494c3c5f173f5b38338b1ade7e65b1de37194919b901f047cac76f370d42
herb (0.11.2-aarch64-linux-gnu) sha256=b8015cba548ff79f04c69dd9ccf92a8dc8900fca8a0fc23b000f92fdf7219842
herb (0.11.2-aarch64-linux-musl) sha256=0b41e988a6c81cb05cacfb3a5444d729fb1c41970bfe594fbdc91319376ce8cc
herb (0.11.2-arm-linux-gnu) sha256=f7f7d1ecf69670a39911b7d159705e55d2f0f9f3e935cf27f29a02e4723a6445
herb (0.11.2-arm-linux-musl) sha256=677d0e8676f96448c4e0a82da6e772c90f6de43e48ef13987f57518472d69568
herb (0.11.2-arm64-darwin) sha256=7a5e23818c3f784690384fc111eae50d6993723eb0c172a8a72d0be167281d78
herb (0.11.2-x86_64-darwin) sha256=3c44bbfac81d95e5760fa6e20054c4ac6d2aeaca28dcee5df83dcd43adf84897
herb (0.11.2-x86_64-linux-gnu) sha256=2627fe909e7e6b0548926573d87a2e12b6d65bc85964832d34abf5ba165bfc37
herb (0.11.2-x86_64-linux-musl) sha256=aa6e7aa38d44de757d3076e331234f55ed2f392c2bd0203a3aa4ceea0b6bdd3e
herb (0.11.3-aarch64-linux-gnu) sha256=cf0ff5ea95df4709c4afe6f5f0c574c5943a7c3eff1b4eee745af77359d2d8b0
herb (0.11.3-aarch64-linux-musl) sha256=f0b2cdb5be9f444a55978ac5cf5769da18b6c3ff093c4d43e02d9b0286dc0ea7
herb (0.11.3-arm-linux-gnu) sha256=fcbd9c6d38d733d8f57f691c807358fa9bafe9d0d46bdac644ad5502f6ff408a
herb (0.11.3-arm-linux-musl) sha256=db0fe7ec45d88c2f3e865b1216ba248edce6a107c5d400252d14d73ddf1190e9
herb (0.11.3-arm64-darwin) sha256=2455cb33c85056aee29b72759ac272c63daa77f95c40d15c134b27cb462dfbb6
herb (0.11.3-x86_64-darwin) sha256=f67dc74663fd3247f8cbaaf8d9cd5693b740b785130b336e2f08428beb9f8264
herb (0.11.3-x86_64-linux-gnu) sha256=a1f5d4b26cb097ce1d6785c7dd24f4551c43cf3d5713d1aa1898f440b86d2799
herb (0.11.3-x86_64-linux-musl) sha256=af5634e0402d8e552bd5d0b332016852d34967d5d48aa9c432572608fe3070fe
i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5
io-console (0.9.5) sha256=83dd9bbf4c4680416629245b39cd4212eb5f4d9a4ea91804870c1f6b846414d5
irb (1.19.0) sha256=55ee56acbdd6c9fe06a2e6909f46a24e5c41f45f16906bab04e8049cf46f1d27
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 6

## main

* Benchmark pull requests against the base branch's dependencies and compare absolute component times to catch performance regressions from dependency updates, and run more benchmark processes to reduce noise.

*Joel Hawksley*

* Enable all Herb lint rules, template formatting, Tailwind class sorting, and editor support for development.

*Joel Hawksley*
Expand Down
7 changes: 4 additions & 3 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ bundle exec appraisal rails-8.0 rake

### Performance

CI compares each pull request against its base branch on Rails 8.1 and Rails main. For each rendering scenario in `performance/measure.rb`, it divides the component render time by the render time of an equivalent partial. It also measures cold component digests relative to cold partial digests, clearing Action View's digest caches and using a new lookup context for every call.
CI compares each pull request against its base branch on Rails 8.1 and Rails main, measuring the base with its own dependencies so dependency updates are compared too. The report lists any dependency changes. For each rendering scenario in `performance/measure.rb`, it divides the component render time by the render time of an equivalent partial. It also measures cold component digests relative to cold partial digests, clearing Action View's digest caches and using a new lookup context for every call.

The digest and boot scenarios use 300 generated ERB components and 300 generated Slim components. Each renders another component and includes a shared helper that references multiple components, exercising overlapping and cyclic dependencies. The boot scenario divides the time spent in ViewComponent (requiring it, loading components, compiling them, and precomputing digests) by the rest of boot. CI fails if any scenario's ratio is more than 5% higher than the baseline's ratio.
The digest and boot scenarios use 300 generated ERB components and 300 generated Slim components. Each renders another component and includes a shared helper that references multiple components, exercising overlapping and cyclic dependencies. The boot scenario divides the time spent in ViewComponent (requiring it, loading components, compiling them, and precomputing digests) by the rest of boot. CI fails if any scenario's ratio is more than 5% higher than the baseline's ratio. Ratios cancel out runner noise but miss changes, such as dependency updates, that slow components and partials alike, so CI also fails if any scenario's absolute component time, measured on the same runner, is more than 10% higher than the baseline's.

The executor scenario runs empty `app.executor.wrap` jobs on four threads in development with template caching disabled and the polling file watcher. It uses the generated components plus 600 model directories and compares against Rails without ViewComponent, catching template scans on executor-only paths such as Action Cable broadcasts.

Expand All @@ -122,7 +122,8 @@ To run the comparison locally:

```command
git worktree add tmp/base main
VIEW_COMPONENT_LIB=tmp/base/lib bundle exec ruby performance/measure.rb tmp/performance/base.json
BUNDLE_GEMFILE=tmp/base/Gemfile bundle install
BUNDLE_GEMFILE=tmp/base/Gemfile VIEW_COMPONENT_LIB=tmp/base/lib bundle exec ruby performance/measure.rb tmp/performance/base.json
bundle exec ruby performance/measure.rb tmp/performance/head.json
bundle exec ruby performance/compare.rb tmp/performance/base.json tmp/performance/head.json
```
Expand Down
18 changes: 9 additions & 9 deletions gemfiles/rails_7.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,21 @@ GEM
base64 (~> 0.2)
concurrent-ruby (~> 1.1)
websocket-driver (~> 0.7)
globalid (1.4.0)
globalid (1.5.0)
activesupport (>= 6.1)
haml (7.5.2)
prism (>= 1.1.0)
temple (>= 0.8.2)
thor
tilt
herb (0.11.2-aarch64-linux-gnu)
herb (0.11.2-aarch64-linux-musl)
herb (0.11.2-arm-linux-gnu)
herb (0.11.2-arm-linux-musl)
herb (0.11.2-arm64-darwin)
herb (0.11.2-x86_64-darwin)
herb (0.11.2-x86_64-linux-gnu)
herb (0.11.2-x86_64-linux-musl)
herb (0.11.3-aarch64-linux-gnu)
herb (0.11.3-aarch64-linux-musl)
herb (0.11.3-arm-linux-gnu)
herb (0.11.3-arm-linux-musl)
herb (0.11.3-arm64-darwin)
herb (0.11.3-x86_64-darwin)
herb (0.11.3-x86_64-linux-gnu)
herb (0.11.3-x86_64-linux-musl)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
io-console (0.9.5)
Expand Down
30 changes: 15 additions & 15 deletions gemfiles/rails_7.2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ GEM
cruise (0.3.0-x86_64-darwin)
cruise (0.3.0-x86_64-linux-gnu)
cruise (0.3.0-x86_64-linux-musl)
cuprite (0.22)
cuprite (1.0)
capybara (~> 3.0)
ferrum (~> 0.22.0)
ferrum (~> 1.0)
date (3.6.0)
diff-lcs (1.6.2)
drb (2.2.3)
Expand All @@ -141,26 +141,26 @@ GEM
rubocop (>= 1)
smart_properties
erubi (1.13.1)
ferrum (0.22.0)
addressable (~> 2.5)
ferrum (1.0.0)
addressable (~> 2.10)
base64 (~> 0.2)
concurrent-ruby (~> 1.1)
websocket-driver (~> 0.7)
globalid (1.4.0)
concurrent-ruby (~> 1.3, >= 1.3.7)
websocket-driver (~> 0.9, >= 0.9.1)
globalid (1.5.0)
activesupport (>= 6.1)
haml (7.5.2)
prism (>= 1.1.0)
temple (>= 0.8.2)
thor
tilt
herb (0.11.2-aarch64-linux-gnu)
herb (0.11.2-aarch64-linux-musl)
herb (0.11.2-arm-linux-gnu)
herb (0.11.2-arm-linux-musl)
herb (0.11.2-arm64-darwin)
herb (0.11.2-x86_64-darwin)
herb (0.11.2-x86_64-linux-gnu)
herb (0.11.2-x86_64-linux-musl)
herb (0.11.3-aarch64-linux-gnu)
herb (0.11.3-aarch64-linux-musl)
herb (0.11.3-arm-linux-gnu)
herb (0.11.3-arm-linux-musl)
herb (0.11.3-arm64-darwin)
herb (0.11.3-x86_64-darwin)
herb (0.11.3-x86_64-linux-gnu)
herb (0.11.3-x86_64-linux-musl)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
io-console (0.9.5)
Expand Down
30 changes: 15 additions & 15 deletions gemfiles/rails_8.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ GEM
cruise (0.3.0-x86_64-darwin)
cruise (0.3.0-x86_64-linux-gnu)
cruise (0.3.0-x86_64-linux-musl)
cuprite (0.22)
cuprite (1.0)
capybara (~> 3.0)
ferrum (~> 0.22.0)
ferrum (~> 1.0)
date (3.6.0)
diff-lcs (1.6.2)
drb (2.2.3)
Expand All @@ -138,26 +138,26 @@ GEM
rubocop (>= 1)
smart_properties
erubi (1.13.1)
ferrum (0.22.0)
addressable (~> 2.5)
ferrum (1.0.0)
addressable (~> 2.10)
base64 (~> 0.2)
concurrent-ruby (~> 1.1)
websocket-driver (~> 0.7)
globalid (1.4.0)
concurrent-ruby (~> 1.3, >= 1.3.7)
websocket-driver (~> 0.9, >= 0.9.1)
globalid (1.5.0)
activesupport (>= 6.1)
haml (7.5.2)
prism (>= 1.1.0)
temple (>= 0.8.2)
thor
tilt
herb (0.11.2-aarch64-linux-gnu)
herb (0.11.2-aarch64-linux-musl)
herb (0.11.2-arm-linux-gnu)
herb (0.11.2-arm-linux-musl)
herb (0.11.2-arm64-darwin)
herb (0.11.2-x86_64-darwin)
herb (0.11.2-x86_64-linux-gnu)
herb (0.11.2-x86_64-linux-musl)
herb (0.11.3-aarch64-linux-gnu)
herb (0.11.3-aarch64-linux-musl)
herb (0.11.3-arm-linux-gnu)
herb (0.11.3-arm-linux-musl)
herb (0.11.3-arm64-darwin)
herb (0.11.3-x86_64-darwin)
herb (0.11.3-x86_64-linux-gnu)
herb (0.11.3-x86_64-linux-musl)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
io-console (0.9.5)
Expand Down
30 changes: 15 additions & 15 deletions gemfiles/rails_8.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ GEM
cruise (0.3.0-x86_64-linux-gnu)
cruise (0.3.0-x86_64-linux-musl)
csv (3.3.7)
cuprite (0.22)
cuprite (1.0)
capybara (~> 3.0)
ferrum (~> 0.22.0)
ferrum (~> 1.0)
date (3.6.0)
diff-lcs (1.6.2)
drb (2.2.3)
Expand All @@ -147,11 +147,11 @@ GEM
rubocop (>= 1)
smart_properties
erubi (1.13.1)
ferrum (0.22.0)
addressable (~> 2.5)
ferrum (1.0.0)
addressable (~> 2.10)
base64 (~> 0.2)
concurrent-ruby (~> 1.1)
websocket-driver (~> 0.7)
concurrent-ruby (~> 1.3, >= 1.3.7)
websocket-driver (~> 0.9, >= 0.9.1)
ffi (1.17.4-aarch64-linux-gnu)
ffi (1.17.4-aarch64-linux-musl)
ffi (1.17.4-arm-linux-gnu)
Expand All @@ -160,21 +160,21 @@ GEM
ffi (1.17.4-x86_64-darwin)
ffi (1.17.4-x86_64-linux-gnu)
ffi (1.17.4-x86_64-linux-musl)
globalid (1.4.0)
globalid (1.5.0)
activesupport (>= 6.1)
haml (7.5.2)
prism (>= 1.1.0)
temple (>= 0.8.2)
thor
tilt
herb (0.11.2-aarch64-linux-gnu)
herb (0.11.2-aarch64-linux-musl)
herb (0.11.2-arm-linux-gnu)
herb (0.11.2-arm-linux-musl)
herb (0.11.2-arm64-darwin)
herb (0.11.2-x86_64-darwin)
herb (0.11.2-x86_64-linux-gnu)
herb (0.11.2-x86_64-linux-musl)
herb (0.11.3-aarch64-linux-gnu)
herb (0.11.3-aarch64-linux-musl)
herb (0.11.3-arm-linux-gnu)
herb (0.11.3-arm-linux-musl)
herb (0.11.3-arm64-darwin)
herb (0.11.3-x86_64-darwin)
herb (0.11.3-x86_64-linux-gnu)
herb (0.11.3-x86_64-linux-musl)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
io-console (0.9.5)
Expand Down
Loading
Loading