Skip to content

Commit

Permalink
Improve ZRuntime (#893)
Browse files Browse the repository at this point in the history
* Use minimal one worker for each ZRuntime as the default value

* Introduce proc_macros to manage ZRuntime

* Remove ZRuntimePoolGuard and use libc::atexit to clean up the static variables

* Update comments

* Enable to get RuntimeParam from ZRuntime

* cargo fmt

* Use Enum type to specify which runtime to be handed over and hence remove the unneeded lifetime.

* Test the limit of ZRuntime

* Trigger CI

* Revert "Test the limit of ZRuntime"

This reverts commit a712240.

* Test the limit of ZRuntime again

* Revert "Test the limit of ZRuntime again"

This reverts commit 71e2fab.

* Fix the deadlock of `session_ext::Arc<Session>::declare_publication_cache` in zenoh-ext/src/session_ext.rs

* Correct CI workflow

* Use timeout-minutes

* Use the whole doc test

* Revert the changes on CI

* Test the limit of ZRuntime

* Use one-line env

* alias => rename

* Refine the traits and add some doc

* Update the documentation

* Use workspace dependencies

* Add the missing dependence "ron"

* Remove the optimal ZRuntime configuration

* Tidy up

* Cargo fmt

* Typo

* Make zenoh-runtime-derive be part of workspace

* Append the missing Cargo.toml

* Move zenoh-runtime-derive into zenoh-macros

* Ignore doc test of zenoh-runtime-derive in zenoh-macros

* Test with macos-14

* Grid search the paramters

* fixup! Grid search the paramters

* fixup! Grid search the paramters

* Set rx=2

* Optimize the worker threads

* Raise RX worker threads to 2 to tackle the failure on macos-14.
  • Loading branch information
YuanYuYuan authored Apr 19, 2024
1 parent 2c7e3c4 commit 0283aaa
Show file tree
Hide file tree
Showing 8 changed files with 490 additions and 150 deletions.
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# By default, retry a few times until pass the test within the specified timeout
[profile.default]
retries = 4
retries = 1
slow-timeout = { period = "60s", terminate-after = 2 }

# Run the following tests exclusively with longer timeout
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ rand = { version = "0.8.5", default-features = false } # Default features are di
rand_chacha = "0.3.1"
rcgen = "0.11"
regex = "1.7.1"
ron = "0.8.1"
ringbuffer-spsc = "0.1.9"
rsa = "0.9"
rustc_version = "0.4.0"
Expand Down
2 changes: 0 additions & 2 deletions ci/valgrind-check/src/pub_sub/bin/z_pub_sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ use zenoh::prelude::r#async::*;
async fn main() {
zenoh_util::init_log_test();

let _z = zenoh_runtime::ZRuntimePoolGuard;

let pub_key_expr = KeyExpr::try_from("test/valgrind/data").unwrap();
let sub_key_expr = KeyExpr::try_from("test/valgrind/**").unwrap();

Expand Down
2 changes: 0 additions & 2 deletions ci/valgrind-check/src/queryable_get/bin/z_queryable_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ use zenoh::prelude::r#async::*;
async fn main() {
zenoh_util::init_log_test();

let _z = zenoh_runtime::ZRuntimePoolGuard;

let queryable_key_expr = KeyExpr::try_from("test/valgrind/data").unwrap();
let get_selector = Selector::try_from("test/valgrind/**").unwrap();

Expand Down
35 changes: 35 additions & 0 deletions commons/zenoh-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,38 @@ pub fn ke(tokens: TokenStream) -> TokenStream {
Err(e) => panic!("{}", e),
}
}

mod zenoh_runtime_derive;
use syn::DeriveInput;
use zenoh_runtime_derive::{derive_generic_runtime_param, derive_register_param};

/// Make the underlying struct `Param` be generic over any `T` satifying a generated `trait DefaultParam { fn param() -> Param; }`
/// ```rust,ignore
/// #[derive(GenericRuntimeParam)]
/// struct Param {
/// ...
/// }
/// ```
#[proc_macro_derive(GenericRuntimeParam)]
pub fn generic_runtime_param(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input: DeriveInput = syn::parse_macro_input!(input);
derive_generic_runtime_param(input)
.unwrap_or_else(syn::Error::into_compile_error)
.into()
}

/// Register the input `Enum` with the struct `Param` specified in the param attribute
/// ```rust,ignore
/// #[derive(RegisterParam)]
/// #[param(Param)]
/// enum Enum {
/// ...
/// }
/// ```
#[proc_macro_derive(RegisterParam, attributes(alias, param))]
pub fn register_param(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input: DeriveInput = syn::parse_macro_input!(input);
derive_register_param(input)
.unwrap_or_else(syn::Error::into_compile_error)
.into()
}
Loading

0 comments on commit 0283aaa

Please sign in to comment.