-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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 components blazing fast ⛽️ #44487
Conversation
…-improvement-on-inline-components
…n-inline-components [9.x] Makes Blade inline components 10x faster. ⛽️
Just tested this again against the issue we were having blade-ui-kit/blade-icons#190 Based on the repo in that issue we are seeing the following improvement when rendering 10,000 icons with this PR in place (M1 Mac Studio)
After this PR applied
👍 |
This PR is quite large. Please could we have a better understanding of what parts of this PR contribute to the speed increase? It looks like there are 3 main areas that are being targeted here to improve speed:
What parts of those contribute most to the speed increase? Are they all necessary, or could some of them be micro optimizations? |
Love this! I just tried this on a project which relies heavily on data tables where tables, tr, td and th are all anonymous components. The experience has been sluggish on render, so much so that we've had to aggressively paginate to have a tolerable experience. (1k-10k components). While I couldn't do the proper benchmarking at the moment, the difference is night and day and very noticeable. Blazing fast! |
Just an FYI, this breaks the "View" tab of Laravel Debugbar. |
BRAVO!!! @nunomaduro |
A beautiful change and colossal speed difference. Thank you very much for your contribution to the project! <3 @nunomaduro |
Technical Details
This pull request addresses the performance of blade view components, and it mainly performs:
Components are only resolved from the IOC container if necessary. This is done by checking if the component
$data
matches exactly theComponent::__construct()
method parameters names, and if not, we proxy for the container.The computation of the
Component::render
, when using inline components, is only computed once. So, assuming that the return iscomponents.button
, we only check ifcomponents.button
is a view once, and following calls will use this cached result.We provide a new method, called
Component::view
, that should be documented instead of having people using the simpleview
helper.Events on views, related to creators and composers, are only fired if there is actually creators or composers for the given view.
Checking if views are expired, only happens once for the given view, during the lifecycle of the Application instance.
How To Test This Pull Request
If you would like to test this pull request locally, simply run the command above.
After, run your test suite, navigate in your application, and see if things are working as normal.
Results
Anonymous components — up to 52% faster:
Class View components - up to 39% faster:
Class Inline components — up to 92% faster:
Dynamic components ( that renders anonymous components ) — up to 72% faster:
Dynamic components ( that renders inline class components ) — up to 83% faster: