perf(front): drop Carbon and Doctrine Inflector from uncached page renders - #2483
Merged
Merged
Conversation
A fresh install left the Minimal Template on the legacy "automatic" source, the only template in the system showing that option, while every template created in the manager starts as "database". Seed it as "db" so it skips the view-file probes like any other database template. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The base soft-delete trait casts deletedon to datetime, so toArray() built a Carbon instance only to print it as an ISO string. Every uncached page loaded Carbon (about 40 files) for it, and [*deletedon*] rendered as 1970-01-01T00:00:00.000000Z instead of a timestamp like every other date field. Array form now keeps the stored value; reading the attribute still returns Carbon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Models without $table made Eloquent pluralise the class name on the first query of a request, which loads Doctrine Inflector (about 20 files) on every uncached front-end page. Each name is the one Eloquent derived before, so no query changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
A cache-miss render of a page on a fresh install loaded Carbon and Doctrine Inflector although the page needs
neither. This PR removes both from the front-end path and seeds the default template the way the manager creates
new ones.
upd(install)– the seeded Minimal Template now usestemplatesource = 'db'. It was the only template ina fresh system on the legacy "Automatic (a matching file wins)" source; templates created in the manager already
default to
db. This is for consistency: the skipped view-file probes do not change render time measurably.fix(models)–SiteContent::toArray()no longer builds a Carbon instance fordeletedon. The basesoft-delete trait casts that column to
datetime, so every uncached page loaded Carbon (~40 files) and[*deletedon*]rendered as1970-01-01T00:00:00.000000Zinstead of a Unix timestamp like every other date field.The array form now keeps the stored value; reading
$doc->deletedonstill returns Carbon.ref(models)– all 29 core models without$tablenow declare it. Without it, Eloquent pluralises the classname on the first query, which loads Doctrine Inflector (~20 files). Each name is exactly the one Eloquent derived
before, so no query changes.
Measurements
Fresh SQLite install, PHP 8.3 with OPcache, Apache, guest request to the home page with the page cache off (200
requests per run):
About 0.55 ms (~9%) per cache miss in the two quiet rounds; later rounds were too noisy to compare. Cached hits (~3
ms, 0 queries) are unaffected.
Behaviour change
toArray()/toJson()of a document now givesdeletedonas an integer (0when never deleted) instead of anISO string, matching
createdon,editedonand the other date fields.A subclass of a core model that does not set its own
$tablenow inherits the parent's table instead of onederived from the subclass name. Nothing shipped does this.
Tests
DefaultSiteTemplateSeederTest– both install seeders seedtemplatesource = 'db'; the CI smoke check assertsthe same on a real install.
SiteContentDeletedOnArrayTest– integerdeletedonin arrays, column order and other casts kept, attributeaccess still Carbon, an in-memory deletion time is arrayed as a timestamp, and (in a separate process) arraying a
document does not load Carbon.
ModelTableNamesTest– every core model declares its table, and the 29 new declarations equal Eloquent's derivednames.
Unit suite: 1097 passed, 2 skipped. PHPStan: 0 errors, as before.