johang/btfs

fetch pieces ahead for sequential access

Closed this issue · 1 comments

currently btfs is blocking
when i do sequential access and reach the end of a piece

btfs should fetch pieces ahead
similar to a video player, buffering ahead some seconds

let the user set a read-ahead buffer size, in MB or in number of pieces

btfs allows read speeds around 250 KB/s
qbittorrent downloads the same torrent with 5 MB/s = 20x faster

example

in my app this looks like this...

dt = time per file
loop_speed = average speed for all files

dt > 0 means that btfs is blocking before i can read the next file
ideally these dt values should be much smaller

dt == 0 means that btfs has fetched a piece
and i get zero-latency access to all files in that piece

md5 b8c46f2f467f1a443c2d36d5a1868ec7 file 1 of 61189 name 12184604 dt 224 loop_speed 0.6 KiB/s size 145422 piece 0
md5 af0ecf18abbbf686ca22195490db7f9a file 2 of 61189 name 12192831 dt 0 loop_speed 2.6 KiB/s size 446504 piece 0
md5 61ea9b7861b3ef490b5958bb4337d9ab file 3 of 61189 name 12175161 dt 0 loop_speed 5.2 KiB/s size 593085 piece 0
md5 9b197e0b663570574800f4b77615517a file 4 of 61189 name 12191130 dt 0 loop_speed 5.5 KiB/s size 78127 piece 0
...
md5 37f35378f9da4e16ce46b0d96fdbc25f file 53 of 61189 name 12177702 dt 0 loop_speed 226.3 KiB/s size 490350 piece 13
md5 b57e37adbeab5cac4479a17bfb7c2e57 file 54 of 61189 name 12223239 dt 0 loop_speed 228.6 KiB/s size 564931 piece 13
md5 caa60a6258d0a298d6355dd2758a5dce file 55 of 61189 name 12186999 dt 0 loop_speed 240.7 KiB/s size 3026337 piece 13

md5 844134fa6c44bc9e2d0ac26c555a41e9 file 56 of 61189 name 12220974 dt 234 loop_speed 123.9 KiB/s size 1239232 piece 14
md5 86e0c726c169297ec885f4d1d0080a8f file 57 of 61189 name 12218838 dt 0 loop_speed 124.4 KiB/s size 262761 piece 14
md5 3f6f83fd6490fd53a3be607a1123a8de file 58 of 61189 name 12164863 dt 0 loop_speed 125.4 KiB/s size 472554 piece 14
md5 d6892a0e4c9890d39cbfe7ad223b2ef5 file 59 of 61189 name 12212911 dt 0 loop_speed 126.6 KiB/s size 622071 piece 14
...
md5 6f0f10c430aaf14d1c852d8873e320f3 file 100 of 61189 name 12180449 dt 0 loop_speed 220.3 KiB/s size 231766 piece 25
md5 00101c9975b483e5fa9fc4d03debf925 file 101 of 61189 name 12180385 dt 0 loop_speed 220.9 KiB/s size 289934 piece 25
md5 8edf400959bfa1758b28460e354f78a5 file 102 of 61189 name 12184859 dt 0 loop_speed 222.5 KiB/s size 833130 piece 25

md5 cb4778a9bb3c8ac65a84a425923094e6 file 103 of 61189 name 12217502 dt 519 loop_speed 253.1 KiB/s size 149307727 piece 61
md5 b9238e23b18a944211e898bf2a41ddfb file 104 of 61189 name 12161528 dt 0 loop_speed 253.4 KiB/s size 364811 piece 61
md5 a1b8de016a729874fca8cc67e3f5e9de file 105 of 61189 name 12200477 dt 0 loop_speed 253.7 KiB/s size 287275 piece 61
md5 177ec39fbd67333ef2aca6dc79dd2a46 file 106 of 61189 name 12216700 dt 0 loop_speed 253.9 KiB/s size 206337 piece 61
...
md5 bda2a081729dc0657209a76aa1f7d2c6 file 122 of 61189 name 12179049 dt 0 loop_speed 267.8 KiB/s size 1440523 piece 65
md5 67e743f33a522eecef48c406e2691d4a file 123 of 61189 name 12180495 dt 0 loop_speed 268.0 KiB/s size 228700 piece 65
md5 2da2d16bbd05058271f2ee9bdfeb134e file 124 of 61189 name 12182479 dt 0 loop_speed 268.5 KiB/s size 497815 piece 65

