Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Conflate Stale Renderings Runtime #868

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

steve-the-edwards
Copy link
Contributor

@steve-the-edwards steve-the-edwards commented Aug 23, 2022

Performance tests for this new runtime are forthcoming, but not included in this PR.

@steve-the-edwards steve-the-edwards force-pushed the sedwards/runtime-prototypes branch from b7536ef to 2030aef Compare August 23, 2022 21:37
@steve-the-edwards steve-the-edwards force-pushed the sedwards/proto-conflate branch 3 times, most recently from 14acb3f to ae4d7fd Compare August 24, 2022 15:13
@steve-the-edwards steve-the-edwards marked this pull request as ready for review August 24, 2022 15:48
actionResult: ActionProcessingResult?,
onOutput: suspend (OutputT) -> Unit
): RenderingAndSnapshot<RenderingT> {
// After receiving an output from the actions that were processed,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd to have the same comment in two places (here and line 171). I think it's just confusing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed and clarified.

Comment on lines 147 to 152
when (actionResult) {
is WorkflowOutput<*> -> {
@Suppress("UNCHECKED_CAST")
val output = actionResult as? WorkflowOutput<OutputT>
output?.let { onOutput(it.value) }
}
else -> {} // no -op
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a single cast not work?

Suggested change
when (actionResult) {
is WorkflowOutput<*> -> {
@Suppress("UNCHECKED_CAST")
val output = actionResult as? WorkflowOutput<OutputT>
output?.let { onOutput(it.value) }
}
else -> {} // no -op
}
@Suppress("UNCHECKED_CAST")
(actionResult as? WorkflowOutput<OutputT>)?.let {
onOutput(it.value)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to this.

Comment on lines 171 to 170
// After receiving an output, the next render pass must be done before emitting that output,
// so that the workflow states appear consistent to observers of the outputs and renderings.
renderingsAndSnapshots.value = runner.nextRendering()
output?.let { onOutput(it.value) }
nextRenderAndSnapshot = renderAndEmitOutput(runner, actionResult, onOutput)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're violating what this comment warns about -- under ConflateStateRenderings, we may emit several outputs before the next rendering. Question is, does that matter? @zach-klippenstein and I convinced each other that it does, but I don't believe that any more -- sanity check requested.

If we do think it's true, then this method needs to exit immediately after emitting output, right? Perhaps it becomes a do {} while().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IC what you mean. The wording needs more specificity. We are doing a Render Pass before emitting each output (they are tied together in the helper method).

What we are not doing is emitting the new rendering in the flow (and thus being able to update any UI).

You would likely have a better practical sense of use cases, but in theory the Output handling should be orthogonal to UI updates. Also we know that UI is already stale, so we wait to give you the fresh one. But Output by nature of being an event, can never be stale.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


      // If the action did produce an Output, we send it immediately after the render pass.
      nextRenderAndSnapshot = renderAndEmitOutput(runner, actionResult, onOutput)

      if (runtimeConfig == ConflateStaleRenderings) {
        // With this runtime modification, we do not pass renderings we know to be stale. This
        // means that we may be calling onOutput out of sync with the update of the UI. Output
        // is an event though, and should always occur immediately - i.e. it cannot be stale.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording needs more specificity.

I think it was pretty clearly about emitting the rendering, since we're talking about observers.

But it sounds like you agree that it's okay to consider the output and rendering streams as separate things.

Base automatically changed from sedwards/runtime-prototypes to main August 24, 2022 18:26
Check for empty channels and synchronously return if they are empty.
@steve-the-edwards steve-the-edwards merged commit ff53530 into main Aug 24, 2022
@steve-the-edwards steve-the-edwards deleted the sedwards/proto-conflate branch August 24, 2022 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants