Add json_object_array_shrink() (and array_list_shrink()) and use it in json_tokener to minimize the amount of memory used. This results in a 39%-50% reduction in memory use (peak RSS, peak heap usage) on the jc-bench benchmark and 9% shorter runtime.

Also add the json_object_new_array_ext, array_list_new2, and array_list_shrink functions.
This commit is contained in:
Eric Haszlakiewicz
2020-06-20 18:03:04 +00:00
parent 99bb2121c6
commit e26a1195f4
6 changed files with 95 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ Next Release 0.15
Deprecated and removed features:
--------------------------------
...none yet...
* array_list_new() has been deprecated in favor of array_list_new2()
Other changes
--------------
@@ -19,6 +19,12 @@ Other changes
less memory usage.
Memory used just for json_object structures decreased 27%, so use cases
with fewer arrays and/or strings would benefit more.
* Minimize memory usage in array handling in json_tokener by shrinking
arrays to the exact number of elements parsed. On bench/ benchmark:
9% faster test time, 39%(max RSS)-50%(peak heap) less memory usage.
Add json_object_array_shrink() and array_list_shrink() functions.
* Add json_object_new_array_ext(int) and array_list_new_2(int) to allow
arrays to be allocated with the exact size needed, when known.
***