wc-smooth-generator icon indicating copy to clipboard operation
wc-smooth-generator copied to clipboard

Memory limit when generating large amounts of test data

Open mikkamp opened this issue 11 months ago • 1 comments
trafficstars

Prerequisites

  • [x] I have carried out troubleshooting steps and I believe I have found a bug.
  • [x] I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug

I tried to generate a large set of orders for testing (50k), however it seems that this eventually runs out of memory (1GB):

$ wp wc generate orders 50000 --date-start=2010-01-01 --date-end=2024-12-10
Generating orders  6  % [=======>                                                                                                              ] 33:14  / 478:53
2024/12/11 11:40:10 Resident memory usage of 1258954752 bytes exceeded maximum allowed value of 1258291200

    3.0mb	/bin/bash -i -l
  989.6mb	/usr/local/php8.3/bin/php /usr/local/bin/wp-cli --path=/srv/htdocs/__wp__/ wc generate orders 50000 --date-start=2010-01-01 --date-end=2024-12-10

I haven't looked into the details of the memory usage, but from this run it seems like it's not cleaning up some things after creating an order which is making the used memory grow, till it runs out.

WordPress Environment

Pressable site with:

WordPress 6.7.1 WooCommerce 9.4.3 WooCommerce Smooth Generator 1.2.1

Isolating the problem

  • [x] I have deactivated other plugins and confirmed this bug occurs when only WooCommerce and WooCommerce Smooth Generator plugins are active.
  • [x] This bug happens with a default WordPress theme active, or Storefront.
  • [x] I can reproduce this bug consistently using the steps above.

mikkamp avatar Dec 11 '24 12:12 mikkamp

I did some rudimentary profiling of the orders and products generators using xdebug. I don't really know what I'm doing with yet with the profiling tools, but from the output files, it looks like the biggest bottlenecks are:

  • Orders: Order::get_random_products
  • Products: Generator::generate_image

coreymckrill avatar Jan 04 '25 00:01 coreymckrill