Skip to content

Commit

Permalink
wire: optimize sending packets now we can return EAGAIN.
Browse files Browse the repository at this point in the history
Interestingly, this patch and the last take my total test time on my
build machine down by about 10%.  From 403.93s (0:06:43) to 366.64s (0:06:06)
though there were some unrelated errors.

Changelog-Changed: connectd: I/O optimizations to significantly speed up larger nodes.
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and ShahanaFarooqui committed Jul 2, 2024
1 parent 341b62e commit eb1c04e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions wire/wire_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ static int do_read_wire(int fd, struct io_plan_arg *arg)
ssize_t ret;

/* Still reading header? */
if (arg->u2.s & INSIDE_HEADER_BIT)
return do_read_wire_header(fd, arg);
if (arg->u2.s & INSIDE_HEADER_BIT) {
ret = do_read_wire_header(fd, arg);
/* If this is OK, and finished header, we continue below. */
if (ret != 0 || (arg->u2.s & INSIDE_HEADER_BIT))
return ret;
}

/* Normal read */
ret = read(fd, arg->u1.cp, arg->u2.s);
Expand Down Expand Up @@ -107,8 +111,12 @@ static int do_write_wire(int fd, struct io_plan_arg *arg)
size_t totlen = tal_bytelen(arg->u1.cp);

/* Still writing header? */
if (arg->u2.s & INSIDE_HEADER_BIT)
return do_write_wire_header(fd, arg);
if (arg->u2.s & INSIDE_HEADER_BIT) {
ret = do_write_wire_header(fd, arg);
/* If this is OK, and finished header, we continue below. */
if (ret != 0 || (arg->u2.s & INSIDE_HEADER_BIT))
return ret;
}

/* Normal write */
ret = write(fd, arg->u1.cp + arg->u2.s, totlen - arg->u2.s);
Expand Down

0 comments on commit eb1c04e

Please sign in to comment.