Skip to content

Avoid some copies in Keeper#85131

Merged
antonio2368 merged 3 commits intomasterfrom
keeper-avoid-some-copies
Aug 8, 2025
Merged

Avoid some copies in Keeper#85131
antonio2368 merged 3 commits intomasterfrom
keeper-avoid-some-copies

Conversation

@antonio2368
Copy link
Copy Markdown
Member

@antonio2368 antonio2368 commented Aug 6, 2025

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh Bot commented Aug 6, 2025

Workflow [PR], commit [8ef1bb0]

Summary:

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 6, 2025
@vdimir vdimir self-assigned this Aug 6, 2025
Comment thread src/Coordination/KeeperStorage.cpp Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why can we move(children)? Doesn't it make the current object malformed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In shallowCopy we copy stats but not children, so getChildren on on object with was obtained via shallowCopy will trigger assert, is it intended?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is a bit hacky, when creating snapshot we don't iterate children.
If snapshot is being made, each update of a node will create a copy first and then update it.
Snapshot will use the old node, while every new operation will use new node.
So that's why we can move children from the snapshotted node, we don't need it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This deserves a comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As a safety I added asserts on children getters (getChildren)

@antonio2368 antonio2368 force-pushed the keeper-avoid-some-copies branch 3 times, most recently from 672e894 to 09f736f Compare August 6, 2025 10:00
@antonio2368 antonio2368 force-pushed the keeper-avoid-some-copies branch from 09f736f to 8c6f6dd Compare August 6, 2025 12:58
@antonio2368 antonio2368 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 7, 2025
@antonio2368 antonio2368 requested a review from vdimir August 7, 2025 10:47
@alexey-milovidov alexey-milovidov removed the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 7, 2025
@alexey-milovidov
Copy link
Copy Markdown
Member

@antonio2368 Wrong category.

@antonio2368 antonio2368 added this pull request to the merge queue Aug 8, 2025
@antonio2368 antonio2368 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 8, 2025
Merged via the queue into master with commit 6f8d0fe Aug 8, 2025
124 checks passed
@antonio2368 antonio2368 deleted the keeper-avoid-some-copies branch August 8, 2025 09:37
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 8, 2025
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Aug 8, 2025
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 8, 2025
clickhouse-gh Bot added a commit that referenced this pull request Aug 8, 2025
Backport #85131 to 25.7: Avoid some copies in Keeper
clickhouse-gh Bot added a commit that referenced this pull request Aug 8, 2025
Backport #85131 to 25.6: Avoid some copies in Keeper
antonio2368 added a commit that referenced this pull request Aug 11, 2025
Backport #85131 to 25.3: Avoid some copies in Keeper
antonio2368 added a commit that referenced this pull request Aug 11, 2025
Backport #85131 to 25.5: Avoid some copies in Keeper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-backports-created-cloud deprecated label, NOOP pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants