Skip to content

Investigate consolidating WASM transfer calls #26

Description

@cowboyd

Motivation

Each render frame currently makes multiple WASM calls: Clay_SetPointerState, Clay_UpdateScrollContainers, reduce, and a post-layout Clay_SetPointerState for hit testing. Each call has JS↔WASM context switch overhead and requires marshaling arguments through shared memory.

While the overhead is likely negligible compared to layout and diffing work, there are two reasons to investigate consolidation:

  1. Memory safety: calls that write to opsBuf (pointer state, scroll delta) followed by calls that read from it (reduce) could break if a WASM call triggers memory growth between them, invalidating the DataView.

  2. Future proofing: as more pre-layout state is added (drag scrolling, transitions), the number of per-frame calls will grow.

Approach

Profile the current multi-call approach to establish a baseline, then evaluate whether a single consolidated entry point (or packing all per-frame state into the command buffer) yields measurable improvement.

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

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions