sass: Breaking Change Proposal: Move compilation_id out of the protobuf to improve performance in multi-thread/multi-isolate context
- Embedded protocol (https://github.com/sass/sass/pull/3599)
- Dart Sass (https://github.com/sass/dart-sass/pull/1981)
- Node.js Embedded Host (https://github.com/sass/embedded-host-node/pull/224)
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:
- For most of cases it would be shorter
- 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
- [Embedded Protocol 2] Mark as accepted See #3579, #3575, #3577 — committed to sass/sass by nex3 a year ago
- [Embedded Protocol 2] Mark as accepted (#3598) See #3579, #3575, #3577 — committed to sass/sass by nex3 a year ago
- Update the embedded protocol to 2.0.0 Closes #3579 Closes #3575 Closes #3577 — committed to sass/sass by nex3 a year ago
- Update the embedded protocol to 2.0.0 (#3599) Closes #3579 Closes #3575 Closes #3577 — committed to sass/sass by nex3 a year ago
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.Pinging maintainers of other known host implementations for comments:
@ahabhgk (https://github.com/ahabhgk/sass-embedded-host-rust) @bep (https://github.com/bep/godartsass) @johnfairh (https://github.com/johnfairh/swift-sass) @larsgrefer (https://github.com/larsgrefer/dart-sass-java)