md5 372c20b180e783d7f4ff9f04b39bcb1f file 125 of 61189 name 12181063 dt 191 loop_speed 240.9 KiB/s size 19010218 piece 69
md5 7f6a76e110d5ee932009f3fd85cd817b file 126 of 61189 name 12220749 dt 0 loop_speed 241.3 KiB/s size 521314 piece 69
md5 c9bacd2236315152b595796f189decff file 127 of 61189 name 12207086 dt 0 loop_speed 241.5 KiB/s size 239430 piece 69
md5 aa95aa3419405b05ef2b6d690268b04c file 128 of 61189 name 12179903 dt 0 loop_speed 243.8 KiB/s size 2825488 piece 70
md5 8483c11ce6d1d3ea73892e61dbb1c3f1 file 129 of 61189 name 12194668 dt 0 loop_speed 244.5 KiB/s size 890267 piece 70
md5 2c153e541dbf0ed08ba83349a9a3ed3b file 130 of 61189 name 12194495 dt 0 loop_speed 244.9 KiB/s size 515632 piece 70
md5 50aa1eda957fe0c0310de1d0865cbd83 file 131 of 61189 name 12185790 dt 0 loop_speed 246.1 KiB/s size 1433790 piece 71
md5 7805e9ab174172483a7cf17c21f2a63c file 132 of 61189 name 12211762 dt 0 loop_speed 247.1 KiB/s size 1215474 piece 71
md5 42b0bf65b2419a7449f19b3088563e7c file 133 of 61189 name 12174472 dt 0 loop_speed 247.3 KiB/s size 301717 piece 71
md5 721c302fca2cfaffe4fd3ba23b8ed64b file 134 of 61189 name 12182568 dt 0 loop_speed 247.4 KiB/s size 190503 piece 71

md5 f7ac48f0b187e476273910c2d3b2cd12 file 135 of 61189 name 12209152 dt 109 loop_speed 228.1 KiB/s size 1945615 piece 72
md5 c41246b6e634c9a8be74d3b820df2f38 file 136 of 61189 name 12172397 dt 1 loop_speed 235.2 KiB/s size 9470131 piece 74
md5 ec8c527c4504afd3eb9b4266edd6663f file 137 of 61189 name 12221948 dt 0 loop_speed 235.6 KiB/s size 628967 piece 74
md5 4704659efe9b567280c8a7d126f06a7f file 138 of 61189 name 12206406 dt 0 loop_speed 235.9 KiB/s size 301714 piece 74
...
md5 f531722a9131ca767c12fcfe93fd055c file 162 of 61189 name 12171478 dt 0 loop_speed 249.2 KiB/s size 1427906 piece 78
md5 d5a9f679791de7595e360130b228240b file 163 of 61189 name 12166403 dt 0 loop_speed 249.4 KiB/s size 211837 piece 78
md5 76ef590e5682bce267c8a3344e4017c0 file 164 of 61189 name 12191607 dt 0 loop_speed 249.9 KiB/s size 650937 piece 79

md5 67746c66c740c7567b11581d91b7a730 file 165 of 61189 name 12196119 dt 113 loop_speed 258.6 KiB/s size 41663305 piece 89
md5 416178f867b025085ead922bc20ebf1f file 166 of 61189 name 12173024 dt 0 loop_speed 259.3 KiB/s size 955844 piece 89
md5 8a9dc0eda3bab3ea35efda2e5bf9bd29 file 167 of 61189 name 12204452 dt 0 loop_speed 259.4 KiB/s size 157378 piece 89
md5 579b437495fb2648d4f9470d629094b1 file 168 of 61189 name 12207392 dt 0 loop_speed 259.8 KiB/s size 693383 piece 89

md5 bd85453d7e47b43a13c55549af83d38f file 169 of 61189 name 12171995 dt 87 loop_speed 248.4 KiB/s size 5480876 piece 90
md5 aa512f948a08e0131c8b0e58b596e665 file 170 of 61189 name 12226602 dt 0 loop_speed 248.8 KiB/s size 619464 piece 90

md5 304b5597c787a385bd799c093e3f50c9 file 171 of 61189 name 12168543 dt 52 loop_speed 240.7 KiB/s size 517216 piece 91
md5 d32d92e7721666f2814f628f5fe77913 file 172 of 61189 name 12222367 dt 0 loop_speed 240.9 KiB/s size 280431 piece 91
md5 12636a7fac8069fd9b698ff9874cd433 file 173 of 61189 name 12214970 dt 0 loop_speed 241.3 KiB/s size 716296 piece 91
md5 cec8a8ad88ec6c20748e75ed9acef711 file 174 of 61189 name 12190582 dt 0 loop_speed 241.4 KiB/s size 161841 piece 91
...
md5 c3229232bdd1942f2a97d391ab2f6db2 file 245 of 61189 name 12193195 dt 0 loop_speed 274.3 KiB/s size 658557 piece 104
md5 e90736ced7207e5bc7ad535d016c6b2a file 246 of 61189 name 12206622 dt 0 loop_speed 274.5 KiB/s size 318741 piece 104
md5 f34171404aa0402cbb1dcfe342e8363b file 247 of 61189 name 12172417 dt 0 loop_speed 277.5 KiB/s size 4865681 piece 105

md5 7a5a8b9cfb54dc27668fbf8f0683c96c file 248 of 61189 name 12228993 dt 318 loop_speed 248.6 KiB/s size 34953875 piece 113
md5 fdf04fd43ff36b25bee1b08133348bcb file 249 of 61189 name 12175952 dt 0 loop_speed 248.9 KiB/s size 544166 piece 113
md5 9857486edfc8d89aba656ecbee2bd076 file 250 of 61189 name 12197293 dt 0 loop_speed 249.0 KiB/s size 238188 piece 113
md5 893bb9914744a346c9044c573a54ce47 file 251 of 61189 name 12171012 dt 0 loop_speed 249.1 KiB/s size 196201 piece 113
...

btfs should fetch pieces ahead
similar to a video player, buffering ahead some seconds

It already does this.