Skip to content

Conversation

@lgo
Copy link

@lgo lgo commented Feb 15, 2021

  • Swaps out the pympler memory grabber for resource which instead pulls total current resource usage. This is done because pympler's asizeof is not compatible with pypy.
  • Adds in a gc.collect() call before the solution code. Along with the above change, this should ensure a solution's memory does not carry over -- assuming there are no memory leaks.
  • Added a requirements.txt for the ease of just using pip install -r requirements.txt rather than fishing dependencies out while running it 😅

Here's what I've used to run this using pypy on MacOS.

# Install pypy3 and openblas (library)
brew install pypy3 openblas
# Update pypyp pip essentials.
pip_pypy3 install --upgrade pip setuptools wheel
# Compile numpy for pypy with the local openblas. without doing this,
# the pypy numpy installation will have runtime errors (at least on my setup)
OPENBLAS="$(brew --prefix openblas)" pip_pypy3 install numpy
# Install the other requirements.
pip_pypy3 install -r requirements.txt

# Vroom!
pypy3 tests/test_game.py

# Measure the current memory usage. Because we GC before
# beginning the solution, this should be representative
# of the solution's memory usage.
mem_usage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also completely uncertain if this is the right thing, but was a suggested alternative for asizeof when I was googling around for the pypy error.

@zig1000
Copy link
Contributor

zig1000 commented Feb 15, 2021

Unfortunately I'm developing on windows which resource is not available on, and would like to keep it window-compatible, so I probably won't merge this. I assume pympler is the reason this isn't pypy-compatible, I'll try to look into some better memory measurer / one that's pypy-compatible when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants