This is an archive of the discontinued LLVM Phabricator instance.

[Support][JSON] Add reserve() to json Array
ClosedPublic

Authored by anton-afanasyev on Apr 16 2019, 11:11 AM.

Details

Summary

Space reservation increases json lib performance for the arrays with large number of entries.
Here is an example and discussion: https://reviews.llvm.org/D60609#1468941.
In short: there is json array with ~32K entries, one can build it using llvm::json::Array by pushing back each entry.
This pushing takes ~4% of whole time compared to the method of preliminary memory reservation: (3995-3845)/3995 = 3.75%.

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2019, 11:11 AM

As i have previously discussed in IRC with @sammccall this change needs motivational numbers.
Just copying them (+methodology) from https://reviews.llvm.org/D60609#inline-538565 sounds good.
-5.5% sounds rather great to me.

anton-afanasyev edited the summary of this revision. (Show Details)Apr 16 2019, 12:09 PM

As i have previously discussed in IRC with @sammccall this change needs motivational numbers.
Just copying them (+methodology) from https://reviews.llvm.org/D60609#inline-538565 sounds good.
-5.5% sounds rather great to me.

Ok, updated summary.

lebedev.ri edited the summary of this revision. (Show Details)Apr 16 2019, 12:23 PM
sammccall accepted this revision.Apr 16 2019, 12:38 PM

Thanks for gathering the numbers here, it is really useful to see how people are using this in performance-sensitive contexts. Definitely makes sense to fix this.

This revision is now accepted and ready to land.Apr 16 2019, 12:38 PM
This revision was automatically updated to reflect the committed changes.