[pypy-dev] pypy, vmprof and mpmath

Ronan Lamy ronan.lamy at gmail.com
Mon Nov 19 15:12:16 EST 2018


Le 17/11/18 à 15:39, Kris Kuhlman a écrit :
> I am using pypy to run numerical integration calculations with the 
> arbitrary precision library mpmath (http://mpmath.org).
> 
> I am using pypy2-v6.0.0-osx64 and version 1.0 of mpmath (from github). I 
> install mpmath with pypy and use the native (python only) version; I am 
> not using the gmp backend.
> 
> I have noticed that sometimes seemingly small changes in my scripts 
> result in big changes in runtime with pypy, and I was wondering if there 
> were some jit options or settings I could change to improve things.  
> Following advice from the pypy website, I tried using vmprof to profile 
> one of my scripts.
> 
> I installed vmprof into pypy using pip, starting with "pypy -m ensurepip".
> 
> First I tried to run one of my scripts with vmprof, which typically take 
> <10 minutes to run, but it ran for a few hours and so I eventually 
> killed it (it doesn't respond to ^C, so I have to put it into the 
> background and kill it explicitly with the kill command).
> 
> Then I tried just a small test script like the following:
> 
> cat -> test.py
> import mpmath as mp
> print mp.pi
> ^D
> 
> This runs fine from pypy as:
> 
> $pypy test.py
> 
>>3.14159265358979
> 
> 
> 
> but running this same script using vmprof and pypy as
> 
> 
> pypy -m vmprof -o output.log test.py
> 
> 
> uses 4GB of ram, 100% processor, and if left running will generate a 
> output.log file of growing size (so I kill it).
> 
> 
> If I run the following:
> 
> 
> cat -> test2.py
> 
> x = 3.14159
> 
> print x
> 
> ^D
> 
> 
> vmprof runs quickly and generates a small output.log file (~400kb). As 
> an aside, if I try to use the --web option, it hangs on "Uploading to 
> http://vmprof.com..."  If I try to go to this website in my browser 
> there is an error page about bad gateway from Cloudflare.
> 
> 
> I seem to be able to use mpmath with pypy just fine, but the combination 
> of pypy, mpmath, and vmprof seems to not work.
> 
> 
> Any suggestions?  I am not an experienced vmprof user.
> 
I tried your test script on Linux and everything works as expected 
locally. So I guess the issue is specific to OS X, or to your own system.

Try using the --no-native option, as in 'pypy -m vmprof -o output.log 
--no-native test.py'. That should disable most of the platform-specific 
code, and it doesn't lose much information on pypy anyway.




More information about the pypy-dev mailing list