On Wednesday, 12 January 2022 at 16:17:02 UTC, H. S. Teoh wrote:
On Wed, Jan 12, 2022 at 03:41:03PM +0000, Adam D Ruppe via Digitalmars-d-announce wrote:
On Wednesday, 12 January 2022 at 15:25:37 UTC, H. S. Teoh wrote:
>    However it turns out that unless you are writing a computer
>    game, a high frequency trading system, a web server

Most computer games and web servers use GC too.
[...]

Depends on what kind of games, I guess. If you're writing a 60fps real-time raytraced 3D FPS running at 2048x1152 resolution, then *perhaps* you might not want a GC killing your framerate every so often.

(But even then, there's always GC.disable and @nogc... so it's not as if you *can't* do it in D. It's more a psychological barrier triggered by the word "GC" than anything else, IMNSHO.)


T

Oh there is a psychological barrier for sure. On both sides of the, uh, "argument". I've said this before but I can repeat it again: time it. 4 milliseconds. That's how long a single GC.collect() takes on my machine. That's a quarter of a frame. And that's a dry run. Doesn't matter if you can GC.disable or not, eventually you'll have to collect, so you're paying that cost (more, actually, since that's not going to be a dry run). If you can afford that - you can befriend the GC. If not - GC goes out the window.

In other words, it's only acceptable if you have natural pauses (loading screens, transitions, etc.) with limited resource consumption between them OR if you can afford to e.g. halve your FPS for a while. The alternative is to collect every frame, which means sacrificing a quarter of runtime. No, thanks.

Thing is, "limited resource consumption" means you're preallocating anyway, at which point one has to question why use the GC in the first place. The majority of garbage created per frame can be trivially allocated from an arena and "deallocated" in one `mov` instruction (or a few of them). And things that can't be allocated in an arena, i.e. things with destructors - you *can't* reliably delegate to the GC anyway - which means your persistent state is more likely to be manually managed.

TLDR: it's pointless to lament on irrelevant trivia. Time it! Any counter-arguments from either side are pointless without that.
              • ... Araq via Digitalmars-d-announce
              • ... H. S. Teoh via Digitalmars-d-announce
              • ... Vinod K Chandran via Digitalmars-d-announce
              • ... Steven Schveighoffer via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
              • ... Paulo Pinto via Digitalmars-d-announce
              • ... H. S. Teoh via Digitalmars-d-announce
              • ... Ola Fosheim Grøstad via Digitalmars-d-announce
      • Re: Why I Like D H. S. Teoh via Digitalmars-d-announce
      • Re: Why I Like D Elronnd via Digitalmars-d-announce
      • Re: Why I Like D Stanislav Blinov via Digitalmars-d-announce
      • Re: Why I Like D Johndavidson9 via Digitalmars-d-announce
  • Re: Why I Like D zjh via Digitalmars-d-announce

Reply via email to