Skip to content

perf(context): build template funcs by mode#2015

Merged
moshloop merged 1 commit into
mainfrom
perf/template-funcs-by-mode
Jun 24, 2026
Merged

perf(context): build template funcs by mode#2015
moshloop merged 1 commit into
mainfrom
perf/template-funcs-by-mode

Conversation

@adityathebe

Copy link
Copy Markdown
Member

RunTemplate built both CEL env functions and Go-template functions before dispatching to the active template mode.

That added avoidable allocation churn and made otherwise cacheable gomplate CEL evaluations look like they had custom functions attached.

Only attach CEL env options for CEL expressions and only attach Go-template functions for Go templates.

RunTemplate built both CEL env functions and Go-template functions before evaluating any template, even when only one template mode was in use. That work also made otherwise cacheable gomplate evaluations look like they had custom functions.

Only attach CEL env options for CEL expressions and only attach Go-template functions for Go templates. Add regression coverage for the mode-specific construction behavior.
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@adityathebe, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 57 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fe018f12-0cfd-48e1-8d7a-3038f199f78f

📥 Commits

Reviewing files that changed from the base of the PR and between fe0592b and 88329f8.

📒 Files selected for processing (2)
  • context/template.go
  • context/template_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/template-funcs-by-mode
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch perf/template-funcs-by-mode

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Benchstat (Other)

Base: fe0592b12ec8a287e14c7576c5cd27116c680eae
Head: 88329f8103fbab49fe033a1398d8467274791e18

✅ 2 improvement(s)
Benchmark Base Head Change p-value
ResourceSelectorQueryBuild/tags-4 17.57µ 17.18µ -2.23% 0.009
ResourceSelectorQueryBuild/name_and_type-4 64.19µ 63.14µ -1.64% 0.009
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 7763 64-Core Processor                
                                                       │ bench-base.txt │          bench-head.txt           │
                                                       │     sec/op     │   sec/op     vs base              │
InsertionForRowsWithAliases/external_users.aliases-4        617.9µ ± 8%   639.1µ ± 4%       ~ (p=0.093 n=6)
InsertionForRowsWithAliases/config_items.external_id-4      1.151m ± 8%   1.167m ± 8%       ~ (p=0.937 n=6)
InsertionOfConfigsWithProperties-4                          3.877m ± 4%   3.913m ± 3%       ~ (p=0.699 n=6)
UpdateOfConfigsWithProperties-4                             7.540m ± 2%   7.533m ± 2%       ~ (p=1.000 n=6)
ResourceSelectorConfigs/name-4                              221.5µ ± 3%   225.3µ ± 2%       ~ (p=0.132 n=6)
ResourceSelectorConfigs/name_and_type-4                     239.0µ ± 7%   242.3µ ± 3%       ~ (p=0.937 n=6)
ResourceSelectorConfigs/tags-4                              30.01m ± 4%   30.51m ± 1%       ~ (p=0.132 n=6)
ResourceSelectorQueryBuild/name-4                           44.17µ ± 2%   43.49µ ± 1%       ~ (p=0.093 n=6)
ResourceSelectorQueryBuild/name_and_type-4                  64.19µ ± 2%   63.14µ ± 1%  -1.64% (p=0.009 n=6)
ResourceSelectorQueryBuild/tags-4                           17.57µ ± 2%   17.18µ ± 1%  -2.23% (p=0.009 n=6)
geomean                                                     526.8µ        529.3µ       +0.48%

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Benchstat (RLS)

Base: fe0592b12ec8a287e14c7576c5cd27116c680eae
Head: 88329f8103fbab49fe033a1398d8467274791e18

📊 10 minor regression(s) (all within 5% threshold)

Benchmark Base Head Change p-value
RLS/Sample-15000/config_names/Without_RLS-4 13.75m 14.23m +3.49% 0.009
RLS/Sample-15000/config_summary/Without_RLS-4 99.73m 102.97m +3.25% 0.009
RLS/Sample-15000/analyzer_types/With_RLS-4 3.802m 3.924m +3.21% 0.002
RLS/Sample-15000/analysis_types/With_RLS-4 3.960m 4.065m +2.65% 0.002
RLS/Sample-15000/change_types/Without_RLS-4 5.358m 5.473m +2.14% 0.002
RLS/Sample-15000/config_classes/With_RLS-4 135.4m 137.8m +1.76% 0.002
RLS/Sample-15000/config_changes/With_RLS-4 143.1m 145.3m +1.53% 0.002
RLS/Sample-15000/configs/With_RLS-4 138.5m 140.5m +1.45% 0.002
RLS/Sample-15000/catalog_changes/With_RLS-4 141.6m 143.1m +1.09% 0.002
RLS/Sample-15000/config_names/With_RLS-4 139.7m 140.9m +0.84% 0.002
✅ 6 improvement(s)
Benchmark Base Head Change p-value
RLS/Sample-15000/config_classes/Without_RLS-4 4.526m 4.187m -7.48% 0.002
RLS/Sample-15000/catalog_changes/Without_RLS-4 5.591m 5.432m -2.84% 0.002
RLS/Sample-15000/analysis_types/Without_RLS-4 4.002m 3.957m -1.13% 0.041
RLS/Sample-15000/config_detail/With_RLS-4 139.2m 137.7m -1.08% 0.002
RLS/Sample-15000/config_types/With_RLS-4 137.6m 136.4m -0.83% 0.002
RLS/Sample-15000/config_summary/With_RLS-4 720.5m 715.6m -0.68% 0.015
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 7763 64-Core Processor                
                                               │ bench-base.txt │           bench-head.txt           │
                                               │     sec/op     │    sec/op     vs base              │
