F
Filament14mo ago
noOne

Filament performance

These numbers don't make any sense why is a simple crud taking almost 40 MB of memory ?
No description
41 Replies
TranceCode
TranceCode14mo ago
I have the same problem here, 36MB and only loading an empty FilamentResource, example a customerResource with 36 MB, the dashboard with 32MB only with a widget, can't understand this problem... i check this video in Filament Daily, by Polivas Korop of Laravel Daily and the memory that use is 3MB and 80ms, i have all the time 400ms, 500ms... this is the video @noOne https://www.youtube.com/watch?v=LGHKjqLAhP4
Filament Daily
YouTube
Filament is Slow? Check Laravel Debugbar.
If you notice that some dynamic elements in Filament are loading slowly, I have a tip for you.
noOne
noOneOP14mo ago
caching the icons helped reducing the loading time "php artisan icons:cache" but didn't help with the memory usage i noticed a comment in this video saying that the windows environment is one of the reasons so i have to ask do you use windows like me ?
Thijmen
Thijmen14mo ago
Windows could be the problem Probably best option is to use linux or mac Windows uses a lot of memory for running "larger" projects Is this local or production?
cheesegrits
cheesegrits14mo ago
For me on Mac locally a typical backend resource page is about 5MB and 350 to 400ms. On an AWS Ubuntu in staging/prod it's about 5MB and 250 to 300ms. That's with 'views' turned off in DebugBar and caching icons. Which is actually slightly smaller and slightly faster than a default Jetstream "Profile" page on my front end.
cheesegrits
cheesegrits14mo ago
No description
No description
cheesegrits
cheesegrits14mo ago
Those are actually showing a livewire update, but the initial page loads are essentially identical times and sizes. I just can't click my capture buttons fast enough to snag them. 🙂
H.Bilbao
H.Bilbao14mo ago
It is not the right place, but the above notification of the agreements is filament or is it something customized by you?
TranceCode
TranceCode14mo ago
yes i do with php artisan icons:cache but the memory not change, the time drops a little, but the memory megabytes remains the same, zero changes The time is the same like on of my project, but the memory is over 36MB and over 38 in other times yes bro, i'm working with Windows, i will test this in a laptop with Linux, maybe ubuntu... thank fot the detail this look cool, i love this... maybe later i will test with a droplet on DigitalOcean and check this again
Thijmen
Thijmen14mo ago
Could you check with inspector network tab what is getting loaded?
TranceCode
TranceCode14mo ago
is a local project, not production yet in all resource load the same memory, 36mb or more, but never over 40mb, and this problem with 36mb is a resource loading a table with 13000 register or 900 register, or in empty resource, without data loading, i mean not table... is a stranger problem, mybe is windows like you says guys... i will know later when upload in DigitalOcean and test again
Thijmen
Thijmen14mo ago
Could you check network tab like this to see what gets loaded what is that size?
No description
noOne
noOneOP14mo ago
can you let me know when you test it ? in my case its local
noOne
noOneOP14mo ago
can i ask how you made the sidebar look like this ?
No description
cheesegrits
cheesegrits14mo ago
@noOne just set $navigationIcon to null. I have so many resources it makes no sense to try and use icons for them. You can also set an icon on the main nav group, in the panel service provider, and null for the individual resource icons ...
return $panel
//
->navigationGroups([
NavigationGroup::make()
->label('Aircraft')
->icon('heroicon-o-paper-airplane'),
NavigationGroup::make()
->label('Logs')
->icon('heroicon-o-calendar'),
NavigationGroup::make()
->label('Users')
->icon('heroicon-o-user-group'),
//
])
//
return $panel
//
->navigationGroups([
NavigationGroup::make()
->label('Aircraft')
->icon('heroicon-o-paper-airplane'),
NavigationGroup::make()
->label('Logs')
->icon('heroicon-o-calendar'),
NavigationGroup::make()
->label('Users')
->icon('heroicon-o-user-group'),
//
])
//
No description
cheesegrits
cheesegrits14mo ago
None of that page is Filament. It's a more or less standard Jetstream front end page (the "Profile" page), with custom styling. So the main nav menu is ...
<div x-data="{ open: false }" class="no-print font-josefin sticky top-0 z-30 bg-white">
<!-- Primary Navigation Menu -->
<div class="mx-auto max-w-full">
<div class="flex h-16 justify-between">
<x-desktop-menu :items="$items"></x-desktop-menu>
</div>

<x-overdue-agreements-header />
</div>

<!-- Responsive Navigation Menu -->
<x-mobile-menu :items="$items"></x-mobile-menu>
</div>
<div x-data="{ open: false }" class="no-print font-josefin sticky top-0 z-30 bg-white">
<!-- Primary Navigation Menu -->
<div class="mx-auto max-w-full">
<div class="flex h-16 justify-between">
<x-desktop-menu :items="$items"></x-desktop-menu>
</div>

<x-overdue-agreements-header />
</div>

<!-- Responsive Navigation Menu -->
<x-mobile-menu :items="$items"></x-mobile-menu>
</div>
... and the overdue-agreements-header is ...
@if (auth()->user()->hasAgencyAdminRole() && auth()->user()->hasCurrentAgency() && $agreement = auth()->user()->currentAgency->hasDueAgreement())
<div class="bg-danger-500 px-4 py-1 text-center text-xl text-white sm:px-6 lg:px-8">
Your agency has pending agreements.
<a href="{{ route('agreements.agreement.edit', ['id' => $agreement->id]) }}"> Click here to sign the agreement.</a>
</div>
@endif
@if (auth()->user()->hasAgencyAdminRole() && auth()->user()->hasCurrentAgency() && $agreement = auth()->user()->currentAgency->hasDueAgreement())
<div class="bg-danger-500 px-4 py-1 text-center text-xl text-white sm:px-6 lg:px-8">
Your agency has pending agreements.
<a href="{{ route('agreements.agreement.edit', ['id' => $agreement->id]) }}"> Click here to sign the agreement.</a>
</div>
@endif
The only Filament thing on that page is the notifications bell, which shows the Filament database notifications shade.
noOne
noOneOP14mo ago
thanks
cheesegrits
cheesegrits14mo ago
So to be clear, I have a Filament backend, and a Jetstream based frontend (but which makes extensive use of standalone Filament tables, forms, actions, notifications, etc).
noOne
noOneOP14mo ago
i went to an old laravel 9 project (not filament) and tested on a linux server and tested on my local windows pc the difference is huge the memory usage on windows is 27 MB but on linux its just 3 MB
linux server
windows pc
Shavik
Shavik14mo ago
On windows, how are you running it? Via WSL? If so, are you using php artisan serve or nginx?
noOne
noOneOP14mo ago
Laragon
Shavik
Shavik14mo ago
Hmm Not really familiar with using that I can tell you if you are using php artisan serve expect a huge performance hit I have a tool that I'm close to releasing that makes Laravel via WSL a breeze on Windows Sets everything up for you I have seen similar really bad performance with Filament using php artisan serve
Mark Chaney
Mark Chaney14mo ago
i never use artisan serve, like ever. dont recommend it
Shavik
Shavik14mo ago
and high memory as it's effectively running a webserver via php instead of a real webserver
Mark Chaney
Mark Chaney14mo ago
exactly
Shavik
Shavik14mo ago
Back after Laracon when I was helping Marcel with NativePHP, I ran into that a LOT since internally it uses that because PHP natively on Windows does not support PHP-FPM so the php startup on each request really hurts livewire. and thus Filament
noOne
noOneOP14mo ago
not really i got the same result using php artisan serve
Shavik
Shavik14mo ago
Right, because if Laragon is native to Windows, it's solution isn't that much better than artisan serve It's better but still severely suboptimal PHP-CGI isn't great It suffers from starting php for each request PHP-FPM keeps php processes spooled (depending on configuration) and ready to go unfortunately PHP-FPM is not support for windows natively. This is why I use WSL, I can use 'Linux' in Windows Not promoting but if you're interested more in WSL, let me know. I am planning on moving Winux to beta in the coming weeks. I can try to help you get it going. This is a demo video of my tool that I use for my personal development now. https://twitter.com/chrisreedtech/status/1695162262388949058 Just as an alternative to Laragon
noOne
noOneOP14mo ago
thanks for the useful information about PHP-FPM AND PHP-CGI about the tool you're building the reasons i use laragon is the ability to install multiple php versions very easy and it also auto create a virtual domain for every project you have in the www directory and it's an "all in one" package meaning you just install laragon and it will install everything you need "php mysql apache nginx nodejs" and more so well we see something like that in the tool ?
Shavik
Shavik14mo ago
😄 Yes quick run down of how I run my stack (before the tool, which is mirrored in the tool) I'd setup a nginx zone file in /etc/nginx/sites-available then symlink it to sites-enabled have to restart nginx, make a database, then make a line in my hostfile so that the subdomain would point to localhost then I would still not have HTTPS and I'd have to configure all that manually The tool does all that automagically in less than 30 seconds at the end of the process, you have a new Laravel project from nothing, that have a database, .env configured, https, nginx, and it auto opens vscode (for now, php storm coming) and the live webpage in your browser Oh It will also init a git repo in the site and auto via the github cli tool, make a repo on github and do your first push
noOne
noOneOP14mo ago
that looks cool i'm definitely interested
Shavik
Shavik14mo ago
Added you as a Discord friend. I'll definitely post on Twitter and try to message you on discord when I'm ready for others to start testing. I have a bootstrap tool that I'm working on as well that can bootstrap a fresh WSL instance (ubuntu, from the windows store) and will have it fully configured to go It auto installs nginx, php, the modules, pretty much everything you need to then run the main tool to start making projects I want all of the stuff I've said so far to be free but I would like to monetize company/enterprise usage and provide enhanced team/collaberation features. Gotta feed my family after all. But I want everything I've said before this message to be open source and free Just trying to figure out a plan there before I open source the tool and 'let the cat out of the bag' I figured that people would be far more comfortable running such a tool if they could inspect the source to make sure it's not doing anything that it shouldn't. Main tool is made with Laravel Zero but the bootstrap program is straight python (no php in stock Ubuntu install)
noOne
noOneOP14mo ago
nice i wish you luck i followed you on twitter
Shavik
Shavik14mo ago
Appreciate the support! Encourages me to try to spend more time on it 🙂 Good luck with your performance issues on Windows. hope I can help with that before too long
ChesterS
ChesterS14mo ago
FWIW, using WSL, you get a huge performance boost by having the project files inside the container you're using. https://learn.microsoft.com/en-us/windows/wsl/filesystems#file-storage-and-performance-across-file-systems It's a common mistake I've seen a lot of people make (including me until recently). I had my code on a Windows folder. Once I moved it inside the Ubuntu environment, the speed difference was insane
Working across file systems
Learn about the considerations and interop commands available when working across Windows and Linux file systems with WSL.
Shavik
Shavik14mo ago
For sure, that is a huge hit. I don't do any cross file system operations unless it's copying from one into the other to then use it. WSL still can struggle a bit with symlinks. I've run into that doing package development and having it symlinked in to my working project. When the package and main testing app are both open, the vscode server can make the load average go up to 2+. Tracked down to symlinks
awcodes
awcodes14mo ago
For the record I’ve seen this is valet too going up to 35MB. But restarting valet usually takes it back down to 3-5. Probably too much crap in tmp.
Jeff
Jeff14mo ago
FWIW - I'm running HERD and sitting at 11MB right now, with a fairly empty project (data-wise) but with 13 resources.
Shavik
Shavik14mo ago
These are my PHP processes for my WSL instance.
No description
TranceCode
TranceCode14mo ago
im working in a deploy on DigitalOcean, when i finish him, i test the memory with debugbar again Hey friends, finally i put my project in a droplet on DigitalOcean, i check the memory with debugbar and this use 9MB now, from 36Mb or 39Mb is down to 9Mb and between 200ms to 260ms later i will configure the php-fpm
Alex
Alex14mo ago
Hi
TranceCode
TranceCode14mo ago
after that i execute the php artisan icons:cache and now all resource use only 3Mb... this is really really cool
Want results from more Discord servers?
Add your server