Commit e525ef0
perf: optimize EvaluatorBucketing (#88)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes the core bucketing hash computation used for
rollouts/experiments; any mismatch would alter variation assignments.
Added a regression test to confirm the new byte-based SHA-1 parsing
matches the previous hex/substring logic.
>
> **Overview**
> Optimizes `computeBucketValue` to reduce allocations by building the
hash input with a single `StringBuilder` (including `append(int)` where
possible) and by computing the 15-hex-digit bucket value directly from
the raw SHA-1 bytes instead of `sha1Hex(...).substring(...)/parseLong`.
>
> Updates bucketing attribute handling to append directly into the
builder (returning a boolean for bucketability), and adds a test
(`optimizedHashText`) to assert the optimized path produces the same
bucket value as the prior hex-based algorithm.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
cd1884c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Todd Anderson <127344469+tanderson-ld@users.noreply.github.com>1 parent f79fba7 commit e525ef0
2 files changed
Lines changed: 39 additions & 13 deletions
File tree
- lib/sdk/server/src
- main/java/com/launchdarkly/sdk/server
- test/java/com/launchdarkly/sdk/server
Lines changed: 25 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
60 | 67 | | |
61 | | - | |
62 | | - | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | 71 | | |
65 | 72 | | |
66 | | - | |
| 73 | + | |
67 | 74 | | |
68 | 75 | | |
69 | | - | |
| 76 | + | |
| 77 | + | |
70 | 78 | | |
71 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
72 | 84 | | |
73 | | - | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
135 | 149 | | |
136 | 150 | | |
137 | 151 | | |
| |||
0 commit comments