From 589cb500fa5a6df13fa9634d0071922ec11fce17 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 7 Nov 2026 19:39:01 +0100 Subject: Unify the peerlists for v4 and v6 This commit finishes what started with unifying v4 and v6 trackers, from then on, torrents carried a peer list per family, with obvious redundancies. With the race to save memory, these became burdening enough that now these peerlist pointers have been moved into a single struct, holding both v4 and v6 peers in their respective ot_vectors, so the per- torrent cost shrunk by another pointer's size. Each peerlist also lost its peer count cache, as in most cases, it's trivial to load it directly from the ot_vector's entry count. The seed counts that were kept per family only to be aggregated later for every consumer, are also merged now. Total savings depend on the tracker's actual load. In some corner cases, where only one address family dominates the torrents, we actually use a few bytes more in the ot_vector for the absent family, but even that mostly becomes noise: before it actually adds to the memory load, the peer payload will be the deciding factor. Most wins are on what often is experienced on trackers: A long tail of abandoned torrents now needs eight fewer bytes, slipping into a smaller allocation unit on glibc's allocator. --- src/ot_vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ot_vector.h') diff --git a/src/ot_vector.h b/src/ot_vector.h index 8a5ba86..1a73fcf 100644 --- a/src/ot_vector.h +++ b/src/ot_vector.h @@ -32,7 +32,7 @@ int vector_remove_peer(ot_vector *vector, ot_peer const *peer, size_t peer_ void vector_remove_torrent(ot_vector *vector, ot_torrent *match); /* For ot_clean.c */ -void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size); +void vector_redistribute_buckets(ot_vector *peer_vector, size_t peer_size, size_t peer_count); void vector_fixup_peers(ot_vector *vector, size_t peer_size); void vector_clean_list(ot_vector *vector, size_t num_buckets); -- cgit v1.3