Remove redundant call to Serialize() in ConfigItem::Commit() #9362
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.
The very same object is already serialized a few lines above, the result is even stored in a variable, but that variable was not used before. Simply using this variable results in a noticeable improvement of config validation times.
Eyeball statistics on the tests below show around a 13% improvement, exact numbers will vary depending on the config. The improvement will be smaller if there are more complex things in the config (like lots of apply rules) on the other hand, the objects in the config aren't that hard to serialize (you would probably see some more improvement with complex custom variables). But I'd say some 5% to 10% improvement is totally possible for real configs.
Test
Super trivial config showing the effect quite well:
Run
icinga2 daemon -C
a few times on this config.Before
Full Output
After
Full Output