diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-07 03:55:27 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-07 03:55:27 +0100 |
| commit | bbfd674e08c6b1fa4081f9c678fd220bead749d7 (patch) | |
| tree | 41c279103efda2765217a26c8164817d3db96606 /DESIGN | |
| parent | f18339a50eed09ed47b2b22212d2a50e543e9b09 (diff) | |
Start to opentracker's memory requirements
* peer lists for v4 and v6 are now lazily allocated and, more importantly, will be freed once there are no more peers
* The downloaded count is now per torrent and not per peer list anymore, moving in what was alignment loss, anyway
* The (now) per torrent downloaded and the per peer list peer and seed count shrunk from size_t to uint32_t
* A helper guards accesses to the peer and seed count to prevent null pointer dereferences
* The base time also shrank from time_t to uint32_t, minutes since the epoch currently fits in 25 bits
Diffstat (limited to 'DESIGN')
| -rw-r--r-- | DESIGN | 19 |
1 files changed, 19 insertions, 0 deletions
| @@ -84,6 +84,25 @@ finish a sweep in OT_CLEAN_INTERVAL_MINUTES. At the default bucket count that | |||
| 84 | is one bucket every 117 ms. | 84 | is one bucket every 117 ms. |
| 85 | 85 | ||
| 86 | 86 | ||
| 87 | A torrent carries its hash, two peer-list pointers, a base and a down count, | ||
| 88 | 48 bytes on a 64-bit host, and the down count sits in what would otherwise be | ||
| 89 | alignment padding. Each family's peer list, 32 bytes plus its peer vector, is | ||
| 90 | allocated on that family's first peer and freed when its last peer goes. The | ||
| 91 | base and the down count live on the torrent rather than on a list, which is | ||
| 92 | what lets a list come and go: a torrent kept only for its download count holds | ||
| 93 | no list at all, and a single-family torrent holds one rather than two. | ||
| 94 | |||
| 95 | This is paid for in the common shape of a large table. A tracker carrying | ||
| 96 | millions of torrents averages close to two peers each, a few crowded swarms | ||
| 97 | over a long tail of near-empty ones, so fixed per-torrent cost, not peer | ||
| 98 | payload, is most of resident memory. Allocating both lists for every torrent | ||
| 99 | and keeping an idle torrent alive for a day to preserve one counter cost, on | ||
| 100 | glibc, 168 bytes per torrent before a peer; the layout above costs 48 for an | ||
| 101 | empty torrent and 96 for a single-family one. The per-torrent counts are | ||
| 102 | uint32: no single torrent holds 2^32 peers, and the four bytes saved against a | ||
| 103 | size_t are multiplied by the torrent count. Global totals stay 64-bit. | ||
| 104 | |||
| 105 | |||
| 87 | A refused announce is answered over UDP with a well formed announce for an | 106 | A refused announce is answered over UDP with a well formed announce for an |
| 88 | empty swarm rather than with the error action. BEP 15 binds a client to the | 107 | empty swarm rather than with the error action. BEP 15 binds a client to the |
| 89 | interval it is handed and says nothing about what a client should do with an | 108 | interval it is handed and says nothing about what a client should do with an |
