HLSL · Performance · Building an internal platform with hlsl-perf from scratch: architecture and decision log

2.4K
HLr/hlsl-perf·posted by huang_ke·1 hour agoOpen source

Building an internal platform with hlsl-perf from scratch: architecture and decision log

Most hlsl-perf articles stop at "how to use it" and never cover "when not to use it". This is an attempt at the second half.

One last trap: in container environments remember to adjust the memory-related parameters in step. Otherwise the host limit and the process expectation disagree, and the symptom is intermittent, unreproducible failure.

Image placeholder · object storage in production
POST /api/uploads → CDN origin pull
1338 comments

1338 comments

· first 120 loaded
M
Hhuang_ke·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.

482
Ddev_zhou·2 hours 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".

457
Kkite·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.

455
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.

436
Ddev_zhou·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.

411
Ddev_zhouOP·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.

351
Rran_bo·yesterday

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

410
Nnikic·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.

485
Zzhou_yi·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.

8
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".

67
Mmike_xu·28 minutes ago

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

404
Ttang_hao·2 days ago

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

378
Sslow_query·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.

377
Nnikic·2 days agoedited

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.

49
Cchen_dev·28 minutes ago

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

323
Llinlin·2 days ago

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

319
Wwinter·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.

309
Ttang_hao·2 days agoedited

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

74
Oops_wang·2 days agoedited

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

475
Llinlin·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.

305
Mmike_xu·2 days ago

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

4
Kkernel_panic·12 minutes ago

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

308
Sslow_query·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.

443
Aalice_devOP·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.

201
Hhuang_keOP·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.

329
Bbob_chen·3 minutes 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.

73
Bbob_chen·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.

380
Mmike_xu·28 minutes agoedited

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.

120
Llinlin·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.

122
Rrase·2 days ago

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

49
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.

27
Oops_wangMod·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.

207
Llinlin·2 days agoeditedLevel 6

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.

56
Hhuang_ke·2 days ago

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

104
Kkernel_panicMod·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.

35
Ddev_zhou·2 days agoLevel 6

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.

220
Aalice_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.

4
Lli_ming·yesterdayedited

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.

107
Wwinter·2 days agoLevel 6

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

178
Kkernel_panic·2 days agoLevel 6

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.

89
Lli_ming·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.

30
Hhuang_ke·2 days agoLevel 6

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

25
Nnikic·2 days agoLevel 6

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

1
Ddev_zhou·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.

29
Sswoole_leeOP·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.

130
Bbob_chenOPMod·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.

303
Sslow_query·yesterdayedited

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.

57
Lli_ming·28 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
Llinlin·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.

1
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.

289
Zzhu_zongOP·2 days ago

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

229
Oops_wang·yesterday

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.

286
Zzhu_zong·just now

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

278
Cchen_devOP·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.

431
Mmike_xu·2 days ago

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

240
Wwinter·2 days ago

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

206
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.

194
Rran_boOP·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.

96
Sslow_queryOP·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".

73
Ddev_zhou·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.

115
Ddev_zhou·just now

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

111
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.

101
Llinlin·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.

99
Ddev_zhouMod·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.

433
Sslow_query·just now

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

219
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.

31
Wwinter·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.

22
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.

8
Oops_wang·1 hour 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.

99
Rrase·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.

90
Hhuang_keOP·2 hours ago

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

14
Kkite·5 hours ago

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

372
Zzhu_zongOP·5 hours 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".

326
Zzhou_yiOP·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.

109
Oops_wangMod·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.

58
Ddev_zhou·5 hours 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.

34
Rrase·1 hour 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.

4
Sslow_query·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.

414
Ddev_zhouOP·28 minutes ago

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

166
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.

107
Llinlin·just now

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.

3
Zzhou_yi·5 hours ago

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

407
Sswoole_lee·2 days ago

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

391
Hhuang_ke·just now

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.

172
Cchen_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.

10
Rran_bo·2 days agoLevel 6

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.

1
Aalice_dev·just now

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

100
Aalice_dev·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.

1
Rrase·just nowLevel 6

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.

175
Wwinter·2 days agoLevel 6

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.

170
Sswoole_lee·2 days ago

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

4
Kkernel_panic·2 days ago

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

305
Zzhu_zong·2 days agoLevel 6

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.

191
Rran_boMod·2 days agoLevel 6

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.

53
Ddev_zhou·5 hours 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.

264
Cchen_devMod·2 days agoLevel 6

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
Ttang_haoMod·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.

1
Bbob_chen·2 days ago

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

102
Rrase·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.

449
Nnikic·2 days ago

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

69
Wwinter·12 minutes ago

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

67
Ddev_zhou·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.

57
Ttang_hao·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".

54
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.

241
Zzhou_yi·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.

180
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".

71
Hhuang_ke·2 days ago

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

45
Wwinter·3 minutes 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".

40
Sslow_query·2 days ago

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

35
Rran_bo·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.

20
Kkernel_panic·2 days ago

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

17
Kkernel_panic·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.

11
Ttang_hao·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.

259
Aalice_dev·3 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.

8
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".

3
Sswoole_lee·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.

2
Ttang_hao·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.

1
Cchen_devOP·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.

65
Llinlin·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.

1
Zzhou_yi·2 hours ago

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

1

This is the post detail page /en/c/hlsl-perf/post/p6. 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 →