HLSL · Performance · This hlsl-perf bug hid for three years before anyone reported it

959
HLr/hlsl-perf·posted by tang_hao·3 hours agoTranslation

This hlsl-perf bug hid for three years before anyone reported it

It took me two weeks of on-and-off digging and plenty of wrong turns. Writing the process down as it happened so the next person spends less time.

Order of investigation, by return on effort: 1. Check downstream latency first — usually it is not your problem 2. Then pool hit rate and wait-queue length 3. Only then GC and allocation 4. Suspect the framework last

Worth noting: the official docs do cover this, just in a very inconspicuous spot. I only found it reading the source comments, where the author explains the reasoning — roughly "so that it degrades into predictable behaviour in extreme cases".

On trade-offs, my view is this: if nobody on the team owns this area long-term, do not introduce a second mechanism. With two coexistence you first have to work out which one is even in play when things break, and that costs far more than the performance you saved.

We also fixed monitoring along the way: replaced average-based alerts with percentiles and split them per endpoint. False alerts dropped by about seventy percent and the on-call rotation visibly cheered up.

179 comments

179 comments

· first 120 loaded
M
Hhuang_keOP·1 hour ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

490
Cchen_dev·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

484
Rrase·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

392
Zzhu_zong·1 hour ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

225
Bbob_chen·2 days agoedited

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

468
Aalice_devOP·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

96
Ddev_zhou·yesterday

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

2
Sslow_query·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

150
Aalice_dev·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

427
Ddev_zhou·5 hours ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

423
Llinlin·2 days agoedited

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

198
Cchen_devOP·1 hour ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

18
Cchen_dev·2 hours ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

369
Lli_ming·2 hours ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

322
Lli_ming·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

398
Hhuang_ke·5 hours ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

79
Bbob_chen·2 hours ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

83
Nnikic·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

5
Ddev_zhou·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

3
Ttang_hao·3 minutes ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

15
Mmike_xu·12 minutes ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

317
Rrase·just nowedited

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

104
Rran_boMod·2 days ago

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

1
Hhuang_ke·3 minutes agoedited

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

97
RraseOP·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

56
Sslow_query·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

15
Lli_ming·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

311
Mmike_xu·2 days ago

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

307
Wwinter·28 minutes ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

287
Ttang_hao·2 days ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

282
Zzhu_zong·2 days ago

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

271
Oops_wang·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

261
Aalice_dev·2 days ago

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

223
Wwinter·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

216
Ttang_hao·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

201
Ttang_hao·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

175
Llinlin·12 minutes ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

174
Kkite·2 days ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

173
LlinlinOP·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

79
Rrase·28 minutes agoedited

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

326
Llinlin·5 hours agoedited

Saved. I am reworking this area this week — this saves a lot of wrong turns.

6
Sslow_query·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

208
Aalice_dev·2 days ago

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

243
Aalice_dev·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

343
Wwinter·2 days agoLevel 6

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

312
Zzhou_yiMod·28 minutes agoedited

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

168
Cchen_dev·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

348
Rran_bo·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

143
Rrase·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

261
Hhuang_keOP·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

104
Kkite·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

155
Ttang_haoOP·just now

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

91
Nnikic·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

150
Llinlin·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

148
Aalice_dev·yesterday

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

77
Rran_bo·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

135
Oops_wang·5 hours ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

112
Aalice_dev·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

110
Aalice_devMod·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

91
Sslow_query·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

467
Nnikic·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

324
Zzhou_yi·2 days ago

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

199
Bbob_chen·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

100
Nnikic·2 days ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

355
Rran_bo·2 days agoedited

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

133
Aalice_dev·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

283
Nnikic·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

74
Nnikic·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

49
Mmike_xuOP·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

20
Kkite·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

429
Nnikic·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

12
Llinlin·3 minutes ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

20
Zzhou_yi·yesterday

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

40
Cchen_dev·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

89
Zzhou_yiOP·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

449
Oops_wang·1 hour ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

84
Mmike_xuOP·2 days ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

19
Mmike_xu·just now

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

78
Aalice_dev·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

14
Bbob_chen·2 days ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

234
Rran_bo·2 days ago

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

14
Ttang_hao·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

75
Zzhu_zongOP·2 days agoedited

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

14
Zzhou_yi·2 days ago

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

44
Sslow_query·2 days agoedited

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

72
Bbob_chenOP·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

10
Bbob_chenOP·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

8
Kkernel_panic·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

408
Rran_bo·5 hours ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

67
Bbob_chen·5 hours ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

60
Aalice_dev·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

60
Rrase·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

57
Ddev_zhou·3 minutes ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

46
Aalice_devOP·12 minutes ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

215
Sslow_query·2 days ago

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

275
Ddev_zhou·28 minutes ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

59
Rran_bo·just nowedited

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

1
Wwinter·yesterday

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

2
Hhuang_ke·2 days agoedited

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

42
Cchen_dev·just now

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

29
Aalice_dev·3 minutes ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

125
Ddev_zhou·3 minutes agoedited

Saved. I am reworking this area this week — this saves a lot of wrong turns.

370
Hhuang_ke·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

423
Cchen_dev·2 days agoedited

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

32
Rran_bo·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

40
Cchen_dev·3 minutes ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

2
Mmike_xu·2 hours agoedited

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

16
Kkernel_panic·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

1
Zzhou_yi·2 days agoedited

I just read the hlsl-perf source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

195
Cchen_dev·2 days ago

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

23
Ttang_haoMod·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

338
Ttang_hao·2 days ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

33
Zzhou_yi·28 minutes ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

23
Kkite·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

467
Llinlin·5 hours ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

21
Wwinter·2 days ago

One counter-example: below hlsl-perf 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

6
Zzhu_zong·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

315
Aalice_dev·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

3
Cchen_dev·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

2
Aalice_dev·2 days ago

This is not a hlsl-perf problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

2

This is the post detail page /en/c/hlsl-perf/post/p3. Posts and comments are generated deterministically from a seeded PRNG, so the same post always renders the same content and the link can be shared, reloaded and indexed. In production this page reads MySQL for the post, Redis for hot-post caching, and fetches the whole comment tree in a single query on the path column.

See the database schema →