-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize when validation with layering node_when objects #2347
Comments
I have nothing against optimizations but you must not modify |
I appreciate your review and suggestion.
Report logsr_lyd_validate_module() total=327167 msec
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND Validation time can be improved like as previous patch without large setup overheads. I append VSZ/RSS of netopeer2 from last time and I can improve memory usage from previous patch. And I'm sorry but if there are any improper naming or style in my patch, Regards. |
Okay, thanks for the effort but it is always better to discuss the details of an optimization before implementing it. If I understood your changes correctly, all they effectively do is avoid this inefficient loop. Your solution seems fine and is quite straightforward, create a "tree" of the nodes with When writing that loop, I did not even try to optimize it as I was not sure it was worth it but I suppose for large data trees with lots of What do you think about this? Should be quite a small change and I would think you should get similar results to yours with much less code changes. |
I appreciate your follow-up. Unless my understanding about your explanation is wrong, Thus, when we reverse lyd_node objects before starting validation loop at lyd_validate_unres_when() [lyd_validate_autodel_node_del()]
I have to avoid inefficient searching from the large node_when above. Please tell me what you think. Regards. |
Could you please somehow provide the use-case I can test on? Either by sharing your files privately by sending them to me via email or, better yet, creating a small use-case with renamed nodes, which I can directly add to the tests. Because some of my assumptions are wrong. If the nodes are sorted in DFS and are traversed from the end, nested nodes should always be resolved before their parents so deleting anything from the set (unresolved descendants) should never be needed. |
I'm trying to prepare dummy configuration with hearing howto, please wait for a while.
I'd like to confirm about this comment implication. Regards. |
Just please post any small example that actually executes this code. |
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]
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
sr_lyd_validate_module() total=361108 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
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]
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
sr_lyd_validate_module() total=327047 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
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.
The text was updated successfully, but these errors were encountered: