improved perfs and event management

This commit is contained in:
Martino Ferrari committed 2026-10-13 23:00:42 +02:00
1 parent 667ed0c100
commit bb99be5889
17 files changed
+626 -59

No files matched your search

+33 -7
View File
@@ -284,18 +284,38 @@ void apply_layout(App& app, const LayoutState& st) {
ScopeModel& model = *app.model;
const auto& signals = model.signals();
// The session's own state first: enabling is what starts acquisition, and a math channel's
// *name* is only a signal once its graph is installed -- a row that holds one would otherwise be
// skipped as a name the stream no longer has.
// The window before anything structural. Nothing is enabled yet, so there are no channels
// to plan for and this only *records* the span -- but it is the span every plan below is
// then made with, so the `apply_time_window()` at the end of this function finds the
// decimation already right and re-plans nothing. Stated last, as it used to be, it moved
// the stride and bought a second full allocation of the buffer after the data was already
// flowing into the first.
if (st.window_s > 0.0) model.set_target_span(st.window_s);
// The math graph before the enables, because a math channel's *name* is only a signal once
// its graph is installed -- a row that holds one would otherwise be skipped as a name the
// stream no longer has -- and because installing it while nothing is enabled is the one
// ordering in which it does not pay for a buffer of its own. `signals` is a reference to
// the model's own vector, so the synthetic entries this appends are visible below.
app.math = st.math;
apply_math_channels(app);
// What the session had on, collected and enabled **once**, at the end of this function.
// Each enable re-plans the partition, and a re-plan allocates -- and so touches -- the whole
// of `--buffer-mb`: seven signals one at a time is seven allocations before a single sample
// is kept, which is the ten seconds of blank window a large buffer used to start with. The
// math channels are not collected here: their enable state is the session's `math` and
// `set_math_channels()` has already restored it, so listing them again could turn on one
// the user saved off.
std::vector<std::size_t> wanted;
wanted.reserve(st.enabled.size());
for (const std::string& name : st.enabled) {
for (std::size_t si = 0; si < signals.size(); ++si) {
if (signals[si].name != name || signals[si].math) continue;
model.set_signal_enabled(si, true);
wanted.push_back(si);
break;
}
}
app.math = st.math;
apply_math_channels(app);
app.measures = st.measures;
app.measure_stats_on = st.measure_stats;
app.updating_panels = true;
@@ -341,12 +361,18 @@ void apply_layout(App& app, const LayoutState& st) {
// Enabling is what starts acquisition (a loaded plot nobody acquires would
// come back blank), and it is what a drop does for the signal it places.
app.rows->assign(i, slot, name, name, signal_color_index(signals, si));
model.set_signal_enabled(si, true);
wanted.push_back(si);
++slot;
break;
}
}
}
// The one structural change of a restored session: everything the file had on, and
// everything its rows placed, in a single re-plan. Enabling is what starts acquisition (a
// loaded plot nobody acquires would come back blank), and it is what a drop does for the
// signal it places -- so a row holding a signal the `enabled` list did not name is enabled
// here, by having been collected above.
model.set_signals_enabled(wanted, true);
for (const auto& cal : st.calibration) {
for (std::size_t si = 0; si < signals.size(); ++si) {