Skip to content

Add fixed-point percentile type and integer percentile ranking - #14

Merged
BartolomeyKant merged 2 commits into
mainfrom
feature/percentile8-tail-v1
Oct 3, 2026
Merged

BartolomeyKant merged 2 commits into
mainfrom
feature/percentile8-tail-v1

Conversation

@NikolayChirkov

Copy link
Copy Markdown
Collaborator

Summary

Add a reusable fixed-point percentile type for runtime policies and percentile selection without runtime floating-point math.

  • Store the complementary tail probability (100 - percentile) in FixedPoint<uint16_t, 100.0>.
  • Support compile-time construction for percentiles from p30 through p100.
  • Add integer-only percentile-index helpers for fixed-point and integer percentiles.
  • Add the one-byte TimeoutFactor8 fixed-point multiplier.
  • Reject out-of-range compile-time percentile constants.

Representation

  • sizeof(ae::Percentile) == 2
  • tail resolution: 1 / 512 percentage point
  • sizeof(ae::TimeoutFactor8) == 1
  • no runtime float, double, log, pow, or ceil on the percentile/rank path

Representative effective values:

Requested Stored tail Effective percentile
p30 70 30
p95 5 95
p99 1 99
p99.9 0.099609375 99.900390625
p99.99 0.009765625 99.990234375
p100 0 100

Validation

  • Numeric tests: 238/238 PASS
  • Large-N rank tests distinguish p99, p99.9, and p99.99.
  • Compile-fail tests cover values below p30 and above p100.

This PR is required by the corresponding aether-client-cpp Presence and cloud-request-policy PR.

NikolayChirkov and others added 2 commits September 3, 2026 10:20
Encode percentiles as one-byte Exponential tails for p30..p99.99 (plus exact p100), with integer-only PercentileIndex helpers and accuracy tests.
Store tail=100-percentile in FixedPoint<uint16_t,100>; drop Exponential/Log2/Exp2 from the percentile path.

Co-authored-by: Cursor <cursoragent@cursor.com>

@BartolomeyKant BartolomeyKant left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I didn't get the idea of separated type especially for percentiles.

@BartolomeyKant
BartolomeyKant merged commit 9ddd706 into main Oct 3, 2026
7 checks passed
@BartolomeyKant
BartolomeyKant deleted the feature/percentile8-tail-v1 branch October 3, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants