Skip to content

Fix nagle, other minor optimizations #8222

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ jobs:
- name: Check
run: |
tar -xaf cln-${{ matrix.CFG }}.tar.bz2
make -j $(nproc) check-units installcheck VALGRIND=${{ matrix.VALGRIND }}
eatmydata make -j $(nproc) check-units installcheck VALGRIND=${{ matrix.VALGRIND }}

check-fuzz:
name: Run fuzz regression tests
Expand Down Expand Up @@ -343,7 +343,7 @@ jobs:
run: |
env
cat config.vars
VALGRIND=0 poetry run pytest tests/ -vvv -n ${PYTEST_PAR} ${PYTEST_OPTS}
VALGRIND=0 poetry run eatmydata pytest tests/ -vvv -n ${PYTEST_PAR} ${PYTEST_OPTS}

integration-valgrind:
name: Valgrind Test CLN ${{ matrix.name }}
Expand Down Expand Up @@ -411,7 +411,7 @@ jobs:
SLOW_MACHINE: 1
TEST_DEBUG: 1
run: |
VALGRIND=1 poetry run pytest tests/ -vvv -n 3 ${PYTEST_OPTS} ${{ matrix.PYTEST_OPTS }}
VALGRIND=1 poetry run eatmydata pytest tests/ -vvv -n 3 ${PYTEST_OPTS} ${{ matrix.PYTEST_OPTS }}

integration-sanitizers:
name: Sanitizers Test CLN
Expand Down Expand Up @@ -477,7 +477,7 @@ jobs:

- name: Test
run: |
poetry run pytest tests/ -vvv -n 2 ${PYTEST_OPTS} ${{ matrix.PYTEST_OPTS }}
poetry run eatmydata pytest tests/ -vvv -n 2 ${PYTEST_OPTS} ${{ matrix.PYTEST_OPTS }}

update-docs-examples:
name: Update examples in doc schemas
Expand Down Expand Up @@ -519,7 +519,7 @@ jobs:
tar -xaf cln-compile-gcc.tar.bz2
- name: Test
run: |
make -j $(nproc) check-doc-examples
eatmydata make -j $(nproc) check-doc-examples

min-btc-support:
name: Test minimum supported BTC v${{ matrix.MIN_BTC_VERSION }} with ${{ matrix.NAME }}
Expand Down Expand Up @@ -591,7 +591,7 @@ jobs:
run: |
env
cat config.vars
VALGRIND=0 poetry run pytest tests/ -vvv -n ${PYTEST_PAR} ${PYTEST_OPTS}
VALGRIND=0 poetry run eatmydata pytest tests/ -vvv -n ${PYTEST_PAR} ${PYTEST_OPTS}

check-flake:
name: Check Nix Flake
Expand Down
7 changes: 5 additions & 2 deletions common/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ bool daemon_developer_mode(char *argv[])
kill(getpid(), SIGSTOP);
}

/* This checks for any tal_steal loops! */
add_steal_notifiers(NULL);
/* This checks for any tal_steal loops, but it's not free:
* only use if we're already using the fairly heavy memleak
* detection. */
if (getenv("LIGHTNINGD_DEV_MEMLEAK"))
add_steal_notifiers(NULL);

