Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improve C++ JSON parsing performance#4203

Merged
chriche-ms merged 3 commits into
microsoft:mainfrom
chriche-ms:chriche/uwp_performance_jsonparse
Jun 23, 2020
Merged

Improve C++ JSON parsing performance#4203
chriche-ms merged 3 commits into
microsoft:mainfrom
chriche-ms:chriche/uwp_performance_jsonparse

Conversation

@chriche-ms

@chriche-ms chriche-ms commented Jun 22, 2020

Copy link
Copy Markdown
Member

Related Issue

Resolves #4202

Description

This PR modifies the ParseUtil::GetJsonValueFromString function to improve JSON parsing performance. The replaced code used a stream extraction operator (i.e. >>) to convert the passed string into a Json::Value instance. While this code was straightforward and easy to understand it required the string data to be copied into a stringstream (twice) and then copied back into a string before parsing could begin. The updated code creates a Json::CharReader directly to avoid these copies.

How Verified

The changes mean that the GetJsonValueFromString function goes from being around 10% of CPU samples to 4% of samples when profiling adaptive card parsing and rendering.

Microsoft Reviewers: Open in CodeFlow

@chriche-ms chriche-ms requested a review from paulcam206 June 22, 2020 11:47
@chriche-ms chriche-ms self-assigned this Jun 22, 2020
@shalinijoshi19

shalinijoshi19 commented Jun 22, 2020

Copy link
Copy Markdown

Very neat. Thanks for finding and fixing! Btw do you have actually have a sample card here that you used in the before/after comparisons that you could share? @paulcam206 / @RebeccaAnne what would be a good place to house such a perf scenario test card? Someplace here - source\uwp\PerfApp? Or inthe scenarios folder as a Perf scenario?

@shalinijoshi19 shalinijoshi19 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@chriche-ms chriche-ms merged commit e297240 into microsoft:main Jun 23, 2020
@chriche-ms chriche-ms deleted the chriche/uwp_performance_jsonparse branch June 23, 2020 15:45
chriche-ms added a commit to chriche-ms/AdaptiveCards that referenced this pull request Jun 24, 2020
chriche-ms added a commit that referenced this pull request Jun 30, 2020
… operator for performance reasons (#4203) (#4220)

Co-authored-by: Paul Campbell <[email protected]>
@shalinijoshi19 shalinijoshi19 added this to the 20.06 milestone Jul 10, 2020
rankush pushed a commit to rankush/AdaptiveCards that referenced this pull request May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UWP] JSON parsing performance

4 participants