Skip to content

Resolve the plugins path once per component in ComponentBase::getPath() - #1604

Open
austinderrick wants to merge 1 commit into
wintercms:developfrom
austinderrick:perf/component-plugins-path
Open

austinderrick wants to merge 1 commit into
wintercms:developfrom
austinderrick:perf/component-plugins-path

Conversation

@austinderrick

@austinderrick austinderrick commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

ComponentBase::getPath() calls plugins_path(), which resolves the plugins directory one segment at a time with an is_link() and an is_file() check on each segment. Rendering one component partial calls getPath() about four times through ComponentPartial::getFilePath(), so a page with a few components resolves the same directory hundreds of times per request. This change keeps the resolved path on the component instance, so each component resolves it once and nothing is kept between requests.

Per front-end page request Before After
PathResolver::resolve() calls 423 113
is_link() calls from resolve() 3,606 1,126
Time in resolve() 4.25 ms 1.45 ms
CPU per request 30.1 ms 27.0 ms

Measured on a page with 6 components and the plugins directory 8 levels deep, on PHP 8.3 with OPcache and JIT, through a Laravel Octane worker. Paired on and off blocks in one process gave -3.3 ms (an A/A control gave -0.02 and -0.22 ms), 8 fresh-process rounds gave -2.9 ms, and a back-end form page showed no change.

Summary by CodeRabbit

  • Improvements
    • Component path resolution now reuses the resolved plugin path for each component instance, reducing repeated path lookups. This is an internal efficiency improvement; no new user-facing functionality or behavior changes are included.

plugins_path() resolves the plugins directory segment by segment, checking
each segment for a symlink, and ComponentPartial calls getPath() several
times for every component partial it renders. Keep the resolved plugins path
on the component, so each component instance resolves it once.
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ComponentBase adds a protected property to store the plugins path. On the first call to getPath(), it resolves plugins_path() and stores the result. Later calls on the same component instance reuse the stored path when appending the component directory name.

Estimated code review effort: 2 (Simple) | ~5 minutes

Merge Risk: Minimal · up to a971c

The change reduces repeated path resolution per component and does not retain the path between requests. No actionable merge risk was found.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: caching the plugins path once per component in ComponentBase::getPath().
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 322c9808-f463-4bad-97ef-742c5f1342c5
Commits

Reviewing files that changed from the base of the PR and between f9bc204 and a971c32.

Files selected for processing: 1

  • modules/cms/classes/ComponentBase.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant