diff options
author | Rodriguez Betancourt, Esteban <estebarb@hpe.com> | 2016-10-04 19:31:48 +0000 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2016-10-04 16:04:25 -0700 |
commit | 9854d473adea37f3cc6432017bd38511473ae5a1 (patch) | |
tree | 0bddcd3117ad9e34c09d631f22bc298cad14f86b /include/openvswitch/json.h | |
parent | 2e3cf773eac1aaa05dda309da7bd1954d5e7b379 (diff) | |
download | openvswitch-9854d473adea37f3cc6432017bd38511473ae5a1.tar.gz |
json: Use reference counting in JSON objects
After profiling OVSDB insert performance it was found
that some significant portion of its time OVSDB is
calling the function json_clone.
Also, the current usages of json_clone never modify the json,
just keeps it to prevent it to be freed.
With that in mind the struct json, json_create, json_clone
and json_destroy were modified to keep a count of how many
references of the json struct are left. Only when that count
reaches zero the json struct is freed.
The old "json_clone" function was renamed as "json_deep_clone".
Some examples of the performance difference:
In these tests a test table with 4 columns (string, string,
bool, integer) was used. All the tests used "commit block".
*** 50 process each inserting 1000 rows ***
Master OVS
Test Duration 131 seconds
Average Inserts Per second 746.2687 inserts/s
Average Insert Duration 134.1382 ms
Minimal Insert Duration 0.166202 ms
Maximum Insert Duration 489.8593 ms
JSON GC Patch
Test Duration 86 seconds
Average Inserts Per second 1176 inserts/s
Average Insert Duration 82.26761 ms
Minimal Insert Duration 0.165448 ms
Maximum Insert Duration 751.2111 ms
*** 5 process each inserting 10000 rows ***
Master OVS
Test Duration 8 seconds
Average Inserts Per second 7142.857 inserts/s
Average Insert Duration 0.656431 ms
Minimal Insert Duration 0.125197 ms
Maximum Insert Duration 11.93203 ms
JSON GC Patch
Test Duration 7 seconds
Average Inserts Per second 8333.333 inserts/s
Average Insert Duration 0.55688 ms
Minimal Insert Duration 0.143233 ms
Maximum Insert Duration 26.26319 ms
Signed-off-by: Esteban Rodriguez Betancourt <estebarb@hpe.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'include/openvswitch/json.h')
-rw-r--r-- | include/openvswitch/json.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/openvswitch/json.h b/include/openvswitch/json.h index 13f346cc2..83775ed0e 100644 --- a/include/openvswitch/json.h +++ b/include/openvswitch/json.h @@ -63,6 +63,7 @@ struct json_array { /* A JSON value. */ struct json { enum json_type type; + size_t count; union { struct shash *object; /* Contains "struct json *"s. */ struct json_array array; @@ -99,6 +100,7 @@ bool json_boolean(const struct json *); double json_real(const struct json *); int64_t json_integer(const struct json *); +struct json *json_deep_clone(const struct json *); struct json *json_clone(const struct json *); void json_destroy(struct json *); |