Repository navigation
[ESSREDUCE] Build StreamProcessor on sciline stages - #867
Draft
SimonHeybrock wants to merge 4 commits into
Draft
SimonHeybrock wants to merge 4 commits into
SimonHeybrock wants to merge 4 commits into
Conversation
StreamProcessor splits its workflow into sciline.Stage objects built in one prepare_stages call: a context stage computing what the other stages read that depends on the context, one chunk stage per group of accumulators reading the same dynamic keys, and a finalize stage. The forwarded keys are derived from the cached keys of the chunk and finalize stages built on their own, as in sciline ADR 0003. This replaces _FedWorkflow, _build_streaming_workflow, the pruning by assigning None, and the graph walks for context and finalize inputs. visualize uses sciline.visualize_stages with the same node groups and colors, which removes the custom styling and legend code. Behavior changes: - A target depending on a dynamic key other than through an accumulator raises at construction unless allow_bypass=True, instead of passing None to the provider at finalize. - Updating any context key recomputes everything derived from the context, not only what depends on the updated key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With sciline stages dropping unneeded inputs, StreamProcessor no longer builds stages only to find exact inputs: the finalize stage is built once with all accumulation and dynamic keys as candidates, and its inputs give the accumulators it reads and the bypassed dynamic keys. An accumulator that only feeds another accumulator no longer fails at construction; it is computed per chunk as before and its accumulator is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One context stage recomputed every context-derived value on any context update. On the LOKI rear detector in esslivedata, with live sample motor transforms, each sample motor message then rebuilt the detector projection, which does not depend on the sample: about 80 ms per batch instead of 12 ms. Context-derived values are now grouped by the context keys they depend on, one stage per group. A group reading the result of another depends on a strict superset of its keys, so ordering by the number of keys runs each stage after those it reads. set_context runs the stages that read an updated key or a value recomputed before them. A group that reads a value derived in another group takes it as input instead of recomputing it, so an ROI edit no longer rebuilds the projection either. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Taken from #793. It checks, by counting provider calls, that neither accumulate nor finalize recomputes a value derived from the context, for every combination of who reads it: an accumulator, a target computed from the accumulators, or the value being a target itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #746. Fixes #868. Supersedes #793, which fixed the same on the old design; its test is included here. Rewrites
StreamProcessoronsciline.Stageas planned in sciline ADR 0003 (design doc section 6.6). Draft: needs a sciline release withStageand scipp/sciline#256, so CI against released sciline will fail until then.What changed
StreamProcessorsplits its workflow into stages built in oneprepare_stagescall, so everything that depends on neither context nor chunks is still computed once at construction:set_contextruns only the stages that read an updated key or a value recomputed before them;Which context-derived values the context stage computes is found from the cached keys of the chunk and finalize stages built on their own (ADR section "Nested loops"). This replaces
_FedWorkflow,_build_streaming_workflow, pruning by assigningNone, and the graph walks that found context and finalize inputs.visualizeusessciline.visualize_stageswith the same node groups and colors, which removes the custom styling and legend code. The public interface is unchanged.Behavior changes
allow_bypass=True. PreviouslyNonewas passed to the provider atfinalize.The visualize tests that called removed private helpers now check the styles of the rendered nodes.
Performance of context updates
set_contexttimed on the esslivedata LOKI rear detector view in wavelength mode, with live transforms and ROIs:A single context stage, as the sciline design document proposed, rebuilt the detector projection on every sample motor message, although the projection does not depend on the sample. Grouping context-derived values by the context keys they depend on avoids that.
ROI edits got faster than before: the ROI values read the projection, and the old
set_contextcomputed them on a workflow that was fed only the context keys, so it rebuilt the projection as an intermediate on every edit and discarded it. Now the ROI stage takes the projection held from the last position update as input. The sample motor and lookup table improvements likely have the same cause; not traced.Data updates on the same detector view:
accumulateis unchanged (about 95 ms per chunk of 100 events, 175 ms for 1M events), whilefinalizewent from 83 ms to 5 ms. The old finalize workflow was fed the context keys and only those context-derived values that are targets, so eachfinalizerecomputed the ROI masks, ROI pixels, and pixel weights, including the projection they read. The finalize stage now takes them as input. Per-call graph building, whichStage.runavoids, cost only about 1 ms per call before, since inputs were already fed without rebuilding the pipeline.Sciline findings
Stageandprepare_stagesrejected input keys the outputs do not need. That forced this driver to build stages only to find exact inputs, ruled out an accumulator feeding another accumulator, and madeprepare_stagesreject a context-only target that only the context stage outputs. Drop stage inputs the outputs do not need sciline#256 makes stages drop such keys instead, asPipelineignores unneeded parameters;runstays strict.Pipeline.provideand areporterargument onStage, listed as prerequisites in Tracking: migrate from sciline map/reduce to stages and aggregations (sciline ADR 0003) #746, are not needed:Stage.runtakes the values directly, andStreamProcessornever used a reporter.Test plan
mainplus Drop stage inputs the outputs do not need sciline#256.Nonebypass and needsallow_bypass=True.🤖 Generated with Claude Code