Repository navigation
Faster builds: URLs without Antlers for simple routes, and a lazy dirty-state snapshot - #3
Merged
Merged
Conversation
…y state lazily Statamic builds every entry's URL by running its route through Antlers with a new parser each time. For routes that are only placeholders, FastUrlBuilder puts the values in itself and lets Statamic's builder do the rest (slugify, tidy) with a parser that has nothing to do. Anything else is left to Statamic. FlatpackEntry no longer works out its dirty-state snapshot on every read. It keeps a copy of the entry as read and derives the snapshot when getOriginal(), isDirty() or serialisation asks. The parity fixtures gain two collections whose routes can't take the fast path.
# Conflicts: # CHANGELOG.md # src/ServiceProvider.php
A placeholder named merge, pluck, where, take, skip, orderby, groupby or arr is read by Antlers as part of its language even when the entry has a value of that name, so those go to Statamic's builder too.
…he parity suite, fix the 5.11 install The lazy dirty-state snapshot is taken from a copy of the entry, but Statamic remembers origins by entry id, so the copy saw the entry's current origin. The copy is now shown the origin it was read with while the snapshot is worked out. Older Statamic versions don't give a clone its own data, so the copy gets one. The parity suite compares what entries report as their original values and dirty state after being changed in memory (origin changed or removed, data, slug, date moved in place, serialised, cloned). bin/parity now lets Composer update every package when installing a Statamic version: the skeleton pins laravel/pail to a release that needs Laravel 12, which Statamic 5.11 can't use.
…he changelog entries out of 1.1.1
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.
Profiling
flatpack:buildon the demo's largest set (9,000 entries, nested page builder) showed that YAML parsing is now about 1% of the build. The time goes on building entry URLs and on reading entries back from the store. This PR takes two pieces of that.Results
Demo, nested page builder, 9,000 entries. Released 1.1.0 and this branch built alternately, median of 5 (Apple M1 Pro, PHP 8.5, Statamic 6.40; the machine was busy, so read the difference rather than the absolute times):
flatpack:buildURLs for simple routes
Statamic builds each entry's URL by converting its route to Antlers and parsing it, and
Antlers::parse()makes a new parser from the container every time (with about 14 config reads). On this build that was 19,560 parsers.FastUrlBuilder(bound forStatamic\Contracts\Routing\UrlBuilder) handles routes that are only placeholders, such as/books/{slug}or{parent_uri}/{slug}. It puts the values in and hands the result to Statamic's ownbuild()for the rest (slugifying and tidying, which differ between Statamic 5 and 6), usingAntlers::usingParser()with a parser that returns its text unchanged.Statamic's builder is used untouched when:
{{ ... }});Valueobjects);Dirty-state snapshot only when asked
Statamic calls
syncOriginal()on every entry read from the Stache, which builds an array of the entry's slug, date, path, origin and all its data. During a build each entry is read about seven times.FlatpackEntry::syncOriginal()now keeps a clone of the entry as it was read (with its own copy of the data, supplements and date) and works the snapshot out from that clone whengetOriginal(),isDirty()or__sleep()is called. This applies to normal requests too, not just builds.Checks
bin/paritypasses locally on Statamic 6 (latest) and Statamic 5 (latest). 5.11.0 wouldn't install on this machine, so that one is left to CI.Not in this PR
Str::slugreading config on each call), which would be changes to Statamic itself.