return true;
}
18 changes: 3 additions & 15 deletions connectd/multiplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,6 @@ void setup_peer_gossip_store(struct peer *peer,
static void set_urgent_flag(struct peer *peer, bool urgent)
{
int val;
int opt;
const char *optname;

if (urgent == peer->urgent)
return;
Expand All @@ -318,23 +316,13 @@ static void set_urgent_flag(struct peer *peer, bool urgent)
if (peer->is_websocket != NORMAL_SOCKET)
return;

#ifdef TCP_CORK
opt = TCP_CORK;
optname = "TCP_CORK";
#elif defined(TCP_NODELAY)
opt = TCP_NODELAY;
optname = "TCP_NODELAY";
#else
#error "Please report platform with neither TCP_CORK nor TCP_NODELAY?"
#endif

val = urgent;
if (setsockopt(io_conn_fd(peer->to_peer),
IPPROTO_TCP, opt, &val, sizeof(val)) != 0
IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) != 0
/* This actually happens in testing, where we blackhole the fd */
&& peer->daemon->dev_disconnect_fd == -1) {
status_broken("setsockopt %s=1 fd=%u: %s",
optname, io_conn_fd(peer->to_peer),
status_broken("setsockopt TCP_NODELAY=1 fd=%u: %s",
io_conn_fd(peer->to_peer),
strerror(errno));
}
peer->urgent = urgent;
Expand Down
1 change: 1 addition & 0 deletions gossipd/gossipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ static void dev_gossip_memleak(struct daemon *daemon, const u8 *msg)
memleak_scan_obj(memtable, daemon);
memleak_scan_htable(memtable, &daemon->peers->raw);
dev_seeker_memleak(memtable, daemon->seeker);
gossmap_manage_memleak(memtable, daemon->gm);

found_leak = dump_memleak(memtable, memleak_status_broken, NULL);
daemon_conn_send(daemon->master,
Expand Down
8 changes: 8 additions & 0 deletions gossipd/gossmap_manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <common/daemon_conn.h>
#include <common/gossip_store.h>
#include <common/gossmap.h>
#include <common/memleak.h>
#include <common/status.h>
#include <common/timeout.h>
#include <common/wire_error.h>
Expand Down Expand Up @@ -469,6 +470,13 @@ static bool setup_gossmap(struct gossmap_manage *gm,
return true;
}

void gossmap_manage_memleak(struct htable *memtable,
const struct gossmap_manage *gm)
{
memleak_scan_uintmap(memtable, &gm->pending_ann_map.map);
memleak_scan_uintmap(memtable, &gm->early_ann_map.map);
}

struct gossmap_manage *gossmap_manage_new(const tal_t *ctx,
struct daemon *daemon)
{
Expand Down
3 changes: 3 additions & 0 deletions gossipd/gossmap_manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,7 @@ void gossmap_manage_tell_lightningd_locals(struct daemon *daemon,
* The seeker uses this if we're at startup and want complete gossip.
*/
bool gossmap_manage_populated(const struct gossmap_manage *gm);

/* For memleak to see inside of maps */
void gossmap_manage_memleak(struct htable *memtable, const struct gossmap_manage *gm);
#endif /* LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H */
30 changes: 21 additions & 9 deletions lightningd/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,14 @@ static void log_to_files(const char *log_prefix,
struct log_file **log_files)
{
char tstamp[sizeof("YYYY-mm-ddTHH:MM:SS.nnnZ ")];
char *entry, *nodestr;
char *entry, nodestr[hex_str_size(PUBKEY_CMPR_LEN)];
char buf[sizeof("%s%s%s %s-%s: %s\n")
+ strlen(log_prefix)
+ sizeof(tstamp)
+ strlen(level_prefix(level))
+ sizeof(nodestr)
+ strlen(entry_prefix)
+ strlen(str)];
bool filtered;

if (print_timestamps) {
Expand All @@ -218,9 +225,10 @@ static void log_to_files(const char *log_prefix,
tstamp[0] = '\0';

if (node_id)
nodestr = fmt_node_id(tmpctx, node_id);
hex_encode(node_id->k, sizeof(node_id->k),
nodestr, sizeof(nodestr));
else
nodestr = "";
nodestr[0] = '\0';
if (level == LOG_IO_IN || level == LOG_IO_OUT) {
const char *dir = level == LOG_IO_IN ? "[IN]" : "[OUT]";
char *hex = tal_hexstr(NULL, io, io_len);
Expand All @@ -234,14 +242,18 @@ static void log_to_files(const char *log_prefix,
entry_prefix, str, dir, hex);
tal_free(hex);
} else {
size_t len;
entry = buf;
if (!node_id)
entry = tal_fmt(tmpctx, "%s%s%s %s: %s\n",
log_prefix, tstamp, level_prefix(level), entry_prefix, str);
len = snprintf(buf, sizeof(buf),
"%s%s%s %s: %s\n",
log_prefix, tstamp, level_prefix(level), entry_prefix, str);
else
entry = tal_fmt(tmpctx, "%s%s%s %s-%s: %s\n",
log_prefix, tstamp, level_prefix(level),
nodestr,
entry_prefix, str);
len = snprintf(buf, sizeof(buf), "%s%s%s %s-%s: %s\n",
log_prefix, tstamp, level_prefix(level),
nodestr,
entry_prefix, str);
assert(len < sizeof(buf));
}

/* In complex configurations, we tell loggers to overshare: then we
Expand Down
Loading
Loading