Skip to content

Add encoder that works better for large trees #8

Closed as not planned
Closed as not planned

Description

@lemonmade

The default encoder has to deeply traverse every object/ array sent over the wire to replace any functions. Another strategy would be to encode the entire object to a binary representation (since that will give us a chance to convert functions into a meaningful representation at the same time), which should also be faster to transfer via postmessage when the messages are very large.

I have an initial branch that does this here: https://github.com/Shopify/remote-ui/compare/cbor-encoding?expand=1. It is mostly inspired by CBOR, borrowing heavily from a ~1.5K JS implementation I found. It also takes some queued from worker-dom’s serialization logic.

Before shipping that branch, we need to:

  1. Check its impact on bundle size, and offer some way (probably a Babel plugin) of not paying the cost for both the default encoder and the CBOR encoder
  2. See a meaningful performance difference, probably with a puppeteer-based benchmark on a very large tree of remote components

Activity

  1. lemonmade commented on Feb 28, 2022

    @lemonmade
    ContributorAuthor
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions