perf: editing a math graph recomputes that graph, not every channel
`set_math_channels()` rebuilt the store for any change, and a rebuild replaces the buffer:
every channel in the window started again, which is the "modifying one expression invalidates
all the others" report.
The plan is a *partition over the channels*, so it only moves when the set moves. When the
set is unchanged -- same channels, names and enables -- nothing is rebuilt now: the store is
untouched, every other channel keeps its samples and its runtimes, and the surgical path
prepares and recomputes only the affected graphs. The affected set is the edited channels plus
whatever *names* them, because one channel's output is another's input, and the recompute
computes the whole list in order (the inputs have to be there) while writing only those in
the mask -- which is why the step-loop is now `math_apply_locked(sample, write_mask, timed)`.
Adding, removing or renaming a channel still moves the plan, and still rebuilds.
[math-probe] graph edit: stored_slots 800 -> 900 (want the second at least the first, and non-zero)
The count grows because the stream keeps filling while the edit runs; the point is that it
never falls to 0, and that every channel afterwards still reads `N samples vs M time slots`
with N == M.
This commit is contained in:
1 parent
8b3240cacb
commit
5eb20f3cdb
5 files changed
+154
-4
No files matched your search
@@ -424,7 +424,15 @@ gboolean math_probe(gpointer user) {
|
||||
ed->name != nullptr ? gtk_editable_get_text(GTK_EDITABLE(ed->name)) : "-";
|
||||
const std::string unit_read =
|
||||
ed->unit != nullptr ? gtk_editable_get_text(GTK_EDITABLE(ed->unit)) : "-";
|
||||
// The edit must not cost the buffer. The plan is a partition over the channels and an edit does not
|
||||
// move it, so every channel keeps its history and only the edited graph -- and whatever reads it -- is
|
||||
// recomputed. Before this, `set_math_channels()` rebuilt the store and every channel started again.
|
||||
const std::uint64_t slots_before = a->model->stored_slots();
|
||||
on_math_apply(nullptr, ed); // frees the dialog: nothing below may touch `ed`
|
||||
const std::uint64_t slots_after = a->model->stored_slots();
|
||||
std::fprintf(stderr, "[math-probe] graph edit: stored_slots %llu -> %llu (want the second at least the first, and non-zero)\n",
|
||||
static_cast<unsigned long long>(slots_before),
|
||||
static_cast<unsigned long long>(slots_after));
|
||||
const std::size_t saved = a->math.empty()
|
||||
? 0u
|
||||
: a->math[static_cast<std::size_t>(index)].nodes.size();
|
||||
|
||||
Reference in new issue
Block a user