Man... Filament is so damn slow :(
I've 'done all the debugging I can - queries are fast, and minimal. The time being spent is on the "app" side of things, as reported by Debugbar - meaning it's in PHP.
Rest of my site is super fast. I've also cached icons, views, everything - Filament is still taking up to 6s on some pages. π
23 Replies
Try to disable debugbar
Having it enabled/disabled makes zero difference.
Are you developing on Windows? Or are you taking about the page on your production server? π€
Is OPCache active?
Both production and local have the same problem.
It is not.
Thatβs the most important for PHP performance
Octane is not so bad also π
But even if you arent using opcache, it shouldn't take 6s, right?
Can you do some profiling to see what's causing this delay? (Or do some caveman debugging, by commenting parts out / returning early, doing the call a few times, and check the time it takes) ...
If you have really big components with a lot of selects that load data, it can significantly slow things down, but without more information it's a bit hard to help here IMO.
Some general tips and tricks I can give:
- Is this on every request? Or just with working with some components?
If it's on some components, I have some tips that I use myself (These are generally for Livewire, so these work for Filament as well.):
- Work with private properties in Livewire components as much as possible, when they are public they have to get diffed / synced / ... every time
- I also have a lot of success with caching filament Forms in my components, like so:
I do that because these are big forms with a lot of relations / .... and these get used in the createAction, editAction, ... so normally these are initialised multiple times, meaning duplicate queries meaning longer load times ...
- Other than that, I also split Livewire components if they get too large.
Do you have custom middleware?
I've debugged all the queries, there's no + 1 problem or anything like that, the time is being spent in PHP. It's on every page practically. When you say profiling, @Auth1Specialist what specifically are you referring to? Something like xdebug?
Regarding the cache, what's that for? Ps. You could use Arr::set($this->componentCache, 'key', 'value') to avoid the conditional use there π
I do not.
What are your dev/production environments like? Have you tried running the filament-demo project?
For example, I'm using Laravel Sail on an M3 Pro Macbook and most pages are 2-300ms, depending on query complexity.
Any external services/APIs being called?
The latter question - not that I'm aware of. I'll do some more digging.
Before doing anything else, you should turn on OPcache
That'll be the last thing I do. It shouldn't be this slow without it.
That's a very interesting step to do. why do you refuse to enabling OPcache?
I'm not, I'm simply stating it shouldn't be so slow without it enabled. I'd rather fix the issue before enabling it (also, it's already enabled on production, and it's still dog slow).
I think you could create a minimal repo on github to reproduce it
Ok, I'm going to take a VEEERY wild guess.. are you by any chance throttling the page from the dev console?
Please double check
like this
![No description](https://cdn.answeroverflow.com/1326521763961634886/image.png)
In both environments? π
I highly doubt is as well... but ya never know π
. I cant thing of anything else tbh
Not sure if it will affect things or not but any chrome extensions causing issues ? ( assuming using chrome)
No. hehe