Skip to content

Conversation

@andrwng
Copy link
Contributor

@andrwng andrwng commented Jan 14, 2026

The underlying iobufs aren't mutated, and don't have a hard requirement to be called from a const context. As such, swaps over to sharing instead of copying.

Follow up from #29161 and #29160

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v25.3.x
  • v25.2.x
  • v25.1.x

Release Notes

  • None

The underlying iobufs aren't mutated, and don't have a hard requirement
to be called from a const context. As such, swaps over to sharing
instead of copying.
Copilot AI review requested due to automatic review settings January 14, 2026 00:37
Copy link
Contributor

Copilot AI left a comment

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 memory usage by replacing copy() operations with share() operations for iobuf instances in the LSM (Log-Structured Merge-tree) implementation. Since the underlying iobufs are not mutated and don't require const contexts, sharing is more efficient than copying.

Changes:

  • Renamed methods from copy() to share() across multiple structs (lsm_state, serialized_manifest, apply_write_batch_update)
  • Removed const qualifiers from methods and parameters that previously enforced const semantics but are no longer needed
  • Added mutable_state() accessor to the STM class to support non-const access

Reviewed changes

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

Show a summary per file
File Description
src/v/cloud_topics/level_one/metastore/lsm/stm.h Added mutable_state() accessor and removed const from make_snapshot()
src/v/cloud_topics/level_one/metastore/lsm/stm.cc Changed snapshot creation to use share() instead of copy()
src/v/cloud_topics/level_one/metastore/lsm/state.h Renamed copy() methods to share() in lsm_state and serialized_manifest
src/v/cloud_topics/level_one/metastore/lsm/state.cc Updated implementations to use share() and removed const qualifiers
src/v/cloud_topics/level_one/metastore/lsm/replicated_persistence.cc Updated to use mutable_state() and share() for accessing persisted manifest
src/v/cloud_topics/level_one/metastore/lsm/replicated_db.cc Changed write batch serialization to use share()
src/v/cloud_topics/level_one/metastore/lsm/lsm_update.h Renamed copy() to share() in apply_write_batch_update
src/v/cloud_topics/level_one/metastore/lsm/lsm_update.cc Updated implementation to use share() and removed const qualifiers

@vbotbuildovich
Copy link
Collaborator

CI test results

test results on build#78995
test_class test_method test_arguments test_kind job_url test_status passed reason test_history
DataMigrationsMultiClusterTest test_with_consumer_groups null integration https://buildkite.com/redpanda/redpanda/builds/78995#019bb9f7-7848-4746-9ae1-aa550456f4bc FLAKY 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0000, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=DataMigrationsMultiClusterTest&test_method=test_with_consumer_groups
MountUnmountIcebergTest test_simple_remount {"cloud_storage_type": 1} integration https://buildkite.com/redpanda/redpanda/builds/78995#019bb9f7-7850-46db-ae7f-a4fe29c96528 FLAKY 7/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.1896, p0=0.2910, reject_threshold=0.0100. adj_baseline=0.4677, p1=0.2299, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=MountUnmountIcebergTest&test_method=test_simple_remount

@andrwng andrwng merged commit 93b494b into redpanda-data:dev Jan 14, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants