While I was working on #6655, I found out that json_serialize and json methods are slow. We should apply similar techniques to increase performace of json_serialize.
The json methods perform too much work. Some call json_serialize although the results are later passed into json_serialize again.
127.0.0.1 - - [15/Feb/2017 21:26:43] "POST /ipa/session/json HTTP/1.1" 200 - ipa: INFO: [jsonserver_session] admin@IPA.EXAMPLE: json_metadata(None, None, command=u'all', version=u'2.218'): SUCCESS -------------------------------------------------------------------------------- PATH: '/session/json' 2340515 function calls (2131924 primitive calls) in 1.142 seconds Ordered by: internal time, call count List reduced from 432 to 30 due to restriction <30> ncalls tottime percall cumtime percall filename:lineno(function) 3556 0.201 0.000 0.452 0.000 /home/heimes/redhat/freeipa/ipalib/parameters.py:441(__init__) 187490/446 0.148 0.000 1.004 0.002 /home/heimes/redhat/freeipa/ipalib/util.py:58(json_serialize) 718435 0.135 0.000 0.135 0.000 {isinstance} 3999 0.085 0.000 0.256 0.000 /home/heimes/redhat/freeipa/ipalib/parameters.py:954(__json__) 173558 0.076 0.000 0.076 0.000 {hasattr} 143774/143772 0.053 0.000 0.053 0.000 /home/heimes/redhat/freeipa/ipalib/base.py:123(__setattr__) 104200 0.037 0.000 0.072 0.000 {setattr} 1 0.032 0.032 0.032 0.032 {built-in method sasl_interactive_bind_s} 4450/1 0.031 0.000 0.049 0.049 /home/heimes/redhat/freeipa/ipalib/rpc.py:388(_enc_dict) 234842 0.026 0.000 0.027 0.000 {getattr} 4445/446 0.025 0.000 0.460 0.001 /home/heimes/redhat/freeipa/ipalib/util.py:62(<dictcomp>) 234451 0.019 0.000 0.019 0.000 {method 'get' of 'dict' objects} 1 0.018 0.018 0.018 0.018 /usr/lib64/python2.7/json/encoder.py:212(iterencode) 13038/892 0.015 0.000 0.047 0.000 /home/heimes/redhat/freeipa/ipalib/rpc.py:380(_enc_list) 3556 0.012 0.000 0.012 0.000 /home/heimes/redhat/freeipa/ipalib/parameters.py:261(parse_param_spec) 24961 0.012 0.000 0.012 0.000 {_codecs.utf_8_decode} 24961 0.011 0.000 0.030 0.000 {method 'decode' of 'str' objects} 107753 0.010 0.000 0.010 0.000 /home/heimes/redhat/freeipa/ipalib/parameters.py:506(<genexpr>) 7176 0.008 0.000 0.012 0.000 /home/heimes/redhat/freeipa/ipalib/text.py:248(as_unicode) 1973 0.007 0.000 0.273 0.000 /home/heimes/redhat/freeipa/ipalib/parameters.py:725(clone_retype) 24961 0.007 0.000 0.019 0.000 /usr/lib64/python2.7/encodings/utf_8.py:15(decode) 7388 0.006 0.000 0.006 0.000 {method 'match' of '_sre.SRE_Pattern' objects} 9958/9062 0.006 0.000 0.009 0.000 /home/heimes/redhat/freeipa/ipalib/util.py:846(__get__) 77523 0.006 0.000 0.006 0.000 {method 'pop' of 'dict' objects} 1975 0.006 0.000 0.273 0.000 /home/heimes/redhat/freeipa/ipalib/parameters.py:1433(__init__) 7565 0.006 0.000 0.006 0.000 /usr/lib64/python2.7/re.py:230(_compile) 1 0.006 0.006 0.006 0.006 {method 'encode' of 'str' objects} 3364 0.005 0.000 0.010 0.000 /home/heimes/redhat/freeipa/ipalib/plugable.py:288(__enumerate) 7386 0.005 0.000 0.017 0.000 /usr/lib64/python2.7/re.py:138(match) 7475 0.005 0.000 0.018 0.000 /home/heimes/redhat/freeipa/ipalib/text.py:264(__json__)
Metadata Update from @cheimes: - Issue assigned to someone - Issue set to the milestone: Future Releases
Log in to comment on this ticket.