Skip to content

Conversation

@bashtanov
Copy link
Contributor

Currently serde supports classes not based on serde::envelope. These still need version and compat_version static members, but serde reads/writes them in automatic mode, instead of serde_field() it uses reflection. Remove such classes and support for them.

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

To remove serde dependency on refelction in future
There is support for classes that can be written/read by serde, but do
not depend on serde::envelope. These still need version and
compat_version static members, but when read/written in automatic mode
instead of serde_field() rely on reflection. Remove such support.
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 removes support for serde classes that don't inherit from serde::envelope but instead use manual version declarations with reflection-based serialization. The change simplifies the serde implementation by requiring all serializable types to properly inherit from serde::envelope.

Key changes:

  • Removed the inherits_from_envelope concept and related reflection-based serialization paths
  • Converted manual serde structs (segment_meta, segment_meta_v0, segment_meta_v1) to properly inherit from serde::envelope
  • Updated the is_envelope concept to check for inheritance rather than just version member presence

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/serde/envelope.h Simplified is_envelope concept to check inheritance flag; removed inherits_from_envelope concept
src/v/serde/envelope_for_each_field.h Removed reflection-based code paths and dependencies
src/v/serde/BUILD Removed dependencies on reflection utilities (arity, to_tuple)
src/v/serde/test/serde_test.cc Removed test struct test_msg1_new_manual and related tests; updated references to use envelope-based types
src/v/serde/test/fuzz.cc Replaced reflection-based arity calculation with tuple size from serde_fields()
src/v/cloud_storage/types.h Converted segment_meta to inherit from serde::envelope and added serde_fields() method
src/v/cloud_storage/tests/partition_manifest_test.cc Converted segment_meta_v0 and segment_meta_v1 to inherit from serde::envelope
src/v/cloud_storage/segment_meta_cstore.cc Updated arity check to use tuple size from serde_fields() instead of reflection

@bashtanov bashtanov changed the title Serde remove reflection Serde: do not use reflection Jan 6, 2026
Copy link
Member

@oleiman oleiman left a comment

Choose a reason for hiding this comment

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

lgtm

@vbotbuildovich
Copy link
Collaborator

CI test results

test results on build#78592
test_class test_method test_arguments test_kind job_url test_status passed reason test_history
MountUnmountIcebergTest test_simple_remount {"cloud_storage_type": 1} integration https://buildkite.com/redpanda/redpanda/builds/78592#019b948c-d372-4133-af31-237d3e7a3b05 FLAKY 9/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.2020, p0=0.8952, reject_threshold=0.0100. adj_baseline=0.4918, p1=0.0123, 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

std::apply(
[&](auto&&... args) { (fn(args), ...); }, reflection::to_tuple(t));
}
std::apply([&](auto&&... args) { (fn(args), ...); }, envelope_to_tuple(t));
Copy link
Member

Choose a reason for hiding this comment

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

serde: do not use reflection, require classes to inherit envelope

i don't think we have to inherit from envelope, right? i'm pretty sure we have some types that manually add the same metadata that the envelop would otherwise inject. if you want to make this a requirement, then maybe we need a static assert? or is there one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't think we have to inherit from envelope, right?

This PR makes it a requirement

if you want to make this a requirement, then maybe we need a static assert? or is there one?

tag_invoke for both read_tag and write_tag still requires is_envelope<std::decay_t<T>>, which now checks class inheritance instead of a duck-typing-style check

i'm pretty sure we have some types that manually add the same metadata that the envelop would otherwise inject.

The first commit of this PR changes them all to inherit from envelope.

Copy link
Member

Choose a reason for hiding this comment

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

duck-typing-style check

yeah i don't really get why we supported this in the first place. some holdover from the ADL -> serde transition or something?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@bashtanov bashtanov merged commit 17c4265 into redpanda-data:dev Jan 8, 2026
21 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.

4 participants