Skip to content

Commit

Permalink
fix: precise query id rollover semantic (#1606)
Browse files Browse the repository at this point in the history
* fix: use slab instead of hashmap + atomic counter

Allow managing rollover and uniqueness, as well as being faster to access.

* fix: rollback session modification

* Revert "fix: rollback session modification"

This reverts commit a2b1583.

* Revert "fix: use slab instead of hashmap + atomic counter"

This reverts commit 3290782.

* fix: precise query id rollover semantic
  • Loading branch information
wyfo authored Jan 30, 2025
1 parent 6f7c089 commit ba64d7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zenoh/src/net/routing/dispatcher/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ pub(crate) fn undeclare_queryable(
#[inline]
fn insert_pending_query(outface: &mut Arc<FaceState>, query: Arc<Query>) -> RequestId {
let outface_mut = get_mut_unchecked(outface);
outface_mut.next_qid += 1;
// This `wrapping_add` is kind of "safe" because it would require an incredible amount
// of parallel running queries to conflict a currently used id.
// However, query ids are encoded with varint algorithm, so an incremental id isn't a
// good match, and there is still room for optimization.
outface_mut.next_qid = outface_mut.next_qid.wrapping_add(1);
let qid = outface_mut.next_qid;
outface_mut.pending_queries.insert(
qid,
Expand Down

0 comments on commit ba64d7a

Please sign in to comment.