pypy 2.3.1 json encoding performnce is Extremely slow (30x slower ).

$ pypy benchmark.py Array with 256 doubles: json encode : 5044.67291 calls/sec json decode : 19591.44018 calls/sec Array with 256 utf-8 strings: json decode UTF : 71.03748 calls/sec json decode UTF : 482.03748 calls/sec $ /usr/bin/python benchmark.py Array with 256 doubles: json encode : 4292.39818 calls/sec json decode : 15089.87792 calls/sec Array with 256 utf-8 strings: json encode UTF : 2062.16175 calls/sec json decode UTF : 479.04892 calls/sec Test using ultra json: $ /usr/bin/python ujson/test/benchmark.py Array with 256 doubles: ujson encode : 4386.51907 calls/sec simplejson encode : 4269.30241 calls/sec yajl encode : 4268.15286 calls/sec ujson decode : 23814.23743 calls/sec simplejson decode : 15375.76992 calls/sec yajl decode : 15388.19165 calls/sec Array with 256 utf-8 strings: ujson encode : 4114.12586 calls/sec simplejson encode : 1965.17111 calls/sec yajl encode : 1964.98007 calls/sec ujson decode : 1237.99751 calls/sec simplejson decode : 440.96787 calls/sec yajl decode : 440.53785 calls/sec Ofcoz it is not fair comparing against Ultra json but there is no real performance increase vs vanilla python's json

Hi Phyo, Thanks for the report! I may have fixed it in e80c25f01061. Please try it out with tomorrow's nightly build. A bientôt, Armin.

Thanks a lot! i am waiting to switch to PyPy. Also there is one performance problem. I haven't profile it properly yet just from looking at Chrome DEV Console. A simple Tornado async (callback) + pymongo + motor + reading 100 records from db and returning them in json , in Python its takes only 1 ms in Pypy it takes 4-6 ms I will make proper benchmark on it when i get time. and find which part is slowing down. But may be you can guess where it is slowing? On Fri, Aug 29, 2014 at 10:34 PM, Armin Rigo <arigo@tunes.org> wrote:

FWIW, I'm not sure your commit helped, at least, it seems to be worse for some usecases: (PyPy default vs 2.3.1): $ ./pypy-c -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 1.09 msec per loop $ ./pypy-c -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 1.1 msec per loop $ ./pypy-c -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 1.11 msec per loop $ pypy -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000}) 1000 loops, best of 3: 503 usec per loop $ pypy -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 491 usec per loop $ pypy -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 498 usec per loop Alex On Fri, Aug 29, 2014 at 9:52 AM, Phyo Arkar <phyo.arkarlwin@gmail.com> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

Hi Alex, On 30 August 2014 00:09, Alex Gaynor <alex.gaynor@gmail.com> wrote:
FWIW, I'm not sure your commit helped, at least, it seems to be worse for some usecases: (PyPy default vs 2.3.1):
Ah. Yes, my commit helped really a lot: $ ./pypy-c -mtimeit -s"import json;x=u'\u1234'*10000" "json.dumps(x)" went down from 5.8ms per loop to 208us. However, I see that running the same example with 10000 ascii chars went up from 41.4us to 139us. Time to tweak. Armin

Hi Alex, On 30 August 2014 08:43, Armin Rigo <arigo@tunes.org> wrote:
Tweaked! See 65ac482d28d6. This was because if you used this kind of code in RPython: for c in unistring: if c >= u' ': ... then the comparison works, but is done by converting the character back to a full unicode string and calling ll_strcmp()... so the big overhead was caused half by the conversion costs and half by the extra GC pressure. A bientôt, Armin.

Wow, nice catch! Alex On Mon, Sep 1, 2014 at 3:31 AM, Armin Rigo <arigo@tunes.org> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

Thanks a lot. I haven't get to test lastest commit yet. So in that , attached benchmark in pypy is running faster than python now? On Mon, Sep 1, 2014 at 5:01 PM, Armin Rigo <arigo@tunes.org> wrote:

Hi, On 1 September 2014 17:06, Phyo Arkar <phyo.arkarlwin@gmail.com> wrote:
Thanks a lot. I haven't get to test lastest commit yet. So in that , attached benchmark in pypy is running faster than python now?
Yes, for the utf-8 test (the tests with "double" didn't change). Here is what I get on Linux 64: $ pypy-c-r73264-jit benchmark.py Array with 256 doubles: simplejson encode : 3871.15257 calls/sec simplejson decode : 14651.04979 calls/sec Array with 256 utf-8 strings: simplejson encode UTF : 1393.29238 calls/sec simplejson decode UTF : 276.03465 calls/sec $ python benchmark.py # 2.7.3 Array with 256 doubles: simplejson encode : 3469.44902 calls/sec simplejson decode : 12419.69240 calls/sec Array with 256 utf-8 strings: simplejson encode UTF : 1278.32368 calls/sec simplejson decode UTF : 355.18049 calls/sec A bientôt, Armin.

Hi Phyo, Thanks for the report! I may have fixed it in e80c25f01061. Please try it out with tomorrow's nightly build. A bientôt, Armin.

Thanks a lot! i am waiting to switch to PyPy. Also there is one performance problem. I haven't profile it properly yet just from looking at Chrome DEV Console. A simple Tornado async (callback) + pymongo + motor + reading 100 records from db and returning them in json , in Python its takes only 1 ms in Pypy it takes 4-6 ms I will make proper benchmark on it when i get time. and find which part is slowing down. But may be you can guess where it is slowing? On Fri, Aug 29, 2014 at 10:34 PM, Armin Rigo <arigo@tunes.org> wrote:

FWIW, I'm not sure your commit helped, at least, it seems to be worse for some usecases: (PyPy default vs 2.3.1): $ ./pypy-c -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 1.09 msec per loop $ ./pypy-c -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 1.1 msec per loop $ ./pypy-c -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 1.11 msec per loop $ pypy -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000}) 1000 loops, best of 3: 503 usec per loop $ pypy -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 491 usec per loop $ pypy -mtimeit -s "import json" "json.dumps({u'': u'abcdef' * 10000})" 1000 loops, best of 3: 498 usec per loop Alex On Fri, Aug 29, 2014 at 9:52 AM, Phyo Arkar <phyo.arkarlwin@gmail.com> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

Hi Alex, On 30 August 2014 00:09, Alex Gaynor <alex.gaynor@gmail.com> wrote:
FWIW, I'm not sure your commit helped, at least, it seems to be worse for some usecases: (PyPy default vs 2.3.1):
Ah. Yes, my commit helped really a lot: $ ./pypy-c -mtimeit -s"import json;x=u'\u1234'*10000" "json.dumps(x)" went down from 5.8ms per loop to 208us. However, I see that running the same example with 10000 ascii chars went up from 41.4us to 139us. Time to tweak. Armin

Hi Alex, On 30 August 2014 08:43, Armin Rigo <arigo@tunes.org> wrote:
Tweaked! See 65ac482d28d6. This was because if you used this kind of code in RPython: for c in unistring: if c >= u' ': ... then the comparison works, but is done by converting the character back to a full unicode string and calling ll_strcmp()... so the big overhead was caused half by the conversion costs and half by the extra GC pressure. A bientôt, Armin.

Wow, nice catch! Alex On Mon, Sep 1, 2014 at 3:31 AM, Armin Rigo <arigo@tunes.org> wrote:
-- "I disapprove of what you say, but I will defend to the death your right to say it." -- Evelyn Beatrice Hall (summarizing Voltaire) "The people's good is the highest law." -- Cicero GPG Key fingerprint: 125F 5C67 DFE9 4084

Thanks a lot. I haven't get to test lastest commit yet. So in that , attached benchmark in pypy is running faster than python now? On Mon, Sep 1, 2014 at 5:01 PM, Armin Rigo <arigo@tunes.org> wrote:

Hi, On 1 September 2014 17:06, Phyo Arkar <phyo.arkarlwin@gmail.com> wrote:
Thanks a lot. I haven't get to test lastest commit yet. So in that , attached benchmark in pypy is running faster than python now?
Yes, for the utf-8 test (the tests with "double" didn't change). Here is what I get on Linux 64: $ pypy-c-r73264-jit benchmark.py Array with 256 doubles: simplejson encode : 3871.15257 calls/sec simplejson decode : 14651.04979 calls/sec Array with 256 utf-8 strings: simplejson encode UTF : 1393.29238 calls/sec simplejson decode UTF : 276.03465 calls/sec $ python benchmark.py # 2.7.3 Array with 256 doubles: simplejson encode : 3469.44902 calls/sec simplejson decode : 12419.69240 calls/sec Array with 256 utf-8 strings: simplejson encode UTF : 1278.32368 calls/sec simplejson decode UTF : 355.18049 calls/sec A bientôt, Armin.
participants (3)
-
Alex Gaynor
-
Armin Rigo
-
Phyo Arkar