Commit 06196d8
authored
fix: Use thread-safe hash for big segments hashing. (#180)
SHA256 instances are not thread-safe and under heavy-parallelism will
fail.
Newer .Net frameworks have a static method which is higher performance
under heavy-parallelism and inherently thread-safe.
This PR introduces a thin abstraction that uses the correct method in a
thread-safe way depending on the framework.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Replaces a shared SHA256 instance with a thread-safe `LdSha256`
utility and updates Big Segments hashing to use it.
>
> - **Internal hashing**:
> - Add `LdSha256` utility that uses `SHA256.HashData` on .NET 5+ and
per-call `ComputeHash` on older targets.
> - Update `BigSegmentsInternalTypes.BigSegmentContextKeyHash` to use
`LdSha256.HashData` instead of a shared `SHA256` instance.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d5ab7a0. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 9de8b5b commit 06196d8
File tree
2 files changed
+39
-4
lines changed- pkgs/sdk/server/src/Internal
- BigSegments
2 files changed
+39
-4
lines changedLines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
12 | | - | |
13 | | - | |
14 | 11 | | |
15 | 12 | | |
16 | | - | |
| 13 | + | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments