Skip to content

Fixes #2579 - #2580

Merged
michalvasko merged 3 commits into
CESNET:develfrom
fredrik-persson:perf/val-diff-append
Oct 5, 2026
Merged

michalvasko merged 3 commits into
CESNET:develfrom
fredrik-persson:perf/val-diff-append

Conversation

@fredrik-persson

Copy link
Copy Markdown

Fixes #2579

Three commits: the first adds performance test that exercise validation with a diff, then two fix commits as described in the issue.

perf.yang declares no defaults and no when conditions, and test_validate passes
NULL for the diff, so lyd_val_diff_add() is never reached and the cost of
building a validation diff is not measured anywhere.

Add perf_dflt.yang, where every list instance offers four alternative sets of
defaults gated on the same leaf, so only one set can ever apply. Two cases
validate that data, one asking for a diff and one not.
…diff

lyd_val_diff_add() is called once per node created or deleted by validation. It
built a standalone one-node diff and merged that into the accumulating diff,
which duplicated the node's whole ancestor chain on every call.

lyd_diff_add() already reuses the ancestors present in the target diff, so
append straight into it when the node has no entry there yet. The merge is only
needed when an operation on that very node already exists, to reconcile the
two. lyd_diff_add() leaves out an operation that a parent already states, so add
it back to keep the diff shape unchanged.
When a when condition turns out false, the default nodes created speculatively
before it was resolved are auto-deleted again. Recording that deletion went
through lyd_diff_merge_all(), which duplicated the deleted subtree and
reconciled it node by node, only for the entries to end up as "none" and be
dropped as redundant.

Recognise the case directly: if the diff already holds a create for the node,
and nothing in that subtree was set explicitly, the create and the delete
cancel out, so remove the subtree together with any ancestor left without a
change.
@michalvasko
michalvasko merged commit 55e87ce into CESNET:devel Oct 5, 2026
13 checks passed
@fredrik-persson
fredrik-persson deleted the perf/val-diff-append branch October 5, 2026 14:36
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