Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
8 Jan 2025 at 11:12 UTC
Updated:
31 Mar 2025 at 12:24 UTC
Jump to comment: Most recent
See #1199866: Add an in-memory LRU cache - let's use that code here. Postponing on that one...
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
catchEither in this issue or a follow-up, we should remove or modify MigrateExecutable::attemptMemoryReclaim()
Comment #5
heddnre: slot count:
From #1199866-84: Add an in-memory LRU cache, the thought was that this should be a much higher number then 300. So it is nice to see a number of 1000. Do we know if smaller hosting, e.g. an entry level pantheon plan will hold 1000 entity slots for 5-6 fields on a node or paragraph?
Comment #6
alexpott@heddn well atm the moment the number of slots in your cache is infinite so this is not really making anything worse. 5-6 fields on node is not that much - I tried to get the amount of memory used by a node on a production site with a complex data model. I think it might in the realms of 0.2mb per node... so a 1000 of them is about 200mb which is well within what I would expect you to be running a migrate job with. I expect that most sites nodes would take up considerably less space.
Comment #7
catchComment #10
alexpottNow that #1199866: Add an in-memory LRU cache is in we should use it!
Comment #11
catchVery nice. Looks like StandardPerformanceTest needs a tweak.
Comment #12
berdirNo sure I see why this affects standard performance test.
Could that be a random fail? https://git.drupalcode.org/project/drupal/-/pipelines/440609/test_report... does say it failed quite a lot recently on 11.x.
Comment #13
catchHmm I think I saw a similar failure somewhere else, maybe it's a random failure. Not sure we need those assertions now we have the grouped cache tag assertions so might be better to just drop them entirely.
Comment #14
berdirYeah, I've been meaning to file an issue about that, started leaving them out in some cases, they no have no performance meaning now that we can assert the amount of actual lookup queries.
I can't trigger a retest on the MR or I would have done that, saw a similar comment recently, apparently an issue with merge requests created by core maintainers?
Comment #15
catchThe permissions on pipelines are different depending on whether they're triggered by a commit by a core committer or not, I do not really understand why but it's inherent to gitlab. Even the directory it runs in is different which was very annoying when trying to add phpstan et al result caching (it only worked for core committer MRs for a couple of weeks until we noticed).
Comment #16
catchOpened #3511123: Remove cache tag checksum assertions from performance tests.
Comment #17
alexpottTest went green on re-running.
Comment #18
smustgrave commentedSeems pretty straight forward, not entirely sure how else to review.
#16 has also already been committed
Comment #19
kristiaanvandeneyndeShould we document 'entity.memory_cache.slots: 1000' and/or its usefulness for migrations somewhere? Seems like something that could save a lot of time if we explain it beforehand rather than when found during debugging of your migration's memory issues.
MigrateExecutable used to release the entities from memory but no longer does as long as we don't reach the 1000 limit, yet we have (minor) concerns from @heddn that people (with free hosting plans) will run out of memory. To me, that seems like a behavioral change that could lead to some nasty hour-long debugging sessions figuring out why stuff isn't working anymore.
So I'm not sure about RTBC. Seems like we may have some collateral damage here if we release this without a CR or documentation.
Comment #20
alexpottWe could set the number of slots in a compiler pass and change it if you have less memory.
Comment #21
catchMemory could be different for web vs. cli so I'm not sure about changing it dynamically like that.
Comment #22
kristiaanvandeneyndeI'd rather we leave it at 1k but at least mention this in the release notes, accompanied with a CR explaining you can change this behavior with a container param. Adding dynamic memory profiling is perhaps a bit overkill and may lead to obscure bugs.
Comment #23
kristiaanvandeneyndeI'll draft a CR, one sec.
Comment #24
kristiaanvandeneyndehttps://www.drupal.org/node/3512407
Does this seem sufficient? It won't "kill" migrations per se, but it will trigger more batches
and as a result may end up loading the same entities into memory over and over for every batch, leading to slower migrations.Edit: Before, it would erase all entities from memory, so the change makes migrations faster as we can reuse the entities we do have in memory. It will just lead to more batches being created once we hit the memory limit because we no longer flush the entity cache. Not sure what the impact is of firing up a lot more batches vs the old behavior. If I were to guess, the old behavior was probably still slower.
Comment #25
catchCR reads really well to me.
Comment #26
berdirAgreed with leaving it at a fixed value, the scope here is that it shouldn't affect web requests and it can be lowered if necessary.
Comment #27
alexpottThe problem is if you are on minimal hosting changing container params is a right pfaff and knowing that you have to do that is going to be very hard to find out.
Comment #28
kristiaanvandeneyndeCouldn't people change this from their services.yml file which is automatically picked up because it's in the container_yamls setting?
Which reminds me we didn't add this new container param to default.services.yml. We might want to do that as it gives us the opportunity to write some brief documentation in its comment.
Comment #29
catchAdding to
default.services.ymlis a good idea, moving back to needs work for that.Comment #30
alexpottAdded the param to default.services.yml
Comment #31
kristiaanvandeneyndeLGTM.
Maybe wait until @alexpott confirms a services.yml file in sites/default is enough to take away his concerns in #27?
Comment #32
alexpottWe can start here - if it proves a problem then we can visit. Ideally if you're on cheap limited hosting you don't have to edit files to do a migration. I recently set up D11 on some cheap hosting it has 2GB memory limit in PHP so maybe Pantheon will up their game... 128Mb seems tiny.
Comment #33
catchYeah I think this is fine for now. For drush migrations it will start a new batch if it runs into trouble, the more common situation I've seen on Pantheon is regular hook_update_N() and config import running out of memory, which this may or may not help but we'll find out.
Committed/pushed to 11.x, thanks!
Comment #36
catch