Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
8f1ae2c5
Unverified
Commit
8f1ae2c5
authored
Jan 22, 2026
by
Yan Ru Pei
Committed by
GitHub
Jan 22, 2026
Browse files
chore: use Rc in RadixTree BFS dumpt (#5574)
Signed-off-by:
PeaBrane
<
yanrpei@gmail.com
>
parent
0d5c8dfc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
lib/llm/src/kv_router/indexer.rs
lib/llm/src/kv_router/indexer.rs
+19
-10
No files found.
lib/llm/src/kv_router/indexer.rs
View file @
8f1ae2c5
...
...
@@ -528,6 +528,15 @@ impl RadixTree {
/// Uses BFS traversal to ensure that the tree reconstruction is unique,
/// though the exact event ordering will be lost.
pub
fn
dump_tree_as_events
(
&
self
)
->
Vec
<
RouterEvent
>
{
// BFS queue entry: (current_block, parent_hashes_per_worker, tokens_hash)
// parent_hashes_per_worker maps WorkerWithDpRank -> ExternalSequenceBlockHash
// Using Rc to avoid cloning the HashMap for each child
type
BfsQueueEntry
=
(
SharedRadixBlock
,
Rc
<
HashMap
<
WorkerWithDpRank
,
ExternalSequenceBlockHash
>>
,
LocalBlockHash
,
);
tracing
::
debug!
(
"Dumping radix tree as events (contains information about {:?} workers)"
,
self
.lookup
.len
()
...
...
@@ -536,18 +545,17 @@ impl RadixTree {
let
mut
events
=
Vec
::
new
();
let
mut
event_id
=
0u64
;
// BFS queue: (current_block, parent_hashes_per_worker, tokens_hash)
// parent_hashes_per_worker maps WorkerWithDpRank -> ExternalSequenceBlockHash
let
mut
queue
:
VecDeque
<
(
SharedRadixBlock
,
HashMap
<
WorkerWithDpRank
,
ExternalSequenceBlockHash
>
,
LocalBlockHash
,
)
>
=
VecDeque
::
new
();
let
mut
queue
:
VecDeque
<
BfsQueueEntry
>
=
VecDeque
::
new
();
// Process root's children first
let
root_borrow
=
self
.root
.borrow
();
let
empty_parent_hashes
=
Rc
::
new
(
HashMap
::
new
());
for
(
tokens_hash
,
child_block
)
in
&
root_borrow
.children
{
queue
.push_back
((
child_block
.clone
(),
HashMap
::
new
(),
*
tokens_hash
));
queue
.push_back
((
child_block
.clone
(),
empty_parent_hashes
.clone
(),
*
tokens_hash
,
));
}
drop
(
root_borrow
);
...
...
@@ -585,11 +593,12 @@ impl RadixTree {
current_external_hashes
.insert
(
*
worker_id
,
*
external_hash
);
}
// Enqueue children with per-worker parent hashes
// Enqueue children with shared parent hashes (Rc avoids cloning HashMap)
let
parent_hashes_rc
=
Rc
::
new
(
current_external_hashes
);
for
(
child_tokens_hash
,
child_block
)
in
&
current_borrow
.children
{
queue
.push_back
((
child_block
.clone
(),
cur
rent_
external_
hashes
.clone
(),
pa
rent_hashes
_rc
.clone
(),
*
child_tokens_hash
,
));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment