Skip to content

cache suffixes in resource tree #1814

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 24 additions & 48 deletions zenoh/src/net/primitives/mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,12 @@
impl EPrimitives for Mux {
fn send_interest(&self, ctx: RoutingContext<Interest>) {
let interest_id = ctx.msg.id;
let ctx = RoutingContext {
msg: NetworkMessage {
body: NetworkBody::Interest(ctx.msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
},
inface: ctx.inface,
outface: ctx.outface,
prefix: ctx.prefix,
full_expr: ctx.full_expr,
};
let ctx = ctx.map_msg(|msg| NetworkMessage {
body: NetworkBody::Interest(msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
});
let prefix = ctx
.wire_expr()
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))
Expand All @@ -83,18 +77,12 @@
}

fn send_declare(&self, ctx: RoutingContext<Declare>) {
let ctx = RoutingContext {
msg: NetworkMessage {
body: NetworkBody::Declare(ctx.msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
},
inface: ctx.inface,
outface: ctx.outface,
prefix: ctx.prefix,
full_expr: ctx.full_expr,
};
let ctx = ctx.map_msg(|msg| NetworkMessage {
body: NetworkBody::Declare(msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
});
let prefix = ctx
.wire_expr()
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))
Expand Down Expand Up @@ -243,18 +231,12 @@

impl EPrimitives for McastMux {
fn send_interest(&self, ctx: RoutingContext<Interest>) {
let ctx = RoutingContext {
msg: NetworkMessage {
body: NetworkBody::Interest(ctx.msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
},
inface: ctx.inface,
outface: ctx.outface,
prefix: ctx.prefix,
full_expr: ctx.full_expr,
};
let ctx = ctx.map_msg(|msg| NetworkMessage {
body: NetworkBody::Interest(msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
});

Check warning on line 239 in zenoh/src/net/primitives/mux.rs

View check run for this annotation

Codecov / codecov/patch

zenoh/src/net/primitives/mux.rs#L234-L239

Added lines #L234 - L239 were not covered by tests
let prefix = ctx
.wire_expr()
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))
Expand All @@ -269,18 +251,12 @@
}

fn send_declare(&self, ctx: RoutingContext<Declare>) {
let ctx = RoutingContext {
msg: NetworkMessage {
body: NetworkBody::Declare(ctx.msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
},
inface: ctx.inface,
outface: ctx.outface,
prefix: ctx.prefix,
full_expr: ctx.full_expr,
};
let ctx = ctx.map_msg(|msg| NetworkMessage {
body: NetworkBody::Declare(msg),
reliability: Reliability::Reliable,
#[cfg(feature = "stats")]
size: None,
});
let prefix = ctx
.wire_expr()
.and_then(|we| (!we.has_suffix()).then(|| ctx.prefix()))
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/net/routing/dispatcher/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
.as_ref()
.and_then(|is| is.is_empty().not().then_some(is))
{
if let Ok(expr) = KeyExpr::try_from(res.expr().to_string()) {
if let Ok(expr) = KeyExpr::try_from(res.expr()) {
let cache = interceptor.compute_keyexpr_cache(&expr);
get_mut_unchecked(
get_mut_unchecked(res)
Expand All @@ -170,7 +170,7 @@
.downcast_ref::<Mux>()
.and_then(|mux| mux.interceptor.is_empty().not().then_some(mux))
{
if let Ok(expr) = KeyExpr::try_from(res.expr().to_string()) {
if let Ok(expr) = KeyExpr::try_from(res.expr()) {
let cache = mux.interceptor.compute_keyexpr_cache(&expr);
get_mut_unchecked(
get_mut_unchecked(res)
Expand All @@ -187,7 +187,7 @@
.downcast_ref::<McastMux>()
.and_then(|mux| mux.interceptor.is_empty().not().then_some(mux))
{
if let Ok(expr) = KeyExpr::try_from(res.expr().to_string()) {
if let Ok(expr) = KeyExpr::try_from(res.expr()) {

Check warning on line 190 in zenoh/src/net/routing/dispatcher/face.rs

View check run for this annotation

Codecov / codecov/patch

zenoh/src/net/routing/dispatcher/face.rs#L190

Added line #L190 was not covered by tests
let cache = mux.interceptor.compute_keyexpr_cache(&expr);
get_mut_unchecked(
get_mut_unchecked(res)
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/interests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub(crate) fn declare_interest(
let wtables = zwrite!(tables_ref.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr().to_string();
let mut fullexpr = prefix.expr();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
1 change: 1 addition & 0 deletions zenoh/src/net/routing/dispatcher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ pub mod interests;
pub mod pubsub;
pub mod queries;
pub mod resource;
pub(crate) mod suffix;
pub mod tables;
pub mod token;
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub(crate) fn declare_subscription(
let wtables = zwrite!(tables.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr().to_string();
let mut fullexpr = prefix.expr();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub(crate) fn declare_queryable(
let wtables = zwrite!(tables.tables);
(res.unwrap(), wtables)
} else {
let mut fullexpr = prefix.expr().to_string();
let mut fullexpr = prefix.expr();
fullexpr.push_str(expr.suffix.as_ref());
let mut matches = keyexpr::new(fullexpr.as_str())
.map(|ke| Resource::get_matches(&rtables, ke))
Expand Down
Loading