summaryrefslogtreecommitdiff
path: root/lib/automake.mk
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@ovn.org>2021-08-24 23:07:22 +0200
committerIlya Maximets <i.maximets@ovn.org>2021-08-31 19:04:08 +0200
commit748010ff304b7cd2c43f4eb98a554433f0df07f9 (patch)
treed013ed694c9c12a6ce6e42ee666322d002ed4c50 /lib/automake.mk
parent7847bf89eaa03a41652b4dbf1bc6b2f980f7c743 (diff)
downloadopenvswitch-748010ff304b7cd2c43f4eb98a554433f0df07f9.tar.gz
json: Optimize string serialization.
Current string serialization code puts all characters one by one. This is slow because dynamic string needs to perform length checks on every ds_put_char() and it's also doesn't allow compiler to use better memory copy operations, i.e. doesn't allow copying few bytes at once. Special symbols are rare in a typical database. Quotes are frequent, but not too frequent. In databases created by ovn-kubernetes, for example, usually there are at least 10 to 50 chars between quotes. So, it's better to count characters that doesn't require escaping and use fast data copy for the whole sequential block. Testing with a synthetic benchmark (included) on my laptop shows following performance improvement: Size Q S Before After Diff ----------------------------------------------------- 100000 0 0 : 0.227 ms 0.142 ms -37.4 % 100000 2 1 : 0.277 ms 0.186 ms -32.8 % 100000 10 1 : 0.361 ms 0.309 ms -14.4 % 10000000 0 0 : 22.720 ms 12.160 ms -46.4 % 10000000 2 1 : 27.470 ms 19.300 ms -29.7 % 10000000 10 1 : 37.950 ms 31.250 ms -17.6 % 100000000 0 0 : 239.600 ms 126.700 ms -47.1 % 100000000 2 1 : 292.400 ms 188.600 ms -35.4 % 100000000 10 1 : 387.700 ms 321.200 ms -17.1 % Here Q - probability (%) for a character to be a '\"' and S - probability (%) to be a special character ( < 32). Testing with a closer to real world scenario shows overall decrease of the time needed for database compaction by ~5-10 %. And this change also decreases CPU consumption in general, because string serialization is used in many different places including ovsdb monitors and raft. Signed-off-by: Ilya Maximets <i.maximets@ovn.org> Acked-by: Numan Siddique <numans@ovn.org> Acked-by: Dumitru Ceara <dceara@redhat.com>
Diffstat (limited to 'lib/automake.mk')
0 files changed, 0 insertions, 0 deletions