Skip to content

Commit

Permalink
Remove copy_on_multi_recv option and use single field
Browse files Browse the repository at this point in the history
  • Loading branch information
soumagne committed Jul 25, 2024
1 parent 7a7fd81 commit 06cd04c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 37 deletions.
39 changes: 14 additions & 25 deletions src/mercury_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ struct hg_core_init_info {
bool na_ext_init; /* NA externally initialized */
bool multi_recv; /* Use multi-recv capability */
bool listen; /* Listening on incoming RPC requests */
bool copy_on_multi_recv; /* Copy data on multi-recv */
};

/* RPC map */
Expand Down Expand Up @@ -1245,22 +1244,17 @@ hg_core_init(const char *na_info_string, bool na_listen, unsigned int version,
hg_core_class->init_info.multi_recv_op_max =
(hg_init_info.multi_recv_op_max == 0) ? HG_CORE_MULTI_RECV_OP_COUNT
: hg_init_info.multi_recv_op_max;
hg_core_class->init_info.copy_on_multi_recv =
hg_init_info.copy_on_multi_recv;
if (hg_core_class->init_info.copy_on_multi_recv) {
HG_CHECK_SUBSYS_ERROR(cls,
hg_init_info.multi_recv_copy_threshold >
(unsigned int) hg_core_class->init_info.multi_recv_op_max,
error, ret, HG_INVALID_ARG,
"multi_recv_copy_threshold (%u) cannot exceed multi_recv_op_max "
"(%u)",
hg_init_info.multi_recv_copy_threshold,
(unsigned int) hg_core_class->init_info.multi_recv_op_max);
hg_core_class->init_info.multi_recv_copy_threshold =
hg_init_info.multi_recv_copy_threshold;
} else
hg_core_class->init_info.multi_recv_copy_threshold =
hg_core_class->init_info.multi_recv_op_max; /* never copy */

HG_CHECK_SUBSYS_ERROR(cls,
hg_init_info.multi_recv_copy_threshold >
(unsigned int) hg_core_class->init_info.multi_recv_op_max,
error, ret, HG_INVALID_ARG,
"multi_recv_copy_threshold (%u) cannot exceed multi_recv_op_max "
"(%u)",
hg_init_info.multi_recv_copy_threshold,
(unsigned int) hg_core_class->init_info.multi_recv_op_max);
hg_core_class->init_info.multi_recv_copy_threshold =
hg_init_info.multi_recv_copy_threshold;

#ifdef HG_HAS_CHECKSUMS
/* Save checksum level */
Expand Down Expand Up @@ -1907,7 +1901,7 @@ hg_core_context_post(struct hg_core_private_context *context)
HG_CHECK_SUBSYS_HG_ERROR(
ctx, error, ret, "Could not allocate multi-recv resources");
flags |= HG_CORE_HANDLE_MULTI_RECV;
if (hg_core_class->init_info.copy_on_multi_recv)
if (hg_core_class->init_info.multi_recv_copy_threshold > 0)
flags |= HG_CORE_HANDLE_MULTI_RECV_COPY;
}

Expand Down Expand Up @@ -4543,10 +4537,6 @@ hg_core_multi_recv_input_cb(const struct na_cb_info *callback_info)
hg_return_t ret;

if (callback_info->ret == NA_SUCCESS) {
unsigned int copy_threshold =
HG_CORE_CONTEXT_CLASS(context)->init_info.multi_recv_op_max -
HG_CORE_CONTEXT_CLASS(context)->init_info.multi_recv_copy_threshold;

/* Get a new handle from the pool */
ret = hg_core_handle_pool_get(context->handle_pool, &hg_core_handle);
HG_CHECK_SUBSYS_HG_ERROR(
Expand All @@ -4557,9 +4547,8 @@ hg_core_multi_recv_input_cb(const struct na_cb_info *callback_info)
/* Prevent from reposting multi-recv buffer until done with handle */
hg_atomic_incr32(&multi_recv_op->ref_count);
hg_core_handle->multi_recv_copy =
(HG_CORE_CONTEXT_CLASS(context)->init_info.copy_on_multi_recv &&
(hg_atomic_get32(&context->multi_recv_op_count) <=
(int32_t) copy_threshold));
(unsigned int) hg_atomic_get32(&context->multi_recv_op_count) <=
HG_CORE_CONTEXT_CLASS(context)->init_info.multi_recv_copy_threshold;

if (na_cb_info_multi_recv_unexpected->last) {
HG_LOG_SUBSYS_DEBUG(rpc,
Expand Down
17 changes: 5 additions & 12 deletions src/mercury_core_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,11 @@ struct hg_init_info {
* Default value is: 4 */
unsigned int multi_recv_op_max;

/* Force copy when receiving RPCs and multi-recv is being used (in an effort
* to release multi-recv buffers as soon as possible). This is particularly
* useful in large scale situations where multi-recv buffers tend to be
* quickly exhausted.
* Default value is: false */
bool copy_on_multi_recv;

/* When using copy_on_multi_recv, controls when we should start copying data
* in an effort to release multi-recv buffers. Copy will start when
* multi_recv_copy_threshold buffers have been consumed. Value should not
* exceed multi_recv_op_max.
* Default value is: 0 (always copy) */
* in an effort to release multi-recv buffers. Copy will occur when at most
* multi_recv_copy_threshold buffers remain. Value should not exceed
* multi_recv_op_max.
* Default value is: 0 (never copy) */
unsigned int multi_recv_copy_threshold;
};

Expand Down Expand Up @@ -219,7 +212,7 @@ typedef enum {
.no_bulk_eager = false, .no_loopback = false, .stats = false, \
.no_multi_recv = false, .release_input_early = false, \
.no_overflow = false, .multi_recv_op_max = 0, \
.copy_on_multi_recv = false, .multi_recv_copy_threshold = 0 \
.multi_recv_copy_threshold = 0 \
}

#endif /* MERCURY_CORE_TYPES_H */

0 comments on commit 06cd04c

Please sign in to comment.