@@ -2199,7 +2199,7 @@ read_ahead_send_file_filter(Config) ->
21992199 RAL = 4096 , % % read ahead limit
22002200 HS = ? HEADER_SIZE_B ,
22012201 % % we store the entry size on 4 bytes, so we must substract them from the data size
2202- MaxEntrySize = RAL - 4 - HS ,
2202+ MaxEntrySize = RAL - 11 - HS ,
22032203 DFS = ? DEFAULT_FILTER_SIZE ,
22042204 % FilterSizes = [DFS * 2],
22052205 FilterSizes = [DFS , DFS * 2 ],
@@ -2307,50 +2307,47 @@ read_ahead_send_file_filter(Config) ->
23072307 {_ , W1 } = write_committed (Entries , W0 ),
23082308 W1 ;
23092309 (read , #{r := R0 , cs := CS , ss := SS , tracer := T }) ->
2310- % % we still read ahead, so we read a small chunk at once
2310+ % % read ahead is disabled, but will be reenabled
23112311 Entries = [{<<" banana" >>, <<" aaa" >>}],
23122312 [_ , _ , D , _ ] = ra_fake_chunk (Entries ),
23132313 {ok , R1 } = osiris_log :send_file (CS , R0 ),
23142314 {ok , Read } = recv (SS , byte_size (D ) + HS ),
23152315 ? assertEqual (D , binary :part (Read , HS , byte_size (Read ) - HS )),
23162316 ? assertEqual (1 , osiris_tracer :call_count (T , file , pread )),
2317- ? assertEqual (0 , osiris_tracer :call_count (T , file , sendfile )),
2317+ ? assertEqual (1 , osiris_tracer :call_count (T , file , sendfile )),
23182318 R1
23192319 end ,
23202320 fun (write , #{w := W0 }) ->
2321- EData = binary :copy (<<" b" >>, MES1 * 2 ),
2321+ EData = binary :copy (<<" b" >>, MES1 div 2 ),
23222322 Entries = [{<<" banana" >>, EData }],
23232323 {_ , W1 } = write_committed (Entries , W0 ),
23242324 W1 ;
23252325 (read , #{r := R0 , cs := CS , ss := SS , tracer := T }) ->
2326- % % large chunk, we had the header already,
2327- % % but we must use sendfile for the data
2328- EData = binary :copy (<<" b" >>, MES1 * 2 ),
2326+ % % previous chunk enabled read ahead
2327+ EData = binary :copy (<<" b" >>, MES1 div 2 ),
23292328 Entries = [{<<" banana" >>, EData }],
23302329 [_ , _ , D , _ ] = ra_fake_chunk (Entries ),
23312330 {ok , R1 } = osiris_log :send_file (CS , R0 ),
23322331 {ok , Read } = recv (SS , byte_size (D ) + HS ),
23332332 ? assertEqual (D , binary :part (Read , HS , byte_size (Read ) - HS )),
2334- ? assertEqual (0 , osiris_tracer :call_count (T , file , pread )),
2335- ? assertEqual (1 , osiris_tracer :call_count (T , file , sendfile )),
2333+ ? assertEqual (1 , osiris_tracer :call_count (T , file , pread )),
2334+ ? assertEqual (0 , osiris_tracer :call_count (T , file , sendfile )),
23362335 R1
23372336 end ,
23382337 fun (write , #{w := W0 }) ->
2339- EData = binary :copy (<<" b" >>, MES1 div 2 ),
2338+ EData = binary :copy (<<" b" >>, MES1 * 2 ),
23402339 Entries = [{<<" banana" >>, EData }],
23412340 {_ , W1 } = write_committed (Entries , W0 ),
23422341 W1 ;
23432342 (read , #{r := R0 , cs := CS , ss := SS , tracer := T }) ->
2344- % % we don't read ahead anymore because the previous chunk was large
2345- % % so we read the header and use sendfile,
2346- % % even for a small chunk
2347- EData = binary :copy (<<" b" >>, MES1 div 2 ),
2343+ % % large chunk, we had the header already,
2344+ EData = binary :copy (<<" b" >>, MES1 * 2 ),
23482345 Entries = [{<<" banana" >>, EData }],
23492346 [_ , _ , D , _ ] = ra_fake_chunk (Entries ),
23502347 {ok , R1 } = osiris_log :send_file (CS , R0 ),
23512348 {ok , Read } = recv (SS , byte_size (D ) + HS ),
23522349 ? assertEqual (D , binary :part (Read , HS , byte_size (Read ) - HS )),
2353- ? assertEqual (1 , osiris_tracer :call_count (T , file , pread )),
2350+ ? assertEqual (0 , osiris_tracer :call_count (T , file , pread )),
23542351 ? assertEqual (1 , osiris_tracer :call_count (T , file , sendfile )),
23552352 R1
23562353 end
0 commit comments