feat(codecs): make avro codec optional via cargo feature flag#25338
Open
ahachete wants to merge 1 commit intovectordotdev:masterfrom
Open
feat(codecs): make avro codec optional via cargo feature flag#25338ahachete wants to merge 1 commit intovectordotdev:masterfrom
ahachete wants to merge 1 commit intovectordotdev:masterfrom
Conversation
Mirror the existing {arrow,parquet,opentelemetry,syslog} gating
pattern in lib/codecs/Cargo.toml for avro. The apache-avro dependency
and the avro encoder/decoder are now gated behind a new codecs-avro
Cargo feature.
The feature is enabled by default in all release feature aggregators
(base, default-no-api-client, target-* sets). Both sources-pulsar and
sinks-pulsar pull codecs-avro automatically, so default behavior and
shipping releases are unchanged.
Custom builds via --no-default-features that do not enable codecs-avro
(directly or through pulsar) skip compiling apache-avro and the avro
codec implementation, reducing the binary size by ~440 KB on x86_64
on my current setup, against a curated build. YMMV.
Refs vectordotdev#20064.
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
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
Make the
avrocodec optional via a newcodecs-avroCargo feature flag, mirroring the existing gating pattern already used inlib/codecs/Cargo.tomlforarrow,parquet,opentelemetry, andsyslogcodecs.The feature is enabled by default in every release feature aggregator (
base, and transitivelydefault-no-api-client, the per-target release features, etc.). Bothsources-pulsarandsinks-pulsarpullcodecs-avroautomatically. No behavior change for anyone using the default build, the shipping release binaries, or the existing release feature sets.Custom builds via
cargo build --no-default-features --features ...that do not enablecodecs-avro(and do not enablesources-pulsarorsinks-pulsar) skip compilingapache-avroand the avro codec implementation. Measured savings: ~440 KB on the production release profile (opt-level=3, lto=fat, codegen-units=1, panic=abort, strip=symbols) for a curated build.This is a small, self-contained step toward the broader goal in #20064. Quoting @jszwedko in that umbrella issue:
Vector configuration
No configuration change. Existing YAML using
codec: avrocontinues to work becausecodecs-avrois enabled by default in release builds.How did you test this PR?
Compile-time:
cargo check --no-default-features --features "sources-file,transforms-remap,sinks-console,sinks-opentelemetry":apache-avrono longer linked.cargo check --no-default-features --features "sources-file,transforms-remap,sinks-console,sinks-pulsar":codecs-avroauto-pulled viasinks-pulsar, Pulsar'sSerializerConfig::Avromatch arm insrc/sinks/pulsar/config.rs:370compiles unchanged.Runtime:
opt-level=3, lto=fat, codegen-units=1, panic=abort, strip=symbols) shrinks from 30.600 MB to 30.166 MB (−444 KB).Change Type
(Closest fit. The change is purely structural: it adds a build-time opt-out without altering any runtime behavior).
Is this a breaking change?
The feature is enabled by default in every release feature aggregator and pulled in transitively by both Pulsar features, so default and shipping builds are bit-equivalent in behavior.
Does this PR include user facing changes?
no-changeloglabel to this PR.Changelog fragment included:
changelog.d/codecs_avro_optional.enhancement.md.References
codecs-parquetenabled in release feature sets). Same release-aggregator update pattern is followed here forcodecs-avro.Notes for reviewers
lib/codecs/Cargo.toml(and the*Serializer/*Deserializerenum gating inserializer.rs/decoding/mod.rs) forarrow,parquet,opentelemetry,syslog. Each new#[cfg(feature = "avro")]site mirrors a matching site for one of those codecs.src/components/validation/resources/mod.rsalready had#[cfg(feature = "codecs-opentelemetry")]and#[cfg(feature = "codecs-syslog")]gates on the corresponding match arms; this PR adds the analogous#[cfg(feature = "codecs-avro")]gates in two places.[[bin]] generate-avro-fixturesnow declaresrequired-features = ["avro"], the standard cargo idiom for feature-gated binaries.Cargo.tomlkeeps the existingapache-avroworkspace dep at v0.16 unchanged — that is used directly by the Pulsar source/sink for protocol-level types and is independent of the codec dep at v0.20.0 inlib/codecs/Cargo.toml.