Re:Let's Remove the Global Interpreter Lock
by detroitcoder on Wednesday August 16, 2017 @10:18AM
(#15027627)
This looks very interesting. I am reading the docs https://pythonhosted.org/joblib/parallel.html#manual-managem... and it looks like it would help a lot (possibly solve the issue). Do you have any experience using this in production?
Re:Let's Remove the Global Interpreter Lock
by detroitcoder on Wednesday August 16, 2017 @12:00PM
(#15028534)
DAMN. I just did a basic test and it kinnda just worked?!? I created a test dataframe of 100M rows X 10 cols which took up ~2.3G and then used joblib.dump within the on_starting hook which is run when the gunicorn master starts up. Then loaded that df in with joblib.load within the worker and the total memory consumption was practically flat. Then I bumped up the number of workers to 20 and still flat. That is actually amazing. Coolest thing I have seen in months for how easy it is. Now I have to test out if the analytics actually work and a deep dive into the mechanics of mem-mapping.
Save the dataframe in a folder that can be accessed by the gunicorn worker:
Then in the code run by the flask / gunicorn workers themselves: Some pandas function can have issues with read-only buffer though: https://github.com/pandas-dev/pandas/issues/17192 (caused by a currently unsolved bug / limitation of Cython) but it can work for your use case.