Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@veox pointed out that some of the tests use a very large amount of memory. I did some profiling and found the biggest offenders. Here are the top 10, sorted from least to greatest. This number tracks total allocations (from tracemalloc), not maximum size in memory.
Most allocations came from a single line, which has now been changed:
with the requested memory, this created an often unnecessary copy of
the data. It now returns a memoryview(), which is a python wrapper
around a pointer to the raw data.
This caused the total number of allocated bytes to drop dramatically. The new set of top 10 offenders:
Total allocations is not the same as the high water mark of memory used but it was a lot easier for me to measure. To verify that this also helped the thing which actually matters I checked maxrss on some of the tests and saw a nice improvement:
static_Call1MB1024Calldepth_d1g0v0_Constantinople
used to consume 1.2 GB and now uses 705 MBstatic_Call50000_ecrec_d0g0v0_Constantinople
used to consume 3.8GB and now uses 1.4GBFuture work:
Cute Animal Picture
And alternative approach might be to make all the objects images of kittens, in which case any duplication would remain but gain unassailable justification: