‹ BackHN Continuity

Thread

Writing Efficient C++ Code (2013)

176 points · 161 comments · ibobev

  1. Jeaye · · focus · HN ↗
    While we're here, has anyone seen any resources related to data-oriented design when GCs are involved? So much of data-oriented design is arena-focused, but that's not always possible, when the lifetime model of the code requires a GC (for whatever reason).

    I feel like the DoD movement is a slow-moving, but big, change through how systems programming is done, but that there's still insufficient material for how to do this in different scenarios. I would really like to apply this more to my areas of work, which are also in C++, but there seems to be a gap between what they're presenting and how it can be applied.

    More specifically, I'm using C++ to build a dynamic programming language runtime for a Clojure dialect. That runtime is required to be garbage collected, type-erased, and highly polymorphic. So I surely can't just SoA or AoS everything. Yes, I can pack my data, and I can avoid the GC whenever possible, both in compiler/runtime code and in generated code via escape analysis. But what about everything else, which is the 80% or more of the system? It could be that this runtime is too far at odds with DoD, but I generally see things as a gradient rather than black and white.

    1. smj-edison · · focus · HN ↗
      Not sure if this is relevant, but I was in a discussion about heap layout a while ago, and one of the commenters was talking about how they were able to have classic lisp-style linked lists with decent performance by using a copying garbage collector: <a href="https:&#x2F;&#x2F;ziggit.dev&#x2F;t&#x2F;memory-layout-suggestions-for-tcl-interpreter&#x2F;12583&#x2F;5?u=smj-edison" rel="nofollow">https:&#x2F;&#x2F;ziggit.dev&#x2F;t&#x2F;memory-layout-suggestions-for-tcl-inter...

      Or were you referring more to all the intermediate allocations that aren&#x27;t the object heap? V8&#x27;s zones are interesting in this area, because they&#x27;re like an arena, except that they&#x27;re only partially reset when a zone ends, so zones can nest inside each other.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.