summaryrefslogtreecommitdiff
path: root/DESIGN
diff options
context:
space:
mode:
Diffstat (limited to 'DESIGN')
-rw-r--r--DESIGN39
1 files changed, 36 insertions, 3 deletions
diff --git a/DESIGN b/DESIGN
index ff37706..f058fe0 100644
--- a/DESIGN
+++ b/DESIGN
@@ -16,7 +16,7 @@ A connection carries one request and closes. Keep-alive works and is rarely
16asked for. 16asked for.
17 17
18Statistics are approximate on purpose. Counters are per thread and summed 18Statistics are approximate on purpose. Counters are per thread and summed
19when read, so a /stats read can under-report once. Nothing drifts. 19when read, so a /stats read can under-report once.
20 20
21 21
22Decisions 22Decisions
@@ -60,9 +60,44 @@ connections, the filter serves more requests than no filter, not fewer, so it
60is not the denial of service vector that FreeBSD-SA-02:26 once described. 60is not the denial of service vector that FreeBSD-SA-02:26 once described.
61 61
62 62
63The torrent table is split into 2^OT_BUCKET_COUNT_BITS buckets, 1024 by
64default, set from the Makefile. Inserting a torrent opens a slot in a sorted
65vector, so the bytes moved grow with the bucket's occupancy. Insert cost per
66torrent, Linux:
67
68 2^10 2^12 2^14 2^16
69 200k 466 ns 439 ns
70 1M 834 ns 579 ns 529 ns
71 4M 2348 ns 1163 ns 770 ns 674 ns
72
73Re-announcing an existing torrent moves by under ten per cent over the same
74range, so the cost is paid while the torrent population is built and not in
75steady state. Below a few hundred thousand torrents there is nothing to win.
762^14 captures most of the gain for two per cent more resident memory.
77
78The cleaner's wake rate does not follow the bucket count. A cap of ten wakes
79a second sets the sleep, and a wake cleans as many buckets as it must to
80finish a sweep in OT_CLEAN_INTERVAL_MINUTES. At the default bucket count that
81is one bucket every 117 ms.
82
83
63Paths not taken 84Paths not taken
64--------------- 85---------------
65 86
87A keyed hash for the bucket index. Info hashes are SHA-1 output and already
88uniform, so it changes no distribution. It would buy resistance to deliberate
89bucket flooding and cost the ordering a full scrape depends on: buckets are
90ordered by hash prefix and sorted within, so walking them emits the sorted
91dictionary bencode wants, with no sort and no copy.
92
93Cache line padding for the per-bucket locks and vector headers. The
94contention it was meant to remove is not there. On glibc, where a 48-byte
95mutex straddles a line, padding gains 3 to 8 per cent, but gains as much at
96one thread where no false sharing can exist, and scaling from one to eight
97threads is identical either way. On FreeBSD, where eight 8-byte mutexes share
98a line and the risk should be highest, padding is 15 per cent slower at one
99thread and neutral to 6 per cent slower at four and eight.
100
66accf_http, the HTTP-aware accept filter. It duplicates a parser the tracker 101accf_http, the HTTP-aware accept filter. It duplicates a parser the tracker
67has anyway, puts more kernel code in the path, and holds a connection that 102has anyway, puts more kernel code in the path, and holds a connection that
68sends "GET /" and stops, which accf_data hands straight over. 103sends "GET /" and stops, which accf_data hands straight over.
@@ -79,8 +114,6 @@ A directory for object files. bmake has no pattern rules and the Makefile
79builds under FreeBSD's make today. Building each binary in one invocation 114builds under FreeBSD's make today. Building each binary in one invocation
80clears the objects out of the tree without giving that up. 115clears the objects out of the tree without giving that up.
81 116
82A src/ directory. 52 files sharing an ot_ prefix are a module list rather
83than clutter, and build output was most of what made the tree look crowded.
84 117
85 118
86Platform differences that cost us code 119Platform differences that cost us code