What can you do to speed up resource

I am searching for a solution. When editing a resource (just some text fields, checkboxes and a builder) it feels way slower to change fields then it feels like to be. Sometime the 'update' call in the network tab can take longer than 16 seconds. How to make filament feel more snappy? (No debugbar and other first google hits are present)
63 Replies
Thijmen
Thijmen4mo ago
Sounds like you got a problem that isnt Filament. I have enormous forms that save pretty fast.
Wesleyh
WesleyhOP4mo ago
So what could be the problem? I have it in production as well in dev
Dan Harrin
Dan Harrin4mo ago
Using debugbar, check the timeline to see the “booting” ms vs request ms, and also how long the db queries take also are you on windows?
Wesleyh
WesleyhOP4mo ago
I am on mac using herd, production is linux. (laravel 12) Opening the /pages/1/edit:
Booting 39.11ms Application 11.22s (s not ms) Request duration 80.47ms Peak Memory 10MB The database queries took 2.08ms
When adding a 'row' to a builder element. Request to /livewire/update
Booting 35.67ms Application 14.3s (s not ms!) 273x vies 0 Peak memory 26MB Database queries 1.99ms
Where should I look to get application quicker.
Dan Harrin
Dan Harrin4mo ago
absolutely no clue, those numbers are crazy something is obviously seriously wrong but i dont think its filament ive never seen numbers that high when people complain about slowness it may be 1s, not 15s
Wesleyh
WesleyhOP4mo ago
I can handle 3 seconds or so but yeah one textbox 15 seconds is kinda killing 😂 But if not filament what else? Frontend is inertia and Vue, no issues there at all. Maybe it's a reactive thing that's messing with the builder? Relationships maybe?
Dan Harrin
Dan Harrin4mo ago
can you remove each feature from the form one by one and work out which one is causing the problem? i feel like it cant be an issue with it getting slower progressively
Wesleyh
WesleyhOP4mo ago
I will report back to you soon! I will get to the bottom of this. Thanks
Dennis Koch
Dennis Koch4mo ago
OPCache is enabled? Did you run php filament:optimize (if that’s the right command 🙈)
Wesleyh
WesleyhOP4mo ago
Caching didn't do much. I feel like it's a compounding effect actually, each row added with different content just adds to the total views that needs to be rendered is my conclusion of the profiling. So I feel like it re-renders all the time with each update I do. So each row or content adds about 1.3 seconds. Maybe what I do is too complex and I have to find a workaround.
toeknee
toeknee4mo ago
Can you provide the form? have you ensure closures are used when using DB Queries etc for selects / options? Do you have debug bar enabled by any chance? If so, disable view collection since that massively slows it down as per the docs.
Dan Harrin
Dan Harrin4mo ago
how about using the builder "preview" feature, so the form doesnt render upfront each block has a preview view, and is editable in a modal 1 second still sounds super slow for a block though, i wouldnt expect that to be more than 50ms
Wesleyh
WesleyhOP4mo ago
I think this is the way to go! The rendering time is a bit deferred and split up but UX is way better. On a bigger page (like 8 rows) each row takes still about 2 to 4 seconds to load. Maybe I still did something wierd, but at least there is a workable workaround.
toeknee
toeknee4mo ago
2-4 seconds is insane per row fyi live() replaces reactive() Can you also try loading your blocks into an array on mount of the page and then calling the blocks with $this->blocks. To save loading all the files each time on a refresh.
Dan Harrin
Dan Harrin4mo ago
@Wesleyh can you create a full reproduction repository that I can install and test out the performance of on my machine? or if your real project is easy to install, you can share it with me privately on github i at least want to see this insane performance for myself, I feel like something must be seriously up lol
Wesleyh
WesleyhOP4mo ago
Send me a DM with your github I think that is the easiest
Dan Harrin
Dan Harrin4mo ago
my username is danharrin
Wesleyh
WesleyhOP4mo ago
I invited you to the private repo, make sure to be on the "Rebrand" branch. Please forgive me the WIP in general and now of the preview blade components. System wise: MacOS, 128GB, Herd, Yarn as package manager
Dan Harrin
Dan Harrin4mo ago
ok so how many blocks are you using on this page?
Dan Harrin
Dan Harrin4mo ago
feels pretty snappy to me
Wesleyh
WesleyhOP4mo ago
You should switch to the Rebrand branch
Dan Harrin
Dan Harrin4mo ago
and what should i do?
Dan Harrin
Dan Harrin4mo ago
🤷‍♂️
Wesleyh
WesleyhOP4mo ago
Dan Harrin
Dan Harrin4mo ago
Dan Harrin
Dan Harrin4mo ago
think its some php or server set up thing, or something on your machine none of this feels slow i am using macos & valet, but i think herd runs on valet anyway
Wesleyh
WesleyhOP4mo ago
No it feels insanely fast I never had it this fast for any filament project.
Dan Harrin
Dan Harrin4mo ago
are you sure you have opcache enabled? in php.ini
Wesleyh
WesleyhOP4mo ago
Im going to check!
Dan Harrin
Dan Harrin4mo ago
make sure to restart php if you enable that
Wesleyh
WesleyhOP4mo ago
I have checked, opcache was already on, opcache_cli was turned off now turned it on, as well as restarted the whole machine to be sure.
Dan Harrin
Dan Harrin4mo ago
what is your computers current ram usage
Wesleyh
WesleyhOP4mo ago
25 GB of 128GB
Dan Harrin
Dan Harrin4mo ago
you have 128GB of ram? jesus honestly when you first posted that i thought you were talking about storage do you have antivirus software on your computer that scans all files before they get opened? we have this issue with windows defender sometimes
Wesleyh
WesleyhOP4mo ago
It's a mac
Dan Harrin
Dan Harrin4mo ago
i know, im talking about equivalent mac software
Wesleyh
WesleyhOP4mo ago
No nothing that I am aware of
Dan Harrin
Dan Harrin4mo ago
yeah its weird dude, but i think i can rule out it being anything wrong with filament tbh my computer "only" has 32gb ram and its clearly not got issues with perf for me if you deploy it, the perf issues probably wont be there tbh
Wesleyh
WesleyhOP4mo ago
I understand, will investigate further, I can not be the only one that will face this I am actually not sure, because I have deployed Filament projects in the past on VPS and it never was so fast as in your video which amazes me. But for science I will try it out Also ruled out firefox / chrome now
Dan Harrin
Dan Harrin4mo ago
its def not a browser because its the server response time
Wesleyh
WesleyhOP4mo ago
You on PHP 8.3 or 8.4?
Dan Harrin
Dan Harrin4mo ago
8.2 8.3 and above is broken on my machine and i need to format it i think lol actually its only an issue with 8.3 and postgres, let me try 8.3 and another db yeah no issues on 8.3
Wesleyh
WesleyhOP4mo ago
I will deploy this, see if it makes a difference. Okay you were right, the thing with the previews likely did the job in production! Wierd that it wont work locally, I will still try to figure out why for the next person.
toeknee
toeknee4mo ago
Did you enable debug bar locally? or have xdebug enabled?
Dan Harrin
Dan Harrin4mo ago
ah yeah, xdebug really slows things down
Wesleyh
WesleyhOP4mo ago
I have debugbar locally as far as I know? What should I check? I put the views thing to false in the config. Never heard of xdebug honestly. I disabled it in Herd and set everything to no in the debug.ini. I have to go now, I REALLY appreaciate the swiftness and all the help you already provided today. I did some more testing and it has to be something to do with Herd. when just using php artisan serve it's extremely fast. I have disabled xdebug, opcache is enabled.
Dan Harrin
Dan Harrin4mo ago
woop, I'm glad you narrowed it down i bet if you tried valet instead of herd it would also be fast, thats what i use
Wesleyh
WesleyhOP4mo ago
Yeah I'll consider maybe switching now but shouldn't be needed. But I'm on herd pro Actually reached out to the Herd developer because something's fishy about this. I'll investigate further.
Dan Harrin
Dan Harrin4mo ago
@Wesleyh would you mind sharing the ms for Herd vs artisan serve on this page?
Wesleyh
WesleyhOP4mo ago
3.12s and 110ms 💀
Dan Harrin
Dan Harrin4mo ago
lol, nice i might add a note to the docs about herd then please let me know if you figure out what the config issue is
Wesleyh
WesleyhOP4mo ago
Yeah I will do my best What the wierd thing is: php is configured through herd as well as the database. Artisan serve uses that as well. Which got me thinking maybe it's related to ngnix or something. Maybe a far stretch.
Dan Harrin
Dan Harrin4mo ago
when youre telling me about performance, you're using numbers from debugbar instead of the network tab right? the numbers from debugbar do not get affected by the server iirc, just the speed of php-fpm
awcodes
awcodes4mo ago
Just for the record. I"m gettin the same speeds on Herd and Valet. 🤷
Wesleyh
WesleyhOP4mo ago
I reported earlier from the debugbar, tested now quickly again and in the network tab /livewire/update 3.41s in herd (just adding a row) with serve 129.18 ms on the same endpoint.
awcodes
awcodes4mo ago
Definitely something in your herd install then.
Dan Harrin
Dan Harrin4mo ago
i wonder how many of your other apps will be faster too
Wesleyh
WesleyhOP3mo ago
Okay breakthrough, it has to do with https. On http with herd it's also super fast. But it breaks uploaded images since they point towards https. I did a cache:clear to try if filament maybe caches the https. Then I wanted to benchmark it back on https and it was fast all of a sudden? Reissuing the certificate somehow solved it?
Dan Harrin
Dan Harrin3mo ago
lol wow, thats so weird
Wesleyh
WesleyhOP3mo ago
So I am testing a theory here. Maybe in a year something has changed with the way certificates are handled. I now test it out with another project that I considerd slow. Observation 1: the portfolio site was not in apple keychain manager and is not there now as well. Observation 2: the other site (created aug 2024) is there now and is slow. Observation 3: removing the certificate from herd removes it from apple keychain manager. Observation 4: reissuing doesn't add it to keychain manager. This is so wierd, actually it's not fast anymore. I was too fast happy Now I found it and it's replicable! Sorry for the confusion with https. What I think happend is that for a little time Herd was not intercepting dumps but I just now noticed that in the herd is intercepting also views like debugbar it seems. The old project triggered a dump and that opened a background window. It goes CRAZY when you do any action in filament. Solution: disable views in the dumps view
Wesleyh
WesleyhOP3mo ago
No description
No description
Wesleyh
WesleyhOP3mo ago
Thanks @Dan Harrin @toeknee and @awcodes for the commitment, it was a great help! I always thought Filament was just a tad slow and it was a tradeoff between speed and ease of use. Probably there is something in production that also logs something (telescope perhaps) that slows it down but that is now easily findable.

Did you find this page helpful?