Improving error handing when reading json config#885
Open
kheaactua wants to merge 1 commit intoCOVESA:masterfrom
Open
Improving error handing when reading json config#885kheaactua wants to merge 1 commit intoCOVESA:masterfrom
kheaactua wants to merge 1 commit intoCOVESA:masterfrom
Conversation
kheaactua
commented
Apr 8, 2025
kheaactua
commented
Apr 8, 2025
61dbfad to
6a68bfe
Compare
kheaactua
commented
Apr 8, 2025
f08ca43 to
85542c0
Compare
659cffc to
9f498b9
Compare
9f498b9 to
83a538d
Compare
83a538d to
b51830d
Compare
925003c to
69062b1
Compare
Without mandatory fields set, the previous code would hit many exceptions in the happy load case. Thus, instead of depending on exceptions to detect the existence of keys in the parsed json, this change optionals to check to see whether a key exists. This should improve performance (no stack unrolling for the exception) as well as allows some try/catch blocks to be removed (simpler code.)
69062b1 to
4f71625
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without mandatory fields set, the previous code would hit many exceptions in the happy load case. Thus, instead of depending on exceptions to detect the existence of keys in the parsed json, this change optionals to check to see whether a key exists. This should improve performance* (no stack unrolling for the exception) as well as allows some try/catch blocks to be removed (simpler code.)
Another driver for this change was that 4913ae3 swapped ellipses in the
catchstatements forstd::exception. On the surface this seems like a positive change and even follows compiler warning message recommendations, however for unknown reasons on some platformscatch (std::exception)would catch theboost::property_tree::ptree_bad_pathexceptions thrown byget_child, and on other platforms it wouldn't. Even though there is a proposal to revert that commit (eventually committed in 9259c09), reducing dependence on exceptions in favour of optionals obviates this issue.Not every try/catch block was removed here, simply the ones where there's no conceivable change of an exception being thrown. The blocks surrounding the streamstream converters, and map access were left just in case.
Performance
(Measured in 3.5.5)
Using timing data from the log line
Parsed vsomeip configuration in Xms, I saw the following improvements (sample size of n=1).Notes
clang-formatboost:jsoninternally, so I'm not sure this PR will ever be accepted. In the meantime there it provides great speedups. For 3.5.6 for instance, there was a new block added in the config with the try/catch method, and while I don't know why, that caused one of our apps to slow down by 500ms on startup. I fixed up that block and the time it took to parse the config fell back to 9ms.