Skip to content

Commit 078ba6a

Browse files
committed
broker: use msg_route_sendto()
Problem: broker event mcast to downstream peers does a malloc for each peer, and has been shown to be a performance hot spot. Use the new msg_route_sendto() helper which avoids the malloc.
1 parent 71fc0d5 commit 078ba6a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/broker/overlay.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "src/common/libutil/monotime.h"
3737
#include "src/common/libutil/errprintf.h"
3838
#include "src/common/librouter/rpc_track.h"
39+
#include "src/common/libflux/message_route.h" // for msg_route_sendto()
3940
#include "ccan/str/str.h"
4041

4142
#include "overlay.h"
@@ -851,17 +852,11 @@ static int overlay_sendmsg_child (struct overlay *ov, const flux_msg_t *msg)
851852
return rc;
852853
}
853854

854-
/* Push child->uuid onto the message, then pop it off again after sending.
855-
*/
856-
static int overlay_mcast_child_one (struct overlay *ov,
857-
flux_msg_t *msg,
858-
struct child *child)
855+
// callback for msg_route_sendto()
856+
static int overlay_mcast_send (const flux_msg_t *msg, void *arg)
859857
{
860-
if (flux_msg_route_push (msg, child->uuid) < 0)
861-
return -1;
862-
int rc = overlay_sendmsg_child (ov, msg);
863-
(void)flux_msg_route_delete_last (msg);
864-
return rc;
858+
struct overlay *ov = arg;
859+
return overlay_sendmsg_child (ov, msg);
865860
}
866861

867862
static void overlay_mcast_child (struct overlay *ov, flux_msg_t *msg)
@@ -873,7 +868,10 @@ static void overlay_mcast_child (struct overlay *ov, flux_msg_t *msg)
873868

874869
foreach_overlay_child (ov, child) {
875870
if (subtree_is_online (child->status)) {
876-
if (overlay_mcast_child_one (ov, msg, child) < 0) {
871+
if (msg_route_sendto (msg,
872+
child->uuid,
873+
overlay_mcast_send,
874+
ov) < 0) {
877875
if (errno != EHOSTUNREACH) {
878876
flux_log_error (ov->h,
879877
"mcast error to child rank %lu",

0 commit comments

Comments
 (0)