RLS/Sample-15000/catalog_changes/Without_RLS-4      5.591m ± 6%    5.432m ± 1%  -2.84% (p=0.002 n=6)
RLS/Sample-15000/catalog_changes/With_RLS-4         141.6m ± 1%    143.1m ± 0%  +1.09% (p=0.002 n=6)
RLS/Sample-15000/config_changes/Without_RLS-4       5.433m ± 2%    5.439m ± 6%       ~ (p=0.818 n=6)
RLS/Sample-15000/config_changes/With_RLS-4          143.1m ± 0%    145.3m ± 0%  +1.53% (p=0.002 n=6)
RLS/Sample-15000/config_detail/Without_RLS-4        4.866m ± 9%    4.869m ± 3%       ~ (p=1.000 n=6)
RLS/Sample-15000/config_detail/With_RLS-4           139.2m ± 1%    137.7m ± 1%  -1.08% (p=0.002 n=6)
RLS/Sample-15000/config_names/Without_RLS-4         13.75m ± 2%    14.23m ± 3%  +3.49% (p=0.009 n=6)
RLS/Sample-15000/config_names/With_RLS-4            139.7m ± 0%    140.9m ± 0%  +0.84% (p=0.002 n=6)
RLS/Sample-15000/config_summary/Without_RLS-4       99.73m ± 1%   102.97m ± 2%  +3.25% (p=0.009 n=6)
RLS/Sample-15000/config_summary/With_RLS-4          720.5m ± 2%    715.6m ± 1%  -0.68% (p=0.015 n=6)
RLS/Sample-15000/configs/Without_RLS-4              8.210m ± 4%    8.369m ± 3%       ~ (p=0.132 n=6)
RLS/Sample-15000/configs/With_RLS-4                 138.5m ± 0%    140.5m ± 2%  +1.45% (p=0.002 n=6)
RLS/Sample-15000/analysis_types/Without_RLS-4       4.002m ± 5%    3.957m ± 1%  -1.13% (p=0.041 n=6)
RLS/Sample-15000/analysis_types/With_RLS-4          3.960m ± 1%    4.065m ± 1%  +2.65% (p=0.002 n=6)
RLS/Sample-15000/analyzer_types/Without_RLS-4       3.869m ± 1%    3.828m ± 3%       ~ (p=0.240 n=6)
RLS/Sample-15000/analyzer_types/With_RLS-4          3.802m ± 1%    3.924m ± 1%  +3.21% (p=0.002 n=6)
RLS/Sample-15000/change_types/Without_RLS-4         5.358m ± 1%    5.473m ± 3%  +2.14% (p=0.002 n=6)
RLS/Sample-15000/change_types/With_RLS-4            5.400m ± 4%    5.531m ± 3%       ~ (p=0.394 n=6)
RLS/Sample-15000/config_classes/Without_RLS-4       4.526m ± 7%    4.187m ± 1%  -7.48% (p=0.002 n=6)
RLS/Sample-15000/config_classes/With_RLS-4          135.4m ± 0%    137.8m ± 1%  +1.76% (p=0.002 n=6)
RLS/Sample-15000/config_types/Without_RLS-4         4.967m ± 3%    4.917m ± 2%       ~ (p=0.310 n=6)
RLS/Sample-15000/config_types/With_RLS-4            137.6m ± 0%    136.4m ± 1%  -0.83% (p=0.002 n=6)
geomean                                             21.39m         21.48m       +0.42%

@github-actions

Copy link
Copy Markdown

Gavel results

Gavel exited with code .

View full results

@moshloop moshloop merged commit 3fc810d into main Jun 24, 2026
20 of 22 checks passed
@moshloop moshloop deleted the perf/template-funcs-by-mode branch June 24, 2026 07:15
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.

2 participants