Skip to content

UCS/DATASTRUCT: Interval tree fixes - #11213

Merged
yosefe merged 3 commits into
openucx:masterfrom
shasson5:tree2
Mar 3, 2026
Merged

yosefe merged 3 commits into
openucx:masterfrom
shasson5:tree2

Conversation

@shasson5

Copy link
Copy Markdown
Contributor

What?

Some fixes that were not included in first Interval tree PR

Why?

Improve several points:

  1. fast path optimizations
  2. assertion more descriptive
  3. simplify allocations by using mpool directly
  4. support zero length intervals natively

Comment thread src/ucs/datastruct/interval_tree.c Outdated
tree->root = ucs_interval_tree_insert_node(tree->root, new_node);

/* Update single_node flag: tree is single node if root has no children */
tree->single_node = (tree->root->left == NULL) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe have tree->num_nodes and do ++ every time we insert to it and -- when remove?

Comment thread src/ucs/datastruct/interval_tree.h Outdated
Comment on lines +30 to +32
ucs_interval_node_t *root; /**< Root node of the tree */
ucs_mpool_t *mpool; /**< Memory pool for node allocation */
int single_node; /**< Cached flag: 1 if tree has only root node */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: fix indent

Comment thread src/ucs/datastruct/interval_tree.c Resolved
Comment thread src/ucs/datastruct/interval_tree.c Resolved
Comment thread src/ucs/datastruct/interval_tree.h Resolved
Comment thread src/ucs/datastruct/interval_tree.h Resolved
Comment thread src/ucs/datastruct/interval_tree.c Resolved
@yosefe
yosefe enabled auto-merge (squash) March 2, 2026 17:39
@yosefe
yosefe merged commit c0b9ee3 into openucx:master Mar 3, 2026
152 checks passed
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