Repository navigation
Add a blog benchmark that writes - #575
Open
thomasklemm wants to merge 1 commit into
Open
thomasklemm wants to merge 1 commit into
thomasklemm wants to merge 1 commit into
Conversation
thomasklemm
force-pushed
the
thomasklemm/blog-benchmark
branch
2 times, most recently
from
November 18, 2026 00:29
d761531 to
24a4eda
Compare
thomasklemm
marked this pull request as ready for review
November 18, 2026 00:29
The Rails benchmarks here mostly read. In their timed iterations none of them submits a form, fails a validation, or runs after-commit callbacks and broadcasts; lobsters' only writes are its read-ribbon bookkeeping. Real apps spend much of their time saving records: validations, callbacks, transactions, INSERT/UPDATE/DELETE and enqueuing jobs. The app is the one the create-blog script from Sam Ruby's Roundhouse (roundhouse-rb/roundhouse, MIT or Apache-2.0, used here under MIT) builds: rails new --css tailwind on Rails 8.1.4.1, with Article and Comment scaffolds, validations and Turbo broadcasts. It keeps the production defaults of rails new: SQLite, Solid Cache, Solid Queue, Solid Cable, Propshaft and importmap, no external services. The built Tailwind CSS is checked in, so no CSS build runs. benchmarks/blog/README.md lists the changes to the generated tree. Generated files that only deployment, development, tests or a web server use are left out: .kamal/, config/deploy.yml, bin/ except rails and rake, public/, test/, the development and test environments, the Puma, recurring-task, CI, bundler-audit and RuboCop config, Procfile.dev, db/migrate (db/schema.rb creates the tables), the PWA views, the mailer and its layouts, ApplicationJob, the empty helpers and the .keep files in lib/, script/, vendor/, log/, tmp/, app/assets/images/ and the concerns/ directories. Every response is the same without them. The Gemfile keeps its default group without kamal, thruster, puma, bootsnap and tailwindcss-rails, since the app runs in-process and the CSS is already built; setup installs 43 fewer gems. Each iteration runs 200 seeded visits in-process, like railsbench: reads (index, show, JSON) and writes (create, update and delete articles, add and delete comments, a create that fails validation with 422). Writes submit the CSRF token from the page's form, as a browser does, and every response's status is checked, along with a body marker or the redirect target. The iteration runs in one transaction per database that is rolled back at the end, as in Rails tests, so every iteration sees the same rows and IDs. Rails 8.1 opens that transaction in pin_connection!; since rails/rails 9e8fe3955b it no longer does, so benchmark.rb opens it itself when none is open, and works on both. Time.now starts at a fixed date and advances one second per visit, so the work doesn't depend on the date and updates still write updated_at. Saves run as savepoints inside that transaction, and their after-commit callbacks run when the savepoint is released, as in Rails tests. Solid Cable inserts each broadcast in the request rather than on its batching writer thread, so it lands in the transaction; the later broadcasts are enqueued into Solid Queue. Since nothing commits, a real COMMIT is not measured.
thomasklemm
force-pushed
the
thomasklemm/blog-benchmark
branch
from
November 18, 2026 11:59
24a4eda to
eb8364d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Rails benchmarks here mostly read: in their timed iterations none of them submits a form, fails a validation, or runs after-commit callbacks.
This adds
blog, the app built by thecreate-blogscript from Sam Ruby's Roundhouse (MIT or Apache-2.0): arails new --css tailwindapp on Rails 8.1.4.1 with Article and Comment scaffolds, validations and Turbo broadcasts, on the default SQLite, Solid Cache, Queue and Cable. Each iteration makes about 420 in-process requests (reads, creates, updates, deletes, comments and a create that fails with 422) with real CSRF tokens, checks every response, and rolls back one transaction per database at the end, as Rails tests do. It works on Rails 8.1 and main.It runs code the others don't: a small busy loop in
saveanddestroyadds 2.3% to blog's instructions and never runs in railsbench's or lobsters' timed iterations. From Rails 8.1.4.1 to main, its reads take about a tenth fewer instructions while creates and updates don't get faster.An iteration takes about 2 s in the interpreter and about 1 s with YJIT or ZJIT. The README lists every change to the generated app and what the rollback leaves out.
Would a write workload like this be welcome? Happy to reshape it.