core-lightning/wire/wire_io.h
Rusty Russell 0b484b111e gossipd: make more compact getchannels entries.
We can save significant space by combining both sides: so much that we
can reduce the WIRE_LEN_LIMIT to something sane again.

MCP results from 5 runs, min-max(mean +/- stddev):
	store_load_msec:34467-36764(35517.8+/-7.7e+02)
	vsz_kb:2637488
	store_rewrite_sec:35.310000-36.580000(35.816+/-0.44)
	listnodes_sec:1.140000-2.780000(1.596+/-0.6)
	listchannels_sec:55.390000-58.110000(56.998+/-0.99)
	routing_sec:30.330000-30.920000(30.642+/-0.19)
	peer_write_all_sec:50.640000-53.360000(51.822+/-0.91)

MCP notable changes from previous patch (>1 stddev):
	-store_rewrite_sec:34.720000-35.130000(34.94+/-0.14)
	+store_rewrite_sec:35.310000-36.580000(35.816+/-0.44)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-09 12:37:16 -07:00

40 lines
1.3 KiB
C

#ifndef LIGHTNING_WIRE_WIRE_IO_H
#define LIGHTNING_WIRE_WIRE_IO_H
#include "config.h"
#include <ccan/endian/endian.h>
#include <ccan/io/io.h>
#include <ccan/short_types/short_types.h>
/* We don't allow > 128M msgs: enough for more than 1M channels in gossip_getchannels_entry. */
#define WIRE_LEN_LIMIT (1 << 27)
typedef be32 wire_len_t;
#define wirelen_to_cpu be32_to_cpu
#define cpu_to_wirelen cpu_to_be32
/* Read message into *data, allocating off ctx. */
struct io_plan *io_read_wire_(struct io_conn *conn,
const tal_t *ctx,
u8 **data,
struct io_plan *(*next)(struct io_conn *, void *),
void *next_arg);
#define io_read_wire(conn, ctx, data, next, arg) \
io_read_wire_((conn), (ctx), (data), \
typesafe_cb_preargs(struct io_plan *, void *, \
(next), (arg), struct io_conn *), \
(arg))
/* Write message from data (tal_count(data) gives length). data can be take() */
struct io_plan *io_write_wire_(struct io_conn *conn,
const u8 *data,
struct io_plan *(*next)(struct io_conn *, void *),
void *next_arg);
#define io_write_wire(conn, data, next, arg) \
io_write_wire_((conn), (data), \
typesafe_cb_preargs(struct io_plan *, void *, \
(next), (arg), struct io_conn *), \
(arg))
#endif /* LIGHTNING_WIRE_WIRE_IO_H */