Engine: encode message payloads
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 21
- Forks
- 23
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 17
Description
When the runtime event emits a payload out to the worker, there are several layers of serialisation:
- the event is sent out of the worker thread into the child process (this may require it to be serialised to string)
- Inside the child process, its received and presumably parsed back to t javacrcipt object
- Then its sent out of the child process into the main process - where again it is serialised to string and deserialized
- In the main worker thread, the event object is reparsed into a JS object and carries on.
This occurs all events - log, step complete, etc. Since the runtime is quite noisy, it means a LOT of data is getting serialized
There are two possibilities to optimize this:
- We could use a more efficient transport. We could consider streaming JSON through a websocket across the processes (so the worker thread speaks straight to the main worker process). Alternatively there are techniques for a shared array buffer, which we should be able to more efficiently stream across (on both thread borders or just one of them?)
- We should be able to encode all the internal events into an array buffer representation and send that across the thread borders, to be reparsed into JSON on the other side. This should cut out all the intermediate JSON parsing. No-one in the child process or worker thread knows what the message content is, but this should 't matter. We maybe wan to send like a
{ event: string, payload: Buffer }shape so that we can read the event name at least. But I'm not sure its neccessary
The benefit of this is reduced memory overhead while exchanging messages, and probably slightly faster execution times. Less compute time too while hosting.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how runtime events are serialized between the worker thread, child process, and main process, as described in the issue. Compare the proposed more efficient transport and ArrayBuffer approaches; done means internal events cross these boundaries with less serialization while preserving event delivery and payload behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100