Skip to content

Improve logs and performance

Krzysztof Mochocki requested to merge kmochocki/performance_and_tests into develop

Logs contains now pid of process so it's easier match logs for given request.

Performance fix explanation:

jsonrpcserver underneath performs 3 calls of serializaiton and sorting keys in whole response, here is simple script, that proves it:

from jsonrpcserver import method, dispatch

def custom_serial(_in):
	print(f'custom_serial HERE! {_in=}')
	return ''

@method
def ping(*args, **kwargs):
	return '{"id": "aaaa"}'

in_json = '{"jsonrpc":"2.0","id":1,"method":"ping"}'

print('calling dispatch')
res = dispatch(in_json, serialize=custom_serial)
print('gathering json via `str` conversion')
_ = str(res)

and here is output:

calling dispatch
custom_serial HERE! _in='{"id": "aaaa"}'
custom_serial HERE! _in=OrderedDict([('jsonrpc', '2.0'), ('result', '{"id": "aaaa"}'), ('id', 1)])
gathering json via `str` conversion
custom_serial HERE! _in=OrderedDict([('jsonrpc', '2.0'), ('result', '{"id": "aaaa"}'), ('id', 1)])

This is comparsion of old and implementaion from this MR:

For big blocks

image

For casual traffic

image1

Merge request reports

Loading