Skip to content

Decorator: move CsProtocol::Value temporaries into ext maps instead of copying#1498

Open
bmehta001 wants to merge 2 commits into
microsoft:mainfrom
bmehta001:bhamehta/perf-decorator-move
Open

Decorator: move CsProtocol::Value temporaries into ext maps instead of copying#1498
bmehta001 wants to merge 2 commits into
microsoft:mainfrom
bmehta001:bhamehta/perf-decorator-move

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

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 B extPartB map) and then copy-assigned it into the ext / extPartB maps:

CsProtocol::Value temp;
temp.stringValue = v.to_string();
ext[k] = temp;            // copy of a heavy type

Each temp is a local that is never used after insertion, so it is now moved:

ext[k] = std::move(temp);

CsProtocol::Value is a heavy type (vectors of attributes/PII + strings), and this is on the per-event decorate hot path. The final partBdata.properties = extPartB and its baseData.push_back are moved too.

This is a pure move-instead-of-copy of throwaway locals — no interface or behavior change.

Tests

  • EventProperties decorator/serialization tests: 54/54 pass (full WSL UnitTests suite also green).

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>
@bmehta001 bmehta001 requested a review from a team as a code owner June 23, 2026 05:37
@bmehta001 bmehta001 requested a review from Copilot June 23, 2026 05:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 extPartB into partBdata.properties, and move partBdata into record.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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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.

2 participants