Skip to content

Linux stills renders are bound by per-element JS (QuickJS), not the GPU: measurements, two SDK memo fixes, and 3.6x from parallel processes #160

Open

Description

@lizTheDeveloper

These measurements come from rendering a 3D film (4 chapters, 12k–32k frames each) on vast.ai RTX 3090s with
raea render --at stills batches, comparing 0.1.0 against 0.1.4. I'd like to contribute fixes for the SDK side if
you agree with the direction. The patches below are written and measured; I'm opening this issue first, as
CONTRIBUTING asks.

1. Upgrading from 0.1.0 to 0.1.4: the #77 fix is huge in practice

First frame of a batch at a late frame, same composition and pixels:

range 0.1.0 0.1.4
frame 2400 112 s 20 s
frame 16400 561 s 24 s
frame 22000 749 s 32 s

That's 33–38 ms per earlier frame. Over our four chapters' historical batch logs it was 20–52% of all GPU time
(19 of 53.6 GPU-hours). Thank you for #77. (0.1.2's text layout also moved our captions 4 px, so we pin one version
per film.)

2. Steady-state frames are JavaScript on one core, and the GPU idles

On Linux, compositions run on QuickJS. Per-thread CPU over a steady run:

thread busy
raea-runtime-re (React) 79% of a core
main thread 22%
GPU 5–30%

React re-renders every element every frame: 12,000–23,000 3D elements in our heavy scenes, of which 1–10% actually
change. Measured cost is about 110–160 µs per element per frame. Taking 6,000 unchanged elements out of one chapter's
frame took 0.7 s off it.

SDK-side patches I've measured (JavaScript only, applied to share/raea/sdk; pixels identical, PSNR inf):

patch effect
a. structural compare in the existing memo of StandardMaterial and the geometry shapes. An inline half_size={[1, 0.5, 1]} or a colour from Srgba.hex() made again each frame defeats the shallow memo −6% per frame
b. usePlace3d returns the same matrix while parent and own place are numerically equal, plus a structural memo (children elements compared by type, key and props, within a budget) on Mesh3d and Entity. A new matrix each frame is a new Place3d context value, which re-renders every part under it, memoised or not −19% on one chapter, −7% on another

Bigger wins look possible:

  • node3d serialises every node's props with JSON.stringify(serialisable(props)) each frame. It could reuse the
    previous string when the props are structurally unchanged.
  • A JIT JS engine on Linux.

Caveat for (b): user components that read a module-level variable mutated during render would go stale under a memoised
Entity. We have one such pattern, so we keep (b) off in production.

3. One render process uses one core: four processes on one GPU render 3.6× the frames

Same 300 frames:

setup time
1 process 736 s
4 concurrent raea render --at processes (75 frames each) 202 s

Pixels are identical. The GPU had the headroom. A pipelined stills loop (React for frame N+1 while N draws and
encodes, or N React runtimes stepping disjoint frames, as scene_frames already does for rows) would give most of
this inside one process.

Happy to send (a) and (b) as PRs (b behind an opt-in), or to share the measurement harness: it times and counts what
React rebuilds per frame under node, with no GPU.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions