Skip to content
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

Improve query/reply perf #781

Merged
merged 30 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
403bfe9
fix: remove superfluous rc init
jean-roland Nov 6, 2024
a1a7397
feat: lazify svec release
jean-roland Nov 6, 2024
c0c1127
refactor: rename slice_empty as slice_null
jean-roland Nov 6, 2024
f4183a9
feat: rework svec expand
jean-roland Nov 6, 2024
7c63b6d
refactor: z_bytes_append_slice
jean-roland Nov 6, 2024
e5f88a4
feat: lazify arc slice
jean-roland Nov 6, 2024
7ac84dd
feat: improve stirng/slice move
jean-roland Nov 6, 2024
48be0d9
feat: lazify sample timestamp set
jean-roland Nov 6, 2024
1c888ad
feat: add non-reader decode functions
jean-roland Nov 7, 2024
49c2995
feat: remove superfluous keyexpr clear
jean-roland Nov 7, 2024
f870c1e
feat: add bytes alias arc
jean-roland Nov 7, 2024
f68e8d3
feat: add rx pool size config option
jean-roland Nov 7, 2024
4dc26c7
feat: use transport arc slice pool for payload decode
jean-roland Nov 8, 2024
e651026
feat: n msg svec is now a transport resource pool
jean-roland Nov 8, 2024
460bde1
fix: add offset to svec init
jean-roland Nov 8, 2024
0fb2428
feat: make svec use elem f a per call arg
jean-roland Nov 9, 2024
bd76c0f
feat: skip ke suffix check
jean-roland Nov 9, 2024
e4d1a92
fix: arc pool
jean-roland Nov 9, 2024
6393266
feat: improve sub perf and readability
jean-roland Nov 9, 2024
0f6d48f
feat: add z_string_alias_slice function
jean-roland Nov 9, 2024
49fd11e
feat: align queryable with subscription
jean-roland Nov 9, 2024
4ebfe6d
feat: align reply with sub & queryables
jean-roland Nov 9, 2024
e73e357
feat: nothing to clear in frame
jean-roland Nov 9, 2024
a654849
fix: reply clean up
jean-roland Nov 9, 2024
10a7c2a
feat: streamline replies
jean-roland Nov 9, 2024
b59d97d
feat: query is not a rc and store a session rc
jean-roland Nov 10, 2024
8772aae
fix: ci issues
jean-roland Nov 10, 2024
e29eae5
fix: attachment examples
jean-roland Nov 13, 2024
bc5f1ea
fix: keyexpr equals
jean-roland Nov 13, 2024
63123b9
fix: flaky test
jean-roland Nov 13, 2024
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
7 changes: 3 additions & 4 deletions examples/unix/c11/z_get_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ void reply_handler(z_loaned_reply_t *reply, void *ctx) {

// Check attachment
const z_loaned_bytes_t *attachment = z_sample_attachment(sample);
if (attachment == NULL) {
return;
}
ze_deserializer_t deserializer = ze_deserializer_from_bytes(attachment);
size_t attachment_len;
ze_deserializer_deserialize_sequence_length(&deserializer, &attachment_len);
if (ze_deserializer_deserialize_sequence_length(&deserializer, &attachment_len) < 0) {
return;
}
kv_pair_t *kvp = (kv_pair_t *)malloc(sizeof(kv_pair_t) * attachment_len);
for (size_t i = 0; i < attachment_len; ++i) {
ze_deserializer_deserialize_string(&deserializer, &kvp[i].key);
Expand Down
7 changes: 3 additions & 4 deletions examples/unix/c11/z_queryable_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ void query_handler(z_loaned_query_t *query, void *ctx) {

// Check attachment
const z_loaned_bytes_t *attachment = z_query_attachment(query);
if (attachment != NULL) {
ze_deserializer_t deserializer = ze_deserializer_from_bytes(attachment);
size_t attachment_len;
ze_deserializer_deserialize_sequence_length(&deserializer, &attachment_len);
ze_deserializer_t deserializer = ze_deserializer_from_bytes(attachment);
size_t attachment_len;
if (ze_deserializer_deserialize_sequence_length(&deserializer, &attachment_len) == Z_OK) {
kv_pair_t *kvp = (kv_pair_t *)malloc(sizeof(kv_pair_t) * attachment_len);
for (size_t i = 0; i < attachment_len; ++i) {
ze_deserializer_deserialize_string(&deserializer, &kvp[i].key);
Expand Down
8 changes: 3 additions & 5 deletions examples/unix/c11/z_sub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ void data_handler(z_loaned_sample_t *sample, void *ctx) {
printf(" with timestamp: %" PRIu64 "\n", z_timestamp_ntp64_time(ts));
}
// Check attachment

const z_loaned_bytes_t *attachment = z_sample_attachment(sample);
if (attachment != NULL) {
ze_deserializer_t deserializer = ze_deserializer_from_bytes(attachment);
size_t attachment_len;
ze_deserializer_deserialize_sequence_length(&deserializer, &attachment_len);
ze_deserializer_t deserializer = ze_deserializer_from_bytes(attachment);
size_t attachment_len;
if (ze_deserializer_deserialize_sequence_length(&deserializer, &attachment_len) == Z_OK) {
kv_pair_t *kvp = (kv_pair_t *)malloc(sizeof(kv_pair_t) * attachment_len);
for (size_t i = 0; i < attachment_len; ++i) {
ze_deserializer_deserialize_string(&deserializer, &kvp[i].key);
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ _Z_OWNED_TYPE_VALUE(_z_queryable_t, queryable)
/**
* Represents a Zenoh Query entity, received by Zenoh Queryable entities.
*/
_Z_OWNED_TYPE_RC(_z_query_rc_t, query)
_Z_OWNED_TYPE_VALUE(_z_query_t, query)

/**
* Represents the encoding of a payload, in a MIME-like format.
Expand Down
6 changes: 5 additions & 1 deletion include/zenoh-pico/collections/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inline size_t _z_arc_slice_size(const _z_arc_slice_t *s) {
return sizeof(_z_arc_slice_t);
}
_Z_ELEM_DEFINE(_z_arc_slice, _z_arc_slice_t, _z_arc_slice_size, _z_arc_slice_drop, _z_arc_slice_copy, _z_arc_slice_move)
_Z_SVEC_DEFINE(_z_arc_slice, _z_arc_slice_t, true)
_Z_SVEC_DEFINE(_z_arc_slice, _z_arc_slice_t)

/*-------- Bytes --------*/
/**
Expand All @@ -44,13 +44,17 @@ typedef struct {

// Warning: None of the sub-types require a non-0 initialization. Add a init function if it changes.
static inline _z_bytes_t _z_bytes_null(void) { return (_z_bytes_t){0}; }
static inline void _z_bytes_alias_arc_slice(_z_bytes_t *dst, _z_arc_slice_t *s) {
dst->_slices = _z_arc_slice_svec_alias_element(s);
}
bool _z_bytes_check(const _z_bytes_t *bytes);
z_result_t _z_bytes_append_bytes(_z_bytes_t *dst, _z_bytes_t *src);
z_result_t _z_bytes_append_slice(_z_bytes_t *dst, _z_arc_slice_t *s);
z_result_t _z_bytes_copy(_z_bytes_t *dst, const _z_bytes_t *src);
_z_bytes_t _z_bytes_duplicate(const _z_bytes_t *src);
void _z_bytes_move(_z_bytes_t *dst, _z_bytes_t *src);
void _z_bytes_drop(_z_bytes_t *bytes);
void _z_bytes_aliased_drop(_z_bytes_t *bytes);
void _z_bytes_free(_z_bytes_t **bs);
size_t _z_bytes_num_slices(const _z_bytes_t *bs);
_z_arc_slice_t *_z_bytes_get_slice(const _z_bytes_t *bs, size_t i);
Expand Down
27 changes: 10 additions & 17 deletions include/zenoh-pico/collections/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ size_t _z_simple_rc_strong_count(void *cnt);
return p; \
} \
static inline name##_rc_t name##_rc_clone(const name##_rc_t *p) { \
name##_rc_t c = name##_rc_null(); \
if (_z_rc_increase_strong(p->_cnt) == _Z_RES_OK) { \
c = *p; \
return *p; \
} \
return c; \
return name##_rc_null(); \
} \
static inline name##_rc_t *name##_rc_clone_as_ptr(const name##_rc_t *p) { \
name##_rc_t *c = (name##_rc_t *)z_malloc(sizeof(name##_rc_t)); \
Expand All @@ -93,12 +92,10 @@ size_t _z_simple_rc_strong_count(void *cnt);
return c; \
} \
static inline name##_weak_t name##_rc_clone_as_weak(const name##_rc_t *p) { \
name##_weak_t c = name##_weak_null(); \
if (_z_rc_increase_weak(p->_cnt) == _Z_RES_OK) { \
c._val = p->_val; \
c._cnt = p->_cnt; \
return (name##_weak_t){._val = p->_val, ._cnt = p->_cnt}; \
} \
return c; \
return name##_weak_null(); \
} \
static inline name##_weak_t *name##_rc_clone_as_weak_ptr(const name##_rc_t *p) { \
name##_weak_t *c = (name##_weak_t *)z_malloc(sizeof(name##_weak_t)); \
Expand Down Expand Up @@ -137,20 +134,17 @@ size_t _z_simple_rc_strong_count(void *cnt);
return res; \
} \
static inline name##_weak_t name##_weak_clone(const name##_weak_t *p) { \
name##_weak_t c = name##_weak_null(); \
if (_z_rc_increase_weak(p->_cnt) == _Z_RES_OK) { \
c = *p; \
return *p; \
} \
return c; \
return name##_weak_null(); \
} \
static inline void name##_weak_copy(name##_weak_t *dst, const name##_weak_t *p) { *dst = name##_weak_clone(p); } \
static inline name##_rc_t name##_weak_upgrade(const name##_weak_t *p) { \
name##_rc_t c = name##_rc_null(); \
if (_z_rc_weak_upgrade(p->_cnt) == _Z_RES_OK) { \
c._val = p->_val; \
c._cnt = p->_cnt; \
return (name##_rc_t){._val = p->_val, ._cnt = p->_cnt}; \
} \
return c; \
return name##_rc_null(); \
} \
static inline bool name##_weak_eq(const name##_weak_t *left, const name##_weak_t *right) { \
return (left->_val == right->_val); \
Expand Down Expand Up @@ -200,11 +194,10 @@ size_t _z_simple_rc_strong_count(void *cnt);
return p; \
} \
static inline name##_simple_rc_t name##_simple_rc_clone(const name##_simple_rc_t *p) { \
name##_simple_rc_t c = name##_simple_rc_null(); \
if (_z_simple_rc_increase(p->_cnt) == _Z_RES_OK) { \
c = *p; \
return *p; \
} \
return c; \
return name##_simple_rc_null(); \
} \
static inline name##_simple_rc_t *name##_simple_rc_clone_as_ptr(const name##_simple_rc_t *p) { \
name##_simple_rc_t *c = (name##_simple_rc_t *)z_malloc(sizeof(name##_simple_rc_t)); \
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/collections/slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ typedef struct {
_z_delete_context_t _delete_context;
} _z_slice_t;

static inline _z_slice_t _z_slice_empty(void) { return (_z_slice_t){0}; }
static inline void _z_slice_reset(_z_slice_t *bs) { *bs = _z_slice_empty(); }
static inline _z_slice_t _z_slice_null(void) { return (_z_slice_t){0}; }
static inline void _z_slice_reset(_z_slice_t *bs) { *bs = _z_slice_null(); }
static inline bool _z_slice_is_empty(const _z_slice_t *bs) { return bs->len == 0; }
static inline bool _z_slice_check(const _z_slice_t *slice) { return slice->start != NULL; }
static inline _z_slice_t _z_slice_alias(const _z_slice_t bs) {
Expand Down
3 changes: 2 additions & 1 deletion include/zenoh-pico/collections/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static inline _z_string_t _z_string_alias(const _z_string_t str) {
_z_string_t _z_string_copy_from_str(const char *value);
_z_string_t _z_string_copy_from_substr(const char *value, size_t len);
_z_string_t *_z_string_copy_from_str_as_ptr(const char *value);
_z_string_t _z_string_alias_slice(const _z_slice_t *slice);
_z_string_t _z_string_alias_str(const char *value);
_z_string_t _z_string_alias_substr(const char *value, size_t len);
_z_string_t _z_string_from_str_custom_deleter(char *value, _z_delete_context_t c);
Expand All @@ -98,7 +99,7 @@ _z_string_t _z_string_convert_bytes(const _z_slice_t *bs);
_z_string_t _z_string_preallocate(const size_t len);

_Z_ELEM_DEFINE(_z_string, _z_string_t, _z_string_len, _z_string_clear, _z_string_copy, _z_string_move)
_Z_SVEC_DEFINE(_z_string, _z_string_t, true)
_Z_SVEC_DEFINE(_z_string, _z_string_t)
_Z_LIST_DEFINE(_z_string, _z_string_t)
_Z_INT_MAP_DEFINE(_z_string, _z_string_t)

Expand Down
Loading
Loading