Decorator: move CsProtocol::Value temporaries into ext maps instead of copying#1498
Open
bmehta001 wants to merge 2 commits into
Open
Decorator: move CsProtocol::Value temporaries into ext maps instead of copying#1498bmehta001 wants to merge 2 commits into
bmehta001 wants to merge 2 commits into
Conversation
EventPropertiesDecorator builds a throwaway CsProtocol::Value (or the Part B map) for every event property and copy-assigned it into the ext/extPartB maps. Each value is a local that is not used after insertion, so move it instead of copying. CsProtocol::Value is a heavy type (vectors of attributes/PII plus strings), and this runs on the per-event decorate path. Pure move-instead-of-copy of throwaway locals; no interface or behavior change. EventProperties decorator/serialization tests (54) pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the EventPropertiesDecorator hot path by moving temporary CsProtocol::Value (and Part B properties) into the destination maps/vectors instead of copy-assigning, reducing per-event copying of a heavy value type.
Changes:
- Replace
ext[k] = temp;/extPartB[k] = temp;with move assignment from the temporary (std::move(temp)). - Move
extPartBintopartBdata.properties, and movepartBdataintorecord.baseData.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
188
to
195
| if (v.dataCategory == DataCategory_PartB) | ||
| { | ||
| extPartB[k] = temp; | ||
| extPartB[k] = std::move(temp); | ||
| } | ||
| else | ||
| { | ||
| ext[k] = temp; | ||
| ext[k] = std::move(temp); | ||
| } |
The decorator now uses std::move; add the explicit <utility> include instead of relying on transitive includes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Per-event performance fix in
EventPropertiesDecorator(no behavior change).For every event property, the decorator builds a throwaway
CsProtocol::Value temp(or the Part BextPartBmap) and then copy-assigned it into theext/extPartBmaps:CsProtocol::Value temp; temp.stringValue = v.to_string(); ext[k] = temp; // copy of a heavy typeEach
tempis a local that is never used after insertion, so it is now moved:CsProtocol::Valueis a heavy type (vectors of attributes/PII + strings), and this is on the per-event decorate hot path. The finalpartBdata.properties = extPartBand itsbaseData.push_backare moved too.This is a pure move-instead-of-copy of throwaway locals — no interface or behavior change.
Tests
UnitTestssuite also green).