Skip to content

Improve compile speed#116

Merged
ganyicz merged 18 commits intomainfrom
filip/improve-compile-time
Mar 10, 2026
Merged

Improve compile speed#116
ganyicz merged 18 commits intomainfrom
filip/improve-compile-time

Conversation

@ganyicz
Copy link
Collaborator

@ganyicz ganyicz commented Mar 5, 2026

The scenario

Running php artisan view:cache takes significantly longer (~4s with Blade vs 1 minute and 20 seconds with Blaze)

The problem

Blaze's compilation path wasn't optimized to the same degree as its rendering path.

The solution

  1. Render foldable components with Blaze instead of Blade — bypassing Blade's full rendering pipeline during compilation.
  2. Cache ComponentSource instances — avoiding redundant disk reads and directive parsing for the same component.
  3. Register PhpParser\Parser as a singleton — instead of constructing a new one on every parse call.
  4. Improve view:cache in Laravellaravel/framework#59145.

These changes brought compilation time on the same demo app from 1m20s down to ~4s.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Benchmark Results

Attempt Blade Blaze Improvement
#1 * 247.59ms 15.04ms 93.9%
#2 246.02ms 15.02ms 93.9%
#3 246.06ms 15.08ms 93.9%
#4 245.84ms 15.12ms 93.8%
#5 245.80ms 15.04ms 93.9%
#6 245.16ms 15.21ms 93.8%
#7 245.27ms 15.05ms 93.9%
#8 245.48ms 15.12ms 93.8%
#9 * 247.73ms 14.96ms 94%
#10 246.05ms 15.07ms 93.9%
Snapshot 246.66ms 15.08ms 93.9%
Result 245.82ms (~) 15.08ms (~) 93.9% (~)

Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 33.27s total

@ganyicz ganyicz marked this pull request as ready for review March 6, 2026 21:39
@ganyicz ganyicz merged commit 018139c into main Mar 10, 2026
4 checks passed
@ganyicz ganyicz deleted the filip/improve-compile-time branch March 10, 2026 17:20
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