stats can be gathered.
Basically, it counts hits+misses and writes them out every 15 minutes. Every
hour would be fine in my case, but if someone wanted to test with 1 torrent on a high
speed download, given that a 300-800MB torrent can be downloaded (@~3MB/s...) in a few to several minutes, finer granularity might be wanted as well (like every 30seconds in that case). So
the time period might default to 60 minutes, but if _TRX_STAT_DELAY_ is set
in env, then use it as # of seconds between updates?
This is in cache.c: (line numbers and formatting may be different but shouldn't
be hard to adjust (I'd hope, if a prob can like produce a diff against cur release
or cur source...
Code: Select all
--- cache.c 2014-05-18 13:52:14.000000000 -0700
+++ cache.c 2014-06-15 17:09:08.000000000 -0700
@@ -20,6 +20,7 @@
#include "torrent.h"
#include "trevent.h"
#include "utils.h"
+#include <unistd.h>
#define MY_NAME "Cache"
@@ -191,8 +192,7 @@
err = flushContiguous(cache, runs[i].pos, runs[i].len);
for (j = i + 1; j < n; j++)
- if (runs[j].pos > runs[i].pos)
- runs[j].pos -= runs[i].len;
+ if (runs[j].pos > runs[i].pos) runs[j].pos -= runs[i].len;
}
return err;
@@ -321,18 +311,34 @@
return cacheTrim(cache);
}
+int cache_hits, cache_misses;
+time_t logtime;
+# include <stdio.h>
+# include <fcntl.h>
+
int
-tr_cacheReadBlock(tr_cache * cache,
- tr_torrent * torrent,
+tr_cacheReadBlock(tr_cache * cache, tr_torrent * torrent,
tr_piece_index_t piece,
uint32_t offset, uint32_t len, uint8_t * setme) {
int err = 0;
struct cache_block *cb = findBlock(cache, torrent, piece, offset);
+ time_t now;
+
+ time(&now);
+ if (!logtime || now-logtime > 60*15 ) {
+ tr_logAddTorInfo(torrent, "[%ld], Cache H,M=%d,%d\n",
+ now, cache_hits, cache_misses);
+ logtime=now;
+ //close(fileh);
+ }
- if (cb)
+ if (cb) {
+ ++cache_hits;
evbuffer_copyout(cb->evbuf, setme, len);
- else
+ } else {
+ ++cache_misses ;
err = tr_ioRead(torrent, piece, offset, len, setme);
+ }
return err;
}
It's fairly trivial code... finding it's output in the log was a
matter of grepping for the lin -- but used perl to reduce it (as it comes out at the
end of a line):
So wrote a perl script to reduce output of my logs and added option[2014-06-14 16:35:13.754 PDT] Sample-linux-dist-tor.iso.xz [1402788913], Cache H,M=1992567,5111910
to only put out results once/hour, 4x/day or 2x/day.
----cache_filter---
Code: Select all
#!/bin/bash
perl -we'use strict;
BEGIN {
printf "%-9s %-7s %-7s %-7s ", " DT", "Hits", "Misses", "Total";
printf "%-7s %-5s\n", "%Hits", "%Miss";
}
my $hr_re=qr{\d{4}\.\d{2}0}; #1/hour
my $Qs_re=qr{\d{4}\.(?:(?:0[06]0)|(?:1[28]0.))}; #quarter days
my $Hs_re=qr{\d{4}\.(?:00|12)0}; #half days
my $lastmatch;
while (<>) {
m{^(\[[^\]]+\] ).*, (Cache H.*)} && do {
my ($t,$stat)=($1,$2);
$t =~ s/:\d\d\.\d\d\d [A-Z]{3}\]//; #now get rid of junk...
$t =~ s/^\[\d{4}-//;
$t =~ s/[:-]//g; $t=~s/ /./;
my $lm = $lastmatch;
if ($t =~ m{($Hs_re)}) {
my $nm=$lastmatch=$1;
$lm && $lm eq $nm and next; # skip over too soon hits
$stat =~ s/Cache H,M=//;
$stat =~ m{^(\d+),(\d+)} && do { # and show percentages
my ($hits, $misses) = ($1, $2);
my $total=$hits+$misses;
printf "%s %-7d %-7d %-7d ", $t, $hits, $misses, $total;
if ($total) {
printf("(%-6.2f %6.2f)", 100.0*$hits/$total, 100.0*$misses/$total);
}
printf("\n");
};
} else { $lastmatch=$1; next}
};
}
' $1
The above is in a shellscript (though work is in perl)
and I can run it on a log file via:
> cache_filter /var/log/transmission/daemon.log
DT Hits Misses Total %Hits %Miss
0812.1206 0 0 0
0813.0600 0 2800082 2800082 (0.00 100.00)
0813.0700 0 2957686 2957686 (0.00 100.00)
So for the latest 10 days... (aug 12-22):
Code: Select all
DT Hits Misses Total %Hits %Miss
0812.1206 0 0 0
0813.0600 0 2800082 2800082 (0.00 100.00)
0813.0700 0 2957686 2957686 (0.00 100.00)
0813.0800 0 3115141 3115141 (0.00 100.00)
0813.0900 0 3273036 3273036 (0.00 100.00)
0813.1000 0 3431663 3431663 (0.00 100.00)
0813.1100 0 3591137 3591137 (0.00 100.00)
0813.1200 0 3750886 3750886 (0.00 100.00)
0813.1300 0 3909308 3909308 (0.00 100.00)
0813.1400 0 4066789 4066789 (0.00 100.00)
0813.1500 0 4224814 4224814 (0.00 100.00)
0813.1600 0 4384742 4384742 (0.00 100.00)
0813.1700 0 4541596 4541596 (0.00 100.00)
0813.1800 0 4696790 4696790 (0.00 100.00)
0813.1900 0 4856355 4856355 (0.00 100.00)
0813.2000 0 5014073 5014073 (0.00 100.00)
0813.2101 0 5172928 5172928 (0.00 100.00)
0813.2201 0 5333320 5333320 (0.00 100.00)
0813.2301 0 5494871 5494871 (0.00 100.00)
0814.0001 0 5662094 5662094 (0.00 100.00)
0814.0101 0 5827257 5827257 (0.00 100.00)
0814.0201 0 5990160 5990160 (0.00 100.00)
0814.0301 0 6152821 6152821 (0.00 100.00)
0814.0401 0 6315485 6315485 (0.00 100.00)
0814.0501 0 6479130 6479130 (0.00 100.00)
0814.0601 0 6642523 6642523 (0.00 100.00)
0814.0701 0 6803213 6803213 (0.00 100.00)
0814.0801 0 6963577 6963577 (0.00 100.00)
0814.0901 0 7125069 7125069 (0.00 100.00)
0814.1001 0 7283641 7283641 (0.00 100.00)
0814.1101 0 7440393 7440393 (0.00 100.00)
0814.1202 0 7594654 7594654 (0.00 100.00)
0814.1302 0 7747051 7747051 (0.00 100.00)
0814.1402 0 7903241 7903241 (0.00 100.00)
0814.1502 176570 8189357 8365927 (2.11 97.89)
0814.1602 176570 8387017 8563587 (2.06 97.94)
0814.1702 176570 8552971 8729541 (2.02 97.98)
0814.1802 176570 8717172 8893742 (1.99 98.01)
0814.1902 176570 8880289 9056859 (1.95 98.05)
0814.2002 176570 9044708 9221278 (1.91 98.09)
0814.2102 176570 9205987 9382557 (1.88 98.12)
0814.2202 176570 9369832 9546402 (1.85 98.15)
0814.2302 176570 9532492 9709062 (1.82 98.18)
0815.0002 205527 9705350 9910877 (2.07 97.93)
0815.0102 205527 9887064 10092591 (2.04 97.96)
0815.0202 205527 10049279 10254806 (2.00 98.00)
0815.0303 205527 10207031 10412558 (1.97 98.03)
0815.0403 205527 10363460 10568987 (1.94 98.06)
0815.0503 205527 10520387 10725914 (1.92 98.08)
0815.0603 205527 10679192 10884719 (1.89 98.11)
0815.0703 205527 10834626 11040153 (1.86 98.14)
0815.0803 205527 10989111 11194638 (1.84 98.16)
0815.0903 205527 11144314 11349841 (1.81 98.19)
0815.1003 205527 11299890 11505417 (1.79 98.21)
0815.1103 205527 11459430 11664957 (1.76 98.24)
0815.1203 205527 11617679 11823206 (1.74 98.26)
0815.1303 205527 11772829 11978356 (1.72 98.28)
0815.1403 205527 11929266 12134793 (1.69 98.31)
0815.1503 205527 12090035 12295562 (1.67 98.33)
0815.1603 205527 12247638 12453165 (1.65 98.35)
0815.1703 205527 12405248 12610775 (1.63 98.37)
0815.1804 250120 12570579 12820699 (1.95 98.05)
0815.1904 281533 12752753 13034286 (2.16 97.84)
0815.2004 281533 12915276 13196809 (2.13 97.87)
0815.2104 281533 13075067 13356600 (2.11 97.89)
0815.2204 281533 13238250 13519783 (2.08 97.92)
0815.2304 281533 13401445 13682978 (2.06 97.94)
0816.0004 281533 13567310 13848843 (2.03 97.97)
0816.0104 281533 13731373 14012906 (2.01 97.99)
0816.0204 281533 13895479 14177012 (1.99 98.01)
0816.0304 281533 14060308 14341841 (1.96 98.04)
0816.0404 281533 14218650 14500183 (1.94 98.06)
0816.0504 281533 14377049 14658582 (1.92 98.08)
0816.0604 281533 14539064 14820597 (1.90 98.10)
0816.0704 281533 14697839 14979372 (1.88 98.12)
0816.0804 281533 14856514 15138047 (1.86 98.14)
0816.0905 281533 15019803 15301336 (1.84 98.16)
0816.1005 281533 15184550 15466083 (1.82 98.18)
0816.1105 281533 15347745 15629278 (1.80 98.20)
0816.1205 281533 15511191 15792724 (1.78 98.22)
0816.1305 281533 15672750 15954283 (1.76 98.24)
0816.1405 322626 15832604 16155230 (2.00 98.00)
0816.1505 369028 16080038 16449066 (2.24 97.76)
0816.1605 369028 16244616 16613644 (2.22 97.78)
0816.1705 369028 16409368 16778396 (2.20 97.80)
0816.1805 369028 16573936 16942964 (2.18 97.82)
0816.1905 369028 16734520 17103548 (2.16 97.84)
0816.2005 369028 16897534 17266562 (2.14 97.86)
0816.2105 369028 17062075 17431103 (2.12 97.88)
0816.2205 369028 17225989 17595017 (2.10 97.90)
0816.2305 369028 17386065 17755093 (2.08 97.92)
0817.0006 369028 17544246 17913274 (2.06 97.94)
0817.0106 369028 17702214 18071242 (2.04 97.96)
0817.0206 369028 17859266 18228294 (2.02 97.98)
0817.0306 369028 18017833 18386861 (2.01 97.99)
0817.0406 369028 18172603 18541631 (1.99 98.01)
0817.0506 369028 18333460 18702488 (1.97 98.03)
0817.0606 369028 18492471 18861499 (1.96 98.04)
0817.0706 369028 18659765 19028793 (1.94 98.06)
0817.0806 369028 18823755 19192783 (1.92 98.08)
0817.0906 369028 18986082 19355110 (1.91 98.09)
0817.1006 369028 19148459 19517487 (1.89 98.11)
0817.1106 369028 19309604 19678632 (1.88 98.12)
0817.1206 369028 19473653 19842681 (1.86 98.14)
0817.1306 369028 19634794 20003822 (1.84 98.16)
0817.1406 369028 19792401 20161429 (1.83 98.17)
0817.1507 369028 19948057 20317085 (1.82 98.18)
0817.1607 369028 20109820 20478848 (1.80 98.20)
0817.1707 369028 20271541 20640569 (1.79 98.21)
0817.1807 369028 20430339 20799367 (1.77 98.23)
0817.1907 410923 20623456 21034379 (1.95 98.05)
0817.2007 410923 20784632 21195555 (1.94 98.06)
0817.2107 410923 20947461 21358384 (1.92 98.08)
0817.2207 410923 21107754 21518677 (1.91 98.09)
0817.2307 410923 21265632 21676555 (1.90 98.10)
0818.0007 410923 21420109 21831032 (1.88 98.12)
0818.0107 410923 21577187 21988110 (1.87 98.13)
0818.0207 410923 21736848 22147771 (1.86 98.14)
0818.0307 410923 21900815 22311738 (1.84 98.16)
0818.0407 410923 22066156 22477079 (1.83 98.17)
0818.0507 410923 22225327 22636250 (1.82 98.18)
0818.0608 410923 22382814 22793737 (1.80 98.20)
0818.0708 410923 22539394 22950317 (1.79 98.21)
0818.0808 410923 22696116 23107039 (1.78 98.22)
0818.0908 410923 22851771 23262694 (1.77 98.23)
0818.1008 410923 23009136 23420059 (1.75 98.25)
0818.1108 410923 23165336 23576259 (1.74 98.26)
0818.1208 454303 23342230 23796533 (1.91 98.09)
0818.1308 454303 23503918 23958221 (1.90 98.10)
0818.1408 454303 23663329 24117632 (1.88 98.12)
0818.1508 454303 23814764 24269067 (1.87 98.13)
0818.1608 454303 23971659 24425962 (1.86 98.14)
0818.1708 454303 24128539 24582842 (1.85 98.15)
0818.1808 454303 24286535 24740838 (1.84 98.16)
0818.1908 454303 24444339 24898642 (1.82 98.18)
0818.2008 454303 24605073 25059376 (1.81 98.19)
0818.2109 454303 24767293 25221596 (1.80 98.20)
0818.2209 454303 24930168 25384471 (1.79 98.21)
0818.2309 454303 25092581 25546884 (1.78 98.22)
0819.0009 454303 25255219 25709522 (1.77 98.23)
0819.0109 454303 25416760 25871063 (1.76 98.24)
0819.0209 454303 25574733 26029036 (1.75 98.25)
0819.0309 454303 25731611 26185914 (1.73 98.27)
0819.0409 454303 25888115 26342418 (1.72 98.28)
0819.0509 454303 26042256 26496559 (1.71 98.29)
0819.0609 454303 26198178 26652481 (1.70 98.30)
0819.0709 454303 26353457 26807760 (1.69 98.31)
0819.0809 454303 26510303 26964606 (1.68 98.32)
0819.0909 454303 26671372 27125675 (1.67 98.33)
0819.1009 454303 26828383 27282686 (1.67 98.33)
0819.1109 679433 27055414 27734847 (2.45 97.55)
0822.1500 1998483 39928649 41927132 (4.77 95.23)
0822.1600 1998483 40108694 42107177 (4.75 95.25)
0822.1700 1998483 40270326 42268809 (4.73 95.27)
0822.1800 1998483 40431023 42429506 (4.71 95.29)
But here's previous 2 months of log @ 2x/day:
Code: Select all
DT Hits Misses Total %Hits %Miss
0614.0000 254879 1342164 1597043 (15.96 84.04)
0614.1200 1886062 4224900 6110962 (30.86 69.14)
0615.0000 1992567 6325924 8318491 (23.95 76.05)
0615.1200 2033984 8269382 10303366 (19.74 80.26)
0616.0000 2055051 10193085 12248136 (16.78 83.22)
0616.1200 2055051 12082941 14137992 (14.54 85.46)
0618.1200 42432 2818192 2860624 (1.48 98.52)
0619.0001 572127 4752667 5324794 (10.74 89.26)
0619.1202 572127 6414917 6987044 (8.19 91.81)
0620.0007 64864 1970794 2035658 (3.19 96.81)
0620.1208 64864 3912078 3976942 (1.63 98.37)
0621.0009 105444 5865920 5971364 (1.77 98.23)
0622.0007 176735 1266609 1443344 (12.24 87.76)
0622.1208 439417 3323542 3762959 (11.68 88.32)
0623.0009 480345 5609442 6089787 (7.89 92.11)
0626.1200 565322 19415267 19980589 (2.83 97.17)
0627.0000 589676 21353400 21943076 (2.69 97.31)
0627.1201 589676 23228515 23818191 (2.48 97.52)
0628.0002 2954142 25860873 28815015 (10.25 89.75)
0628.1204 2954142 28228698 31182840 (9.47 90.53)
0629.0004 2996323 30224150 33220473 (9.02 90.98)
0629.1205 3950962 32566480 36517442 (10.82 89.18)
0630.0006 3950962 34734920 38685882 (10.21 89.79)
0630.1207 3999572 36626557 40626129 (9.84 90.16)
0701.0008 4020329 38540960 42561289 (9.45 90.55)
0701.1208 4020329 40430314 44450643 (9.04 90.96)
0702.0009 4041156 42315513 46356669 (8.72 91.28)
0705.1200 7665856 57646722 65312578 (11.74 88.26)
0706.0001 7793738 59797858 67591596 (11.53 88.47)
0706.1201 7793738 61831458 69625196 (11.19 88.81)
0707.0002 7814270 63762915 71577185 (10.92 89.08)
0707.1203 7859703 65707359 73567062 (10.68 89.32)
0708.0004 7926534 67663256 75589790 (10.49 89.51)
0708.1205 7950640 69572004 77522644 (10.26 89.74)
0709.0005 7971981 71482445 79454426 (10.03 89.97)
0709.1206 7971981 73371332 81343313 (9.80 90.20)
0710.0007 8035458 75317488 83352946 (9.64 90.36)
0710.1208 10357573 78011157 88368730 (11.72 88.28)
0711.0009 10668618 80612269 91280887 (11.69 88.31)
0711.1209 10668618 82554431 93223049 (11.44 88.56)
0715.0000 11277999 96250444 107528443 (10.49 89.51)
0715.1201 11730181 98442373 110172554 (10.65 89.35)
0716.0002 11751356 100435308 112186664 (10.47 89.53)
0716.1202 11751356 102342444 114093800 (10.30 89.70)
0717.0003 11786484 104241778 116028262 (10.16 89.84)
0717.1204 11880141 106183587 118063728 (10.06 89.94)
0718.0005 11880141 108081030 119961171 (9.90 90.10)
0718.1206 11880141 109948417 121828558 (9.75 90.25)
0719.0006 12066600 111961006 124027606 (9.73 90.27)
0719.1207 12066600 113854197 125920797 (9.58 90.42)
0720.0008 12066600 115714731 127781331 (9.44 90.56)
0720.1209 12066600 117586051 129652651 (9.31 90.69)
0722.0005 1598846 1073453 2672299 (59.83 40.17)
0722.1206 1619527 3776704 5396231 (30.01 69.99)
0724.0000 523886 1801736 2325622 (22.53 77.47)
0724.1201 523886 3744345 4268231 (12.27 87.73)
0725.0002 523886 5669154 6193040 (8.46 91.54)
0725.1202 523886 7578425 8102311 (6.47 93.53)
0726.0003 782424 9643736 10426160 (7.50 92.50)
0726.1204 782424 11522358 12304782 (6.36 93.64)
0727.0005 868881 13495034 14363915 (6.05 93.95)
0727.1206 868881 15304284 16173165 (5.37 94.63)
0728.0006 868881 17163350 18032231 (4.82 95.18)
0728.1207 1106254 19125347 20231601 (5.47 94.53)
0729.0008 1106254 20979416 22085670 (5.01 94.99)
0729.1209 1380523 22917698 24298221 (5.68 94.32)
0802.1200 0 1791925 1791925 (0.00 100.00)
0803.0001 63034 3826182 3889216 (1.62 98.38)
0803.1202 1823498 6162396 7985894 (22.83 77.17)
0804.0002 3140884 9100304 12241188 (25.66 74.34)
0804.1203 3140884 11392460 14533344 (21.61 78.39)
0805.0004 3182644 13595569 16778213 (18.97 81.03)
0805.1205 3182644 15736069 18918713 (16.82 83.18)
0806.0006 3182644 17687958 20870602 (15.25 84.75)
0806.1206 3182644 19574009 22756653 (13.99 86.01)
0807.0002 0 406449 406449 (0.00 100.00)
0807.1203 81168 2446469 2527637 (3.21 96.79)
0808.0003 81168 4428861 4510029 (1.80 98.20)
0808.1204 81168 6326287 6407455 (1.27 98.73)
0809.0005 845093 8792243 9637336 (8.77 91.23)
0810.0000 63204 2423213 2486417 (2.54 97.46)
0810.1201 192671 4432813 4625484 (4.17 95.83)
0811.0002 192671 6430238 6622909 (2.91 97.09)
0811.1203 360025 8454107 8814132 (4.08 95.92)
0812.0003 402191 10428886 10831077 (3.71 96.29)
0812.1204 402191 12349699 12751890 (3.15 96.85)
Note any jumps up might have been due to 1 torrent hogging the BW...
It happens during a D/L.
Hope this wasn't too boring...
Would be more useful if had more stats from standard
version from others...
A better stat script is probably needed... if you couldn't tell
it started out as a 1-liner in shell but quickly went to perl...oh well.