-
Notifications
You must be signed in to change notification settings - Fork 291
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
Data nodes sorted #2128
Merged
Merged
Data nodes sorted #2128
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
michalvasko
requested changes
Nov 24, 2023
lePici
force-pushed
the
lyds_tree
branch
2 times, most recently
from
November 29, 2023 13:14
9333db4
to
c824c0a
Compare
lePici
force-pushed
the
lyds_tree
branch
2 times, most recently
from
February 9, 2024 14:48
8026822
to
53e8c1d
Compare
The lyd_insert_node() expecting first sibling.
... when deleting metadata in the lyd_parse_set_data_flags().
... from different contexts.
The function now has a new context parameter that may be needed when getting the canonical value. Type API version number has increased.
... implemented via new lyplg_type_sort_simple().
Simplification of sort and compare callback functions. The complexity of the comparison was needed in the old version of libyang.
The top parameter is removed.
1. Plugin type 'lyds_tree' is integrated. Used in metadata and it is internal, which is distinguished by the unset print callback. Internal metadata must not be printed. 2. Leaf-list and list data instances are now automatically sorted. 3. Both the explicit and implicit YANG statement 'ordered-by system' will cause the nodes to be ordered. 4. The first instance of the list or leaf-list of node contain new metadata named 'lyds_tree'. 5. Data nodes are sorted only if their data types have callback 'sort' set. 6. Sorting can be turned off so far only by adding the 'ordered-by user' statement to the YANG model. 7. If the sort fails for some reason, the node is still inserted as the last instance. A warning message informs about this situation. 8. The time required for sorting should be relatively small thanks to the Red-black tree implementation. 9. Memory requirements will now increase by 40 bytes per list/leaf-list data node, plus metadata structure overhead. 10. New internal lyds_tree plugin type.
1. When inserting, the last parameter can also be used for nodes with lyds_tree 2. The principle of lyds_tree is that it is created lazily. That is, if it is certain that the nodes are sorted, no metadata or lyds_tree is created. 3. If it is necessary to modify the sorted nodes, the lyds_tree is created additionally. This means that inserting the first node can lead to a delay. 4. The LYD_PARSE_ORDERED flag now has a positive performance effect because the lyds_tree is created lazily.
Unlink and then insert is inefficient for sorted (lyds) list and leaf-list nodes. Also improved lyd_unlink_siblings().
If the LYD_PARSE_ORDERED flag is set incorrectly, the data may be unordered, a warning will inform about this if the DEBUG variable is set. But as soon as the lyds tree is created later, the data will be sorted.
Added return value for functions lyd_unlink_siblings() and lyd_unlink_tree(), which causes ABI breaks.
There is no more freeing of memory and then allocation regarding regarding lyds data. Memory intended to be freed is temporarily not freed and instead waits for an opportunity to use it again.
This change avoids unnecessary finding of the first sibling in case the parent node is not available.
Function lyd_insert_node() has new options that ignore the ordering of data nodes. This is used in lyd_diff_add() because the diff as such does not need to be sorted.
Restored functionality regarding the sorting of opaq nodes and nodes with the LYD_EXT flag set.
Faster node insertion. There is no need to search for the 'anchor' for instances of the (leaf-)list, thus reducing the number of accesses to the hash table.
michalvasko
approved these changes
Feb 14, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview of changes
internal, which is distinguished by the unset print callback.
Internal metadata must not be printed.
will cause the nodes to be ordered.
new metadata named 'lyds_tree'.
callback 'sort' set.
statement to the YANG model.
as the last instance. A warning message informs about this situation.
the Red-black tree implementation.
data node, plus metadata structure overhead.
perf
memory
test: 'create new text' without leaf-list inserts
1000 nodes
devel - 3,177,195
lyds_tree - 3,220,116
difference: 42,921
100000 nodes
devel - 122,591,019
lyds_tree - 126,593,940
difference: 4,002,921
40 bytes per lyd_node + metadata overhead
branch lyds_tree
1000-10
100000-3
branch devel
1000-10
100000-3