Skip to content

Re-rendering abysmally slow on big graphs (if "before graph" and "after graph" are both large) #232

@Domiii

Description

@Domiii

We have been using d3-graphviz for a few weeks now, and it is just amazing!

However, there seems to be a really bad bug and it only happens when re-rendering, and there is already a somewhat large graph on screen. It is really fast most of the time, but if I re-render a big graph and the new graph is very similar to the old graph, things get super slow.

In one of my experiments, I got the following performance measurements:

  1. original render time: 1s
  2. Re-rendering time: 8s
  3. Re-rendering time with workaround (see below): 1s (just like the initial render)
  4. dot string is about 170k in length

It happens, regardless of whether or not I added transitions.

Workaround

It seems to have to do with the internally stored graphviz state on the element. The only workaround I found so far is to simply re-create the graph element every time, something like this:

      if (this.graphEl) {
        this.graphEl.remove();
      }
      const graphEl = this.graphEl = compileHtmlElement('<div id="timeline-graph"></div>');
      this.els.graphcont.appendChild(graphEl);
      this.graphviz = d3Graphviz.graphviz(graphEl, { ...GraphVizCfg });
      console.debug('re-initializing graph');

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions