Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Makes Blade inline components 10x faster. ⛽️ #44480

Conversation

nunomaduro
Copy link
Member

@nunomaduro nunomaduro commented Oct 5, 2022

This pull request is a work in progress, and it makes rendering Blade inline components nearly 10x faster. So, assuming the following environment:

class Button extends Component
{
    function __construct(public $number) {}

    function render() { return <<<'blade'
        <div class="alert alert-danger">
            {{ $number }}
        </div>
    blade; }
}

// and welcome.blade.php
@for ($i = 0; $i < $numberOfComponents; $i++)
    <x-button :number="$i" />
@endfor

// before:
- 1 component: 3.332ms
- 10 components: 5.010ms
- 100 components: 47.670ms
- 1000 components: 482.629ms // 0.5 seconds ...
- 10000 components: 5,046.893ms // 5 seconds ...

// after:
- 1 component: 3.296ms
- 10 components: 0.875ms
- 100 components: 7.285ms
- 1000 components: 65.646ms // 0,06 seconds
- 10000 components: 642.549ms // 0,6 seconds

Important note: this pull request assumes static content being returned from the Component::render. If we think this may not be the case for some users. We will need to adjust this pull request.

@JayBizzle
Copy link
Contributor

JayBizzle commented Oct 5, 2022

Just tested this against an issue we were having with blade-ui-kit/blade-icons#190

Based on the repo in that issue we are seeing the following improvement when rendering 1000 icons with this PR in place.

Not seeing 10x faster in that instance, but a welcome boost none-the-less

Before - 280.601ms
After - 173.016ms

👍

@nunomaduro
Copy link
Member Author

@JayBizzle Can you try again with the latest version of this pull request?

@nunomaduro nunomaduro changed the title [9.x] Improves performance of inline components [9.x] Makes Blade inline components 10x faster. ⛽️ Oct 5, 2022
@JayBizzle
Copy link
Contributor

No difference really with the latest change, if anything, about 10ms slower

@nunomaduro nunomaduro changed the base branch from 9.x to feat/view-components-performance October 6, 2022 10:49
@nunomaduro nunomaduro marked this pull request as ready for review October 6, 2022 10:52
@nunomaduro nunomaduro merged commit fbd6811 into feat/view-components-performance Oct 6, 2022
@nunomaduro nunomaduro deleted the feat/performance-improvement-on-inline-components branch October 6, 2022 10:53
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