sass: Breaking Change Proposal: Move compilation_id out of the protobuf to improve performance in multi-thread/multi-isolate context


Today we have the wire data encoded as:

[ varint proto_length ][ proto ]

This is a propose for a breaking change to remove compilation_id field inside proto, and replace it with a top level session_id like below to serve the same purpose:

[ varint session_id ][ varint proto_length ][ proto ]

The motivation is to improve I/O performance in a multi-thread context, by offloading message encoding and decoding to different CPU cores running different threads/isolates to reduce the pressure on the main isolate/thread due to potential heavy I/O multiplexing on stdio. With this change, both host, and compiler would be able to pass raw proto to a thread/isolate that is currently working on a specific compilation, and the decoding of the proto can happen on the child thread’s CPU cycle, giving the main thread more free CPU cycle to purely process multiplexed I/O.

session_id should be in the range of uint32, the reason to choose varint as its encoding instead is:

  1. For most of cases it would be shorter
  2. Avoid the possible confusion on endianness of uint32 on wire.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 25 (24 by maintainers)

Commits related to this issue

Most upvoted comments

I think just for consistency it makes sense to retain VersionRequest.id even though there’s no real risk of getting concurrent version requests confused with one another.