Repository navigation
fix: cut createRenderer() from ~400 µs to ~60 ns when cache is set via configure() - #176
Open
RomainLanz wants to merge 1 commit into
Open
RomainLanz wants to merge 1 commit into
RomainLanz wants to merge 1 commit into
Conversation
The superCharged plugin read its "recurring" flag from the options
given to the constructor. configure() did not update it. AdonisJS calls
Edge.create() and then edge.configure({ cache: app.inProduction }), so
in production the plugin stayed recurring. Each createRenderer() then
did an existsSync and a recursive readdirSync of the components
directory of every mounted disk. AdonisJS creates one renderer per
request.
configure() now stores the cache flag, and #executePlugins reads it to
decide if the bundled plugins run again. With cache disabled, the
components list still refreshes on each render.
createRenderer() after create() + configure({ cache: true }) with 100
components goes from about 400 µs to about 58 ns.
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.
Hi ! 👋
AdonisJS calls
Edge.create()and thenedge.configure({ cache: app.inProduction }). The superCharged plugin took itsrecurringflag from the constructor options only, soconfigure()did not change it. In production, eachcreateRenderer()call then ranexistsSyncand a recursivereaddirSyncon thecomponentsdirectory of each mounted disk. AdonisJS creates one renderer per request (thectx.viewgetter, which session, shield and auth touch on every request, JSON responses included).Now
configure()stores the cache flag, and#executePluginsreads it to decide if the bundled plugins run again. With cache disabled, the components list still refreshes on each render.createRenderer()withcreate()+configure({ cache: true }), median of 3 runs, Node 26.10, no profiler attached:create({ cache: true })In an AdonisJS Inertia React app with 26 components, CPU time per request went from about 1,140 µs to about 780 µs.
Tests:
do not refresh list when cache mode is enabled via configurerenders a template that is not compiled yet, so the template cache cannot hide a refresh. The existingcache: truetest renders the same template twice, so it passes with or without this fix.refresh list when cache mode is disabled via configurecoverscreate({ cache: true })followed byconfigure({ cache: false }).Not covered: user plugins registered with
use()keep their ownrecurringoption. This PR does not change them.