Sea of Nodes (2015)

(darksi.de)

27 points | by ingve 1343 days ago

2 comments

  • pubby 1343 days ago
    I tested a sea of nodes representation on my toy compiler project and was unimpressed. The gist is that instead of having two graphs (one for operations, one for control flow), you just have one... but no wait you actually have to convert back into a two-graph format eventually so you don't save any lines of code at all. It makes a few algorithms slightly prettier, but most code is made worse and slower, and when you start trying to rectify the disadvantages you realize you're just doing the two-graph thing in a roundabout way and that the sea-of-nodes is a oversold meme.

    Also, I remember reading an anecdote by the V8 team where they had regrets in choosing the sea of nodes representation over a more traditional 2-graph IR, but I can't find a link.

    • sebmellen 1343 days ago
      The V8 blog mentions using a sea-of-nodes representation here: https://v8.dev/blog/turbofan-jit#more-sophisticated-optimiza..., though they don't say anything bad about it:

      > The TurboFan JIT implements more aggressive optimizations than CrankShaft through a number of advanced techniques. JavaScript enters the compiler pipeline in a mostly unoptimized form and is translated and optimized to progressively lower forms until machine code is generated. The centerpiece of the design is a more relaxed sea-of-nodes internal representation (IR) of the code which allows more effective reordering and optimization.

  • quelltext 1343 days ago
    I saw this combination of control and data flow graph before a while ago in some paper and while it made sense there (was a very small part of what they described as a whole) it seemed rather trivial / straightforward as a concept.

    I also heard people reference sea of nodes elsewhere before but I couldn't really get what made it special or a "sea if nodes". Only now I learn that that's basically all it is: data flow and control flow per node/element/instruction combined.

    I guess without also going into what it actually enables it's a bit underwhelming.