F
Filamentβ€’2mo ago
Oddman

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
LeandroFerreira
LeandroFerreiraβ€’2mo ago
Try to disable debugbar
Oddman
OddmanOPβ€’2mo ago
Having it enabled/disabled makes zero difference.
dissto
disstoβ€’2mo ago
Are you developing on Windows? Or are you taking about the page on your production server? πŸ€”
Dennis Koch
Dennis Kochβ€’2mo ago
Is OPCache active?
Oddman
OddmanOPβ€’2mo ago
Both production and local have the same problem. It is not.
Dennis Koch
Dennis Kochβ€’2mo ago
That’s the most important for PHP performance
Matthew
Matthewβ€’2mo ago
Octane is not so bad also πŸ˜… But even if you arent using opcache, it shouldn't take 6s, right?
Auth1Specialist
Auth1Specialistβ€’2mo ago
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:
private array $componentCache = [
AgendaAppointment::class => [],
AgendaTemplate::class => []
];

Then in my actions:
public function createAgendaTemplateAction() {
if (!array_key_exists('agendaTemplateForm', $this->componentCache)) {
$this->componentCache['agendaTemplateForm'] = AgendaTemplate::form();
}
}
private array $componentCache = [
AgendaAppointment::class => [],
AgendaTemplate::class => []
];

Then in my actions:
public function createAgendaTemplateAction() {
if (!array_key_exists('agendaTemplateForm', $this->componentCache)) {
$this->componentCache['agendaTemplateForm'] = AgendaTemplate::form();
}
}
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.
toeknee
toekneeβ€’2mo ago
Do you have custom middleware?
Oddman
OddmanOPβ€’2mo ago
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.
nanopanda
nanopandaβ€’2mo ago
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?
Oddman
OddmanOPβ€’2mo ago
The latter question - not that I'm aware of. I'll do some more digging.
Dennis Koch
Dennis Kochβ€’2mo ago
Before doing anything else, you should turn on OPcache
Oddman
OddmanOPβ€’2mo ago
That'll be the last thing I do. It shouldn't be this slow without it.
Rolland
Rollandβ€’2mo ago
That's a very interesting step to do. why do you refuse to enabling OPcache?
Oddman
OddmanOPβ€’2mo ago
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).
LeandroFerreira
LeandroFerreiraβ€’2mo ago
I think you could create a minimal repo on github to reproduce it
Matthew
Matthewβ€’2mo ago
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
Matthew
Matthewβ€’2mo ago
like this
No description
Dennis Koch
Dennis Kochβ€’2mo ago
In both environments? πŸ˜…
Matthew
Matthewβ€’2mo ago
I highly doubt is as well... but ya never know πŸ˜…. I cant thing of anything else tbh
David | Fortune Validator
Not sure if it will affect things or not but any chrome extensions causing issues ? ( assuming using chrome)
Oddman
OddmanOPβ€’2mo ago
No. hehe

Did you find this page helpful?