@@ -353,3 +353,24 @@ Hopefully this has demonstrated a few benefits of the `ManagedProcess` API, alth
353
353
it's really just scratching the surface. We have focussed on the code that matters -
354
354
state transitions and decision making, without getting bogged down (much) with receiving
355
355
or sending messages, apart from using some simple APIs when we needed to.
356
+
357
+ ### Performance Considerations
358
+
359
+ We did not take much care over our choice of data structures. Might this have profound
360
+ consequences for clients? The LIFO nature of the pending backlog is surprising, but
361
+ we can change that quite easily by changing data structures.
362
+
363
+ What's perhaps more of a concern is the cost of using ` Async ` everywhere - remember
364
+ we used this in the * server* to handle concurrently executing tasks and obtaining
365
+ their results. The ` Async ` module is also used by ` ManagedProcess ` to handle the
366
+ ` call ` mechanism, and there * are* some overheads to using it. An invocation of
367
+ ` async ` will create two new processes: one to perform the calculation and another
368
+ to monitor the first and handle failure and/or cancellation. Spawning processes is
369
+ cheap, but not free as each process is a haskell thread, plus some additional book
370
+ keeping data.
371
+
372
+ The cost of spawning two processes for each computation/task might represent just that
373
+ bit too much overhead for some applications. In our next tutorial, we'll look at the
374
+ ` Control.Distributed.Process.Platform.Task ` API, which looks a lot like ` Async ` but
375
+ manages exit signals in a single thread and makes configurable task pools and task
376
+ supervision strategy part of its API.
0 commit comments