Skip to content

lib,daemon,cli: use float for meta.probability matcher#454

Merged
qdeslandes merged 1 commit intofacebook:mainfrom
agelun:agelun/probability-float
Mar 4, 2026
Merged

lib,daemon,cli: use float for meta.probability matcher#454
qdeslandes merged 1 commit intofacebook:mainfrom
agelun:agelun/probability-float

Conversation

@agelun
Copy link
Contributor

@agelun agelun commented Mar 4, 2026

Change the meta.probability matcher payload from uint8_t to float, enabling fractional percentage values (e.g., "33.33%", "0.1%"). This aligns meta.probability with meta.flow_probability which already used float. Consolidate the now-identical parse and print functions between the two matchers.

@agelun agelun requested a review from qdeslandes as a code owner March 4, 2026 14:10
@meta-cla meta-cla bot added the cla signed label Mar 4, 2026
program,
BPF_JMP_IMM(BPF_JGT, BPF_REG_0,
(uint32_t)((uint64_t)UINT32_MAX * (proba / 100.0)), 0));
(uint32_t)((double)UINT32_MAX / 100.0 * proba), 0));
Copy link

Choose a reason for hiding this comment

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

Claude: nit: The threshold expression here uses (double)UINT32_MAX / 100.0 * proba, while _bf_matcher_generate_meta_flow_probability uses (double)UINT32_MAX * (proba / 100.0). Since the two matchers now share the same payload type and parse/print functions, using the same threshold expression would make the consolidation more complete.

Suggested change
(uint32_t)((double)UINT32_MAX / 100.0 * proba), 0));
(uint32_t)((double)UINT32_MAX * (proba / 100.0)), 0));

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Claude: review of facebook/bpfilter #454 (9908fea)

Clean PR — good consolidation of the two probability matchers. Both previous nits and the maintainer's lexer state feedback have been addressed.

Nits

  • Threshold formula style inconsistencysrc/bpfilter/cgen/matcher/meta.c:76 — Fixed: now uses (double)UINT32_MAX * (proba / 100.0) matching flow_probability.
  • Stale comments reference renamed functiontests/unit/libbpfilter/matcher.c — Fixed: comments now correctly reference _bf_print_probability.

@agelun agelun force-pushed the agelun/probability-float branch from f384813 to e120a75 Compare March 4, 2026 14:34
Copy link
Contributor

@qdeslandes qdeslandes left a comment

Choose a reason for hiding this comment

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

Small change, otherwise LGTM.

Change the meta.probability matcher payload from uint8_t to float,
enabling fractional percentage values (e.g., "33.33%", "0.1%").
This aligns meta.probability with meta.flow_probability which already
used float. Consolidate the now-identical parse and print functions
between the two matchers.
@agelun agelun force-pushed the agelun/probability-float branch from e120a75 to 9908fea Compare March 4, 2026 17:15
@agelun agelun requested a review from qdeslandes March 4, 2026 21:33
Copy link
Contributor

@qdeslandes qdeslandes left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@qdeslandes qdeslandes merged commit 08f4f07 into facebook:main Mar 4, 2026
32 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.

2 participants