- Wasted Resources: While waiting for the call result, the calling function container cannot perform other tasks while still consuming its compute resources.
- Higher Resource Usage: More function containers are required to handle the same number of concurrent application requests if each request blocks multiple function containers.
- Higher Latency: Sequential blocking calls can lead to increased overall latency, especially when multiple function calls are involved.
Awaitables
An awaitable defines a function call without running it. An awaitable can then be passed as an argument to another function call or be returned from a function as a “tail call”. When an awaitable is passed as a function call argument, this tells Tensorlake where to obtain the argument value without having it already available in the calling function. When an awaitable is returned as a tail call, this tells Tensorlake to run the function call defined by the awaitable and then use its return value as the the calling function return value. An awaitable defines a function call without running it. An awaitable can then be passed as an argument to another function call or be returned from a function as a “tail call”. When an awaitable is passed as a function call argument, Tensorlake holds its reference until it needs to make the function’s value available in the calling function. When an awaitable is returned as a tail call, Tensorlake runs the function call defined by the awaitable and then use its return value as the the calling function return value. Tensorlake runs function calls defined by the awaitables automatically as soon as all their data dependencies (function argument values) are available. All function calls that don’t depend on each other run in parallel. This allows Tensorlake to optimize resource usage and reduce overall application latency. Applications that use awaitables and tail calls reduce their overall latency and resource usage significantly.Using Awaitables and Tail Calls
To define an awaitable function call, use theawaitable property of the function. The awaitable property has the same methods and signature as the function itself. For example:
Creating Awaitable objects for map/reduce operations
Awaitable objects for map/reduce operations are also created using theawaitable property of a function. These awaitable properties also require the name of the operation that they will perform as. For example:
Using Awaitable objects
Running an Awaitable object
An operation (i.e. a function call) defined by an Awaitable object can be started by calling therun method on the Awaitable object.