TensorRT · Beginners · Why does tensorrt-newbie use twice the memory of comparable tools?

2.3K
TEr/tensorrt-newbie·posted by bob_chen·just nowHelp

Why does tensorrt-newbie use twice the memory of comparable tools?

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

-- The query that broke: a full scan over 20M rows.
-- A composite index took P99 from 1.8s down to 42ms.
SELECT id, title, created_at
  FROM posts
 WHERE community_id = ?
   AND status = 1
 ORDER BY score DESC
 LIMIT 20;

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

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.

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.

491 comments

491 comments

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

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

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

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

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

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

474
Sswoole_leeOP·12 minutes ago

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

405
Oops_wang·12 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.

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

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

69
Oops_wang·just now

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

5
Nnikic·2 days agoedited

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

421
Sswoole_lee·2 days ago

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

399
Nnikic·1 hour 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.

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

87
Mmike_xu·2 hours 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.

17
Rran_bo·2 days ago

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

338
Mmike_xu·3 minutes ago

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

141
Cchen_dev·2 days ago

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

320
Hhuang_ke·1 hour ago

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

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

310
LlinlinOPMod·2 days agoedited

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

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

292
Bbob_chenOP·3 minutes 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.

204
Sswoole_lee·yesterday

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

78
Oops_wang·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.

466
Kkernel_panic·2 days ago

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

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

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

354
Oops_wang·2 days ago

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

447
Hhuang_ke·2 days agoedited

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

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

223
Oops_wang·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.

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

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

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

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

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

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

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

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

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

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

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

22
Bbob_chenOP·2 days ago

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

4
Rran_boOP·2 days ago

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

11
Llinlin·2 days 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.

63
Ttang_haoOP·yesterday

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
Nnikic·1 hour ago

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

19
Kkite·2 days ago

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

468
Wwinter·just nowedited

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

98
Sslow_query·just now

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

298
Ttang_hao·2 days ago

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

287
Sswoole_lee·2 days ago

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

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

9
Ttang_hao·2 days ago

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

252
Bbob_chen·just now

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

55
Kkernel_panic·28 minutes ago

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

43
Lli_ming·2 days ago

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

461
Llinlin·1 hour ago

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

41
Hhuang_ke·just now

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

35
Rrase·2 hours 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.

74
Kkernel_panic·2 days ago

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

467
Lli_mingOP·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.

362
Ttang_hao·2 days ago

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

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

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

52
Nnikic·2 days ago

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

33
Ttang_hao·2 days agoedited

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

298
Zzhu_zong·2 days agoedited

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

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

394
Nnikic·2 days ago

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

240
Oops_wangOP·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.

131
Aalice_dev·12 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.

13
Lli_ming·2 days ago

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

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

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

437
Lli_ming·2 days agoLevel 6

One counter-example: below tensorrt-newbie 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
Cchen_dev·2 days agoLevel 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.

15
Oops_wang·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.

146
Llinlin·2 days agoLevel 6

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.

93
Kkernel_panic·1 hour ago

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

1
Lli_ming·just now

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

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

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

48
Kkite·2 days ago

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

47
Lli_ming·2 days ago

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

40
Ttang_hao·5 hours ago

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

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

28
Cchen_dev·5 hours ago

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

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

1
Zzhou_yi·just now

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

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

18
Zzhu_zong·2 days ago

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

16
Kkite·5 hours ago

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

14
Cchen_dev·2 days ago

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

492
KkiteOP·2 days ago

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

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

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

132
Hhuang_ke·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.

26
Zzhu_zong·28 minutes ago

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

382
Ddev_zhou·1 hour ago

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

128
Zzhu_zong·2 days ago

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

344
Aalice_devOP·3 minutes ago

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

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

60
Mmike_xu·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.

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

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

16
Aalice_devMod·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.

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

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

11
Lli_ming·2 days ago

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

10
Kkite·2 days ago

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

6
Ttang_hao·2 days ago

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

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

4
Sswoole_lee·1 hour ago

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

1
Wwinter·2 days ago

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

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

1
Rrase·2 days ago

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

1
Cchen_dev·3 minutes ago

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

1

This is the post detail page /en/c/tensorrt-newbie/post/p2. 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 →