# |
Apr 18th 2019, 17:30 |
pedrorocha |
->save() accepts my whole array of data? |
# |
Apr 18th 2019, 17:29 |
ricksaccous |
in one query |
# |
Apr 18th 2019, 17:29 |
ricksaccous |
@pedrorocha why not save 15k per loop pass |
# |
Apr 18th 2019, 17:27 |
slackebot |
loop memory usage run: 10 -> 2.69 MB Inner loop memory usage run: 11 -> 2.69 MB Inner loop memory usage run: 12 -> 2.48 MB Total loop memory usage -> 2.41 MB Why is this happening? How can I free the memory used by the inner loop on each run? |
# |
Apr 18th 2019, 17:27 |
slackebot |
I comment the `->save()` line, it looks like this (as it should be): Inner loop memory usage run: 1 -> 2.66 MB Inner loop memory usage run: 2 -> 2.68 MB Inner loop memory usage run: 3 -> 2.69 MB Inner loop memory usage run: 4 -> 2.69 MB Inner loop memory usage run: 5 -> 2.69 MB Inner loop memory usage run: 6 -> 2.69 MB Inner loop memory usage run: 7 -> 2.69 MB Inner loop memory usage run: 8 -> 2.69 MB Inner loop memory usage run: 9 -> 2.69 MB Inner |
# |
Apr 18th 2019, 17:27 |
slackebot |
-> 23.52 MB Inner loop memory usage run: 5 -> 29.82 MB Inner loop memory usage run: 6 -> 38.11 MB Inner loop memory usage run: 7 -> 44.41 MB Inner loop memory usage run: 8 -> 50.7 MB Inner loop memory usage run: 9 -> 56.99 MB Inner loop memory usage run: 10 -> 67.29 MB Inner loop memory usage run: 11 -> 73.58 MB Inner loop memory usage run: 12 -> 79.67 MB Total loop memory usage -> 82.13 MB It should not be wasting this much memory on each loop, when |
# |
Apr 18th 2019, 17:27 |
pedrorocha |
Hello guys, I'm trying to save 320k records on my db using a foreach loop to iterate through an array of data. I loaded the model outside the loop and split the data in batches of 15k, the inner loop looks like this: ```foreach ($users as $user) { $dataToSave = array('user_id' => $user->id, 'notification_id' => $notificationId); $userNotification = $this->UserNotification->newEntity(); $userNotification = |
# |
Apr 18th 2019, 17:27 |
slackebot |
$this->UserNotification->patchEntity($userNotification, $dataToSave); $this->UserNotification->save($userNotification); }``` It's wrapped around a while loop counting the number of runs and managing the batches. When I run this code and track the memory usage of it, this is what I'm getting: Inner loop memory usage run: 1 -> 2.61 MB Inner loop memory usage run: 2 -> 9.43 MB Inner loop memory usage run: 3 -> 16.23 MB Inner loop memory usage run: 4 |
# |
Apr 18th 2019, 16:32 |
admad |
@mrfeedback `<?=` is short echo, different than short open tag. It's unaffected by php config and always available |
# |
Apr 18th 2019, 16:20 |
mrfeedback |
`Note that this directive does not control the <?= shorthand tag, which can be ; used regardless of this directive.` |
# |
Apr 18th 2019, 16:20 |
mrfeedback |
oh. okay forget what i said |
# |
Apr 18th 2019, 16:18 |
mrfeedback |
yep i mean `<?=` as `short_tag_open` is also not recommened as `On` for production environments according to the official php.ini https://github.com/php/php-src/blob/master/php.ini-production |
# |
Apr 18th 2019, 16:14 |
ricksaccous |
the second is never used |
# |
Apr 18th 2019, 16:13 |
ricksaccous |
@mrfeedback <?= is very distinct from <? ?> |
# |
Apr 18th 2019, 16:13 |
waspinator |
never heard of it being a problem before |
# |
Apr 18th 2019, 16:13 |
waspinator |
you mean this `<?=` |
# |
Apr 18th 2019, 16:11 |
waspinator |
https://github.com/cakephp/cakephp.org/blob/master/src/Template/Element/Layout/default/footer/social_links.ctp |
# |
Apr 18th 2019, 16:09 |
mrfeedback |
i mean its used everywhere as it seems :slightly_smiling_face: |
# |
Apr 18th 2019, 16:09 |
mrfeedback |
cakephp.org\src\Template\Element\Layout\default\footer\social_links.ctp e.g. |
# |
Apr 18th 2019, 16:08 |
admad |
where? |
# |
Apr 18th 2019, 16:08 |
mrfeedback |
hmm browsing through templates of cakephp.org i realize that you use shorttags for opening and echoing in php. i was told that this feature is often disabled on hosts due to security concerns. or is this not an actual problem anymore? |
# |
Apr 18th 2019, 16:07 |
admad |
then make a PR for the docs :slightly_smiling_face: |
# |
Apr 18th 2019, 16:02 |
mrfeedback |
ah funny. on the website itself it is removed. but not in the book |
# |
Apr 18th 2019, 15:56 |
mrfeedback |
thx |
# |
Apr 18th 2019, 15:50 |
admad |
https://github.com/cakephp/cakephp.org |
# |
Apr 18th 2019, 15:49 |
mrfeedback |
hmm i have no idea where to put the PR for the website? :slightly_smiling_face: |
# |
Apr 18th 2019, 15:45 |
admad |
@mrfeedback make a PR :slightly_smiling_face: |
# |
Apr 18th 2019, 15:42 |
mrfeedback |
i think you can remove the Google+ Button on the website :) |
# |
Apr 18th 2019, 15:38 |
this.impetus |
@admad check, will do, ty |
# |
Apr 18th 2019, 15:37 |
admad |
@this.impetus you might also want to consider https://github.com/admad/cakephp-glide |
# |
Apr 18th 2019, 14:49 |
ricksaccous |
lol |
# |
Apr 18th 2019, 14:49 |
neon1024 |
https://github.com/cakephp/cakephp/blob/master/src/Core/ObjectRegistry.php#L97 |
# |
Apr 18th 2019, 14:49 |
ricksaccous |
well actually that makes sense |
# |
Apr 18th 2019, 14:49 |
ricksaccous |
or it didn't instantiate it |
# |
Apr 18th 2019, 14:49 |
this.impetus |
It alarms me terribly that I understand none of that :P |
# |
Apr 18th 2019, 14:49 |
ricksaccous |
i had no idea that it didn't load it until you used it |
# |
Apr 18th 2019, 14:48 |
ricksaccous |
interesting |
# |
Apr 18th 2019, 14:48 |
neon1024 |
.. a bit like a DI container |
# |
Apr 18th 2019, 14:48 |
neon1024 |
As if it can’t find the key, it’ll instantiate the object and set the instance to the key |
# |
Apr 18th 2019, 14:48 |
neon1024 |
At least that’s my understanding of how the object registry works |
# |
Apr 18th 2019, 14:48 |
neon1024 |
They don’t get instantiated in the registry until you use them anyway |