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