-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance #16
Comments
Hey Sean, yes it's something I've encountered. I know of one particular bottleneck, which is actually the rendering of the field. Large Neo fields can render hundreds of kilobytes of raw HTML/JS, which will probably be a strain on the server. A lot of the generated HTML/JS doesn't change, so caching it shouldn't be a problem. Another potential bottleneck, which I haven't verified yet, is the DB insert queries. After every save Neo field structures are completely torn down and rebuilt, which might be an issue if you add a lot of blocks to a Neo field. |
It seems rebuilding the structures is not the bottleneck, nor does it impose any significant delay when saving. I attempted caching as well, and while it does shave off a few hundred milliseconds in rendering, saving the field is still the main bottleneck. I'm going to keep looking into this. |
With a comparative Matrix field and value, the Neo counterpart performs worse, taking about twice as long to save. Just ruling out it being something to do with Craft itself. That said, a Matrix field can still take a very long time to save as well. I have a feeling the time discrepancy may be explained by the fact that Neo uses the |
Here's an interesting idea: Neo fields could auto-save their changes while you're editing them via AJAX, but linked to a temporary element. Then when you save the real element, instead of having to perform a tonne of DB queries to save the Neo field, it just changes the content reference from the temporary element to the real one. This means that it'd effectively take no time at all to save a Neo field. It'd also mean having to fire a task periodically to clean up any temporary elements (which would be left around if someone were to edit a Neo field and then discard the changes). As of version |
Another idea is simply only perform DB queries on changed data. That should see a very noticeable increase in performance. |
(Just some more testing results to my own future reference)
Something very strange is going on under the hood of Craft, or PHP for that matter. Experimentation seems to split the bottleneck between rendering and saving, but disabling one doesn't affect performance at all, but disabling both does. |
So I finally decided to crank out the xDebug profiler, and low-and-behold the culprit is the In practice, disabling generating search keywords see's around a 45% decrease in saving time which, while very good, is not in line with the results from profiling. I'm fairly certain this is due to rendering the field again after saving, so caching that should really speed up the saving time (should cache on a per-block basis). I also need to figure out how to spin off generating search keywords into a separate task. Looks like I finally have a plan in place. Should even out-perform the Matrix field. |
Good news, and great work on this. Thanks! |
Cheers dude. I've got keywords being generated in a task fully implemented, and now even entries that have like 50 blocks filled with content save almost as quickly as an entry with nothing at all. Still got problems with the block caching, but once that's sorted I'll be releasing |
Sounds awesome.! |
Resources included with blocks are now filtered, and only get added to the DOM if they don't already exist there. This dramatically improved render performance for cases where there are a lot of resources included with blocks and their fields. Could perhaps improve on this further by asyncronously loading JS resources
Everything is finalised and has passed all testing, but I will be using it in the wild for at least the next week before I release. If you'd like to try out the new performance enhancements now, you can grab a copy of the plugin here. |
I've been seeing this too - I really love the plugin and the flexibility it's giving me with my layouts, but it's been slowing my control panel to a halt. Granted, I have a few fairly large pages that I'm working on - smaller ones (predictably) don't affect CP speed/performance nearly as much. And it does look like the culprit is the This isn't a deal-breaker by any means for me (and I know you're working on fixing this!), but would I be losing any core functionality if I just stripped out the Thank you for all you work on this, so far it's been a huge asset for me and my team! |
Hmm that is interesting. Since As for the search keyword tasks, I'm not sure how dozens of them are spawning after a single save, unless you have dozens of Neo fields on a single entry. One task is spawned for one Neo field. I haven't experienced stuck tasks either, but I suppose that's bound to happen given Craft's task system (happens a lot with the "Deleting stale caches" task). How large are these fields? Average number of blocks, block types and fields per block type? Search keywords are used in the CP when searching for entries, categories, etc, as well as on the front-end when querying for entries using the Unfortunately even with Matrix fields you're going to see these performance impacts. There's a lot of overhead when adding Craft and Yii into the mix. Craft 3 has seem some big performance boosts in the database querying department so hopefully this doesn't stay a problem for much longer. If you haven't already, I'd strongly recommend upgrading your server's PHP version to 7, as it also performs much better than any 5.x version. |
So after some time testing and trying to isolate the slowdown issues, I'm pretty sure the culprit is one (or more) of my Chrome extensions. If I load and edit entries in the CP in Chrome Incognito mode or Firefox/Safari, the slowdowns are pretty much gone (it still takes a few seconds to initially load the page which is certainly acceptable, but I was getting load times up to a minute on my normal Chrome). I'm going to look into just which extensions are causing the problems. I was getting all hundreds of console errors in my normal Chrome when I would try to click around before giving the entry edit page time to load completely:
I don't get those at all on Incognito or other browsers, which makes me suspect it's an extension that's not playing nicely. And also, I don't think this is a big deal, but I do get some console warnings when I add in a block that contains a Super Table text field: I appreciate your help with this though! I will keep you posted if I can isolate just which extension is causing the problem (in case others are running into similar problems). |
Wow, minute load times are definitely out of the ordinary. It does sound like an extension is playing havoc with Neo, but I'm not sure why that could be. It seems that whatever is going on, a lot of resource requests were being fired, until the point that Chrome ran out of memory (hence the As for the warning, it's a minor warning by Garnish that doesn't really affect anything. In certain situations some Garnish components are being initialised twice, but Garnish picks up on it and handles it. This happens usually because when Neo blocks are created, Neo initialises all Garnish components inside the block, but some fields will explicitly initialise their components as well. So sometimes you get these warnings, but everything still functions normally. No problem, thanks for the heads up. If you figure out what extension is causing this problem, I'll see if I can figure out why and hopefully fix it 👍 |
Hi Benjamin.
I'm just wondering if you've hit many performance issues with Neo yet? I have a pretty large Neo field that includes an awful lot of fields including quite a few Matrix fields. I find saving a page with the Neo field is quite slow. I've had a couple of errors when my php memory was set low at 8M, but it's been upped now and although slow, I've not had any errors. I haven't tested properly yet and I'm sure there's some optimisations I can make, just wondering if you've hit anything yet?
The text was updated successfully, but these errors were encountered: