Question re: data serialisation
TimUnderhay opened this issue · 1 comments
Hello M. de Jong,
A (hopefully) quick question for you. The documentation states:
"Note that both function and arguments must be static and stringifiable, as they need to be sent to the worker in a serialized form. In case of large functions or function arguments, the overhead of sending the data to the worker can be significant."
This is written in the context of offloading functions dynamically. Does that mean that serialisation is a concern only when using dynamic functions, or is it is a universal concern with workerpool? Or to put it another way, it would be helpful to know in exactly which cases data gets (de)serialised. I.e are arguments passed in exec() (using function name arg) / proxy(), and their return values serialised?
Cheers!
The data is always serialized when sent to the worker. This serialization is not specific to workerpool
, but is the case for web workers and worker threads in general. If you have anything other than "plain data", it may be changed when sending it to the worker. Like some class instance, or a function containing references or so.