Fix N+1 styling & evaluation bottleneck during ActionGroup rendering in tables.#19654
Closed
emrullahardc wants to merge 3 commits intofilamentphp:5.xfrom
Closed
Fix N+1 styling & evaluation bottleneck during ActionGroup rendering in tables.#19654emrullahardc wants to merge 3 commits intofilamentphp:5.xfrom
emrullahardc wants to merge 3 commits intofilamentphp:5.xfrom
Conversation
|
it's huge performance impact @emrullahardc |
Member
|
Unfortunately this is not a safe change to merge, actions could be hidden based on many different outside conditions like properties on a Livewire component or arguments passed to actions, and I think this would make the checks become stale. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes severe N+1 styling & evaluation bottleneck during ActionGroup rendering in tables.
Previously, when actions were placed inside an
ActionGroupin tables, the traitCanBeHiddenwould repetitively evaluate closures and perform Gate authorization checks up to 3-6 times per individual action for the exact same table row. This mathematically resulted in hundreds of excessive and completely redundant checks (e.g., 50 rows * 3 actions inside a dropdown generated approximately 870 Gate checks instead of the absolute theoretical minimum of 150 checks).This PR solves this bottleneck by implementing an Instance-Level Caching (Memoization) mechanism safely attached to the cloned component instance lifecycle.
isHidden/isHiddenInGroup) have been smartly cached via simple?boolcomputed properties.toHtmllifecycle. The cache naturally stays fresh per table-row because Filament handles context isolation via cloning action instances per row.flushHiddenCache(). Since records and visibility states can be mutated manually before evaluation (e.g.,->record(),->hidden(),->visible()), the state cache gracefully invalidates itself, cascading down dynamically to any inner actions inside anActionGroupto ensure no stale authorizations or evaluations are rendered ever.Because of this, rendering complex ActionGroups on bulk lists is now extremely lightweight and triggers the exact mathematical minimum of Gate checks.
Visual changes
Before applying the cache optimization (870+ duplicate Gate queries detected):

After the Instance-Level Rendering Optimization (reduced to ideal minimum):

Functional changes
composer cscommand.