donmccurdy / glTF-Transform-View

Syncs a glTF-Transform Document with a three.js scene graph.
Other
49 stars 9 forks source link

Performance benchmarks and improvements #3

Closed donmccurdy closed 2 years ago

donmccurdy commented 3 years ago

Expected issues:

donmccurdy commented 2 years ago

Tried a bunch of test models, including some with lots of nodes. In nearly every test, DocumentView outperforms THREE.GLTFLoader on of wall clock time. GLTFLoader is doing less work, but it's asynchronous and so results take a bit longer. I'm not really comparing CPU time at this point — DocumentView is doing far more work to set up the edit/refresh bindings, and I do expect more overhead there.

All that to say — I didn't find anything that needs optimizing at this point.

There is probably room to improve wall time for DocumentView. It's doing a top-down build from the scene, which is a good thing if there's stuff in the Document we don't want to render. If not, this might be faster (or at least less recursive) going bottom-up. And of course the class structures here are probably doing quite a bit more memory allocation than necessary. TBD if this matters for my purposes — the allocation related to geometry and textures (our main constraint) remains flat.

Screen Shot 2022-04-17 at 11 20 25 PM

Above: Flamechart for one of the more complex models comparing DocumentView (left), serialization (middle), and GLTFLoader parse (right). It's a tall recursive stack on the first step, but does outperform serialization+parse even on initial setup, and (per design) will be much faster for any subsequent updates.