perf(dev-env): tune local database performance defaults#2874
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Disable binary logging (MySQL), raise the buffer pool to 1G (matching the VIP production default), raise redo log capacity, and relax per-commit flushing. These are server-wide settings that benefit all local database use; the largest gains are on bulk SQL imports. Bump DEV_ENVIRONMENT_VERSION so existing environments pick up the new flags on next start. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fdf9ff7 to
14cf32f
Compare
| command: docker-entrypoint.sh mysqld --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION --max_allowed_packet=67M --mysql-native-password=ON | ||
| command: docker-entrypoint.sh mysqld --sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION --max_allowed_packet=67M --mysql-native-password=ON --skip-log-bin --innodb-buffer-pool-size=1G --innodb-redo-log-capacity=1G --innodb-flush-log-at-trx-commit=2 |
There was a problem hiding this comment.
Is this change friendly to existing environments? That is, if I create a dev env with an old VIP CLI, then run this VIP CLI and restart the environment, will it start?
There was a problem hiding this comment.
Good question. Something I did not test, and I'll run some tests and validate
There was a problem hiding this comment.
Alright. This validated fine and found no issues with existing environments.
I created a new environment on trunk (old 2.3.3 dev-env defaults), created an example post, switched to this branch and restarted the environment. It auto-updated to 2.3.4 and rebuilt, the site loaded fine with no database connection errors, the post survived, and the new flags were verified live in the container.
I also added an e2e test (014-database-defaults.spec.js).
Asserts the running database is not on stock defaults (floors, not pinned values, so future tuning does not break the test) and that an environment stamped with the previous version auto-updates on start, applies the new flags over its existing data directory, and keeps data. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|



Problem
The dev-env database containers run with stock settings that are hostile to bulk imports:
SET SESSION SQL_LOG_BIN = 0opt-out fails (thewordpressuser lacksSYSTEM_VARIABLES_ADMIN), so this always happens.Redo log writer is waiting for a new redo log file/log_checkpointer still lagging behindwarnings.innodb_flush_log_at_trx_commit=1): durability guarantees that are meaningless for a disposable local database, paid for on every one of myloader's transactions.Fix
assets/dev-env.lando.template.yml.ejs, both database branches. Note these are server-widemysqldstartup flags — they benefit all local database use (the buffer pool in particularhelps everyday WordPress queries on large sites), with the most dramatic gains on bulk imports:
--skip-log-bin--innodb-buffer-pool-size=1G--innodb-redo-log-capacity=1G--innodb-log-file-size=1G--innodb-flush-log-at-trx-commit=2DEV_ENVIRONMENT_VERSIONis bumped2.3.3→2.3.4(src/lib/constants/dev-environment.ts) so existing environments re-render the template and rebuild automatically on their nextvip dev-env start— no manualdev-env updateneeded.Testing
.lando.ymland live values after the auto-update path (maybeUpdateVersion()→updateEnvironment()→ lando rebuild):log_bin=0, pool 1G, redo 1G,flush=2__tests__/devenv-e2e/014-database-defaults.spec.jscovers both scenarios permanently: (1) a fresh environment runs with non-stock database defaults, and (2) an environment stamped with the previous version auto-updates onstart, applies the new defaults to its existing data directory, and keeps its data. Assertions use floors (e.g. pool > stock 128M) rather than pinned values, so future tuning of the sizes does not break the test — only losing an override doesTrade-off note
innodb_flush_log_at_trx_commit=2means up to ~1s of writes can be lost if the host crashes (not just mysqld). For a local dev database that is recreated from imports, this is the intended trade.Changelog Description
Changed
Related
-ofix), fix(dev-env): recompute mydumper section sizes after search-replace #2872 (search-replace size fix), fix(validations): avoid ENGINE != InnoDB false positives on row data #2873 (ENGINE validation)🤖 Generated with Claude Code