-
Notifications
You must be signed in to change notification settings - Fork 322
Description
I optimize when validation in libyang that reduce about 50% execution time.
If patch(0001-validation-OPTIMIZE-construct-layering-node_when.patch) can be acceptable,
please merge to libyang source tree.
backgroud
Our sysrepo datastore is tremendously grown up, therefore,
sr_apply_change() on edit-config reply is simultaneously slower.
We calibrated each execution in sr_apply_change() and as results,
sr_modinfo_validate() hold about 95% execution time.
=> Our calibration data owns 456917 node_when and 90123 node_type, others are 0
as validation target nodes.
calibration of lyd_validate_module()
[Calibration result with libyang-3.7.8]
patches to use for calibration
o 0001-libyang-validation-performance-check.patch
calibrating time and accounting about when validation
Note: Need libnetconf2 cmake option -DENABLE_EXAMPLES:String=Off to avoid compile error
o 0001-sysrepo-validation-from-sr_apply_changes-calibration.patch
reporting time and accounting in libyang
reported log
sr_lyd_validate_module() total=361108 msec
- when validation takes 69836 msec
o total when=456917
o topmost when=456917
o when rm=456917
o validation eval=456917
== result(disable=424534/enable=32383/autodel=0)
== autodel type=0 - incompletely validated terminal 90123 values 291271 msec
Current when validations are executed for all when nodes without autodel
because they are always started from the lowest descendants to the highest ancestor.
I improve this inefficient behavior by splitting node_when entries into layering node_when
objects(ly_set). Validation always starts from topmost when nodes and If when is disable,
its descendants can be dropped without any search or update costs.
[Calibration result with libyang-3.7.8 + patch]
patches to use for calibration
o 0001-validation-OPTIMIZE-construct-layering-node_when.patch
optimize when validation with layering node_when
o 0002-libyang-validation-performance-check.patch
calibrating time and accounting about when validation
Note: Need libnetconf2 cmake option -DENABLE_EXAMPLES:String=Off to avoid compile error
o 0001-sysrepo-validation-from-sr_apply_changes-calibration.patch
reporting time and accounting in libyang
reported log
sr_lyd_validate_module() total=327047 msec
- when validation takes 31934 msec
o total when=456917
o topmost when=204690
o when rm=247996
o inner set(new=218010/free=218010)
== inner type(container=211350/list=6660)
o validation eval=247996
== result(disable=215613/enable=32383/autodel=208921)
== autodel type=0 - incompletely validated terminal 90123 values 295112 msec
More than 50% execution time(69836 msec -> 31934 msec) is reduced.
We calibrate each pattern more than 5 times and every score is roughly the same.
Regards.