Obviate 'static
lifetime Clone
requirements for operations
#25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Removing
'static
andClone
requirementsThe signature of
Task
has been updated to accept references to operations, rather than an owned value. This requires threading lifetimes through directive chains such that the compiler can guarantee the passed in operations live as long as the execution chain. The implication with respect to the public API is that operations must be passed as references to directive chainers like.map()
and.fold()
. Ultimately this means that directive implementations ofFunctor
andFoldable
no longer need to clone operations, and can simply hold a single immutable reference to operations through the duration of execution. This is a significant efficiency improvement, especially for large operation payloads and large input streams.Reworking the
derive
procedural macroA significant ergonomic improvement to the
derive
macro is included here. Previously,Operation
implementors were required to maintain anenum
of allOperation
definitions to facilitate dynamic remote execution. This scheme has been superseded by a#[derive(RemoteExecute)]
that can be derived directly onOperation
s. Operations annotated with#[derive(RemoteExecute)]
will now be automatically collected at compile time into a contiguous section of the binary by the linker — no more manual maintenance of a comprehensiveenum
.This change was precipitated by the aforementioned
'static
andClone
requirements forOperation
being dropped. With those requirements dropped, andTask
requiring a lifetime annotation, theOpKind
enum
would have had to additionally define a lifetime annotated version with references to the internal operations.For example:
With
Task
requiring a reference to theOpKind
, rather than an owned copy, an additional lifetime would need to be introduced ontoOperation
to support a variant of theMyOps
containing references.Which was rather unfortunate for the public API. I took this as an opportunity to simplify the public API consumers. As such, the
RemoteExecute
trait was introduced.This is accompanied by a derive macro, which generates a unique
ID
for eachOperation
derivingRemoteExecute
. This macro additionally generates a unique execution function with types specialized to the givenOperation
. A pointer to this function is then inserted into adistributed_slice
, indexed by theOperation
's unique ID. With this scheme,Task
s can simply include the givenOperation
's ID in the payload, and the remote worker can use that to retrieve its associated execution function from the slice. This exhibits the same behavior of the previousOpKind
enum construction without requiring such an enum to be maintained by the paladin user.