Skip to content

improve compile perf#6804

Open
benedikt-bartscher wants to merge 1 commit into
reflex-dev:mainfrom
benedikt-bartscher:improve-compile-perf
Open

improve compile perf#6804
benedikt-bartscher wants to merge 1 commit into
reflex-dev:mainfrom
benedikt-bartscher:improve-compile-perf

Conversation

@benedikt-bartscher

Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reduces the CPU cost of deterministic component hashing. The main changes are:

  • Adds exact-type fast paths for common rendered values.
  • Buffers each encoded value before updating the hasher.
  • Caches encoded dataclass field metadata by class.

Confidence Score: 5/5

This looks safe to merge, with a possible peak-memory cost for very large component trees.

  • No blocking correctness issues were found in the changed encoding paths.
  • Whole-value buffering can increase transient compile memory for large inputs.

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/components/component.py Optimizes deterministic hashing with exact-type dispatch, bytearray buffering, and cached dataclass field metadata.

Reviews (1): Last reviewed commit: "improve compile perf" | Re-trigger Greptile

Comment thread packages/reflex-base/src/reflex_base/components/component.py
@codspeed-hq

codspeed-hq Bot commented Jul 21, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.75%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 23 untouched benchmarks
⏩ 8 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
test_compile_all_artifacts[_stateful_page] 26.6 ms 25.5 ms +4.21%
test_compile_page[_stateful_page] 30.2 ms 29 ms +3.83%
test_compile_page_full_context[_stateful_page] 34.6 ms 33.5 ms +3.22%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing benedikt-bartscher:improve-compile-perf (480d8ae) with main (f79d011)2

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (e54bc83) during the generation of this report, so f79d011 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review July 21, 2026 11:09
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner July 21, 2026 11:09
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