New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
msg/simple: apply prefetch policy more precisely #10344
Conversation
We shall apply prefetch policy based on the residual length aftering checking cache instead of the original request length. E.g., if the reading sequences are 1K, 5K, 2K, the improved logic will trigger another prefetch of 4K(as 5K - 3K(from recv_buf) == 2K, and we now have 8K prefetched data total) by the second 5K reading(which we don't do this according to the old logic), and thus the last reading request which asks for 2K data can be also benefited from this prefetch too, which is good for performance. Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
Doesn't this change contradict the comment right there about not prefetching large reads? |
The key difference is how do we define large reads. E.g., suppose the recv_max_prefetch is 4K, and the read sequences are 1K, 5K, 2K Before this change:
After this change:
From the above example, we need exactly 2 (prefetch)reads now instead of 3 reads which we need before. |
@gregsfortytwo Thoughts? |
Yeah, that makes sense. I was worried about the performance impact of the change but going down a few function frames it all looks good to me! |
test run http://pulpito.ceph.com/yuriw-2016-07-27_11:33:48-rados-wip-yuri-testing_2016_7_27-distro-basic-smithi/ |
msg/simple: apply prefetch policy more precisely Reviewed-by: Greg Farnum <gfarnum@redhat.com> Conflicts: src/msg/simple/Pipe.cc (removed unneeded cast)
We shall apply prefetch policy based on the residual length instead of the original requested length. E.g., suppose the recv_max_prefetch is 4K, and the read sequences are 1K, 5K, 2K **Before this change:** - read 1K, as 1K < recv_max_prefetch, we prefetch 4K, and the 1K read itself is hit in the cache after the prefetch is done. - read 5K, the first 3K is hit in the cache and the cache is now empty, as 5K > recv_max_prefetch, we don't prefetch and trigger a 2K read instead. - read 2K, the cache is now empty, as 2K > recv_max_prefetch, we trigger another prefetch and get 2K from the cache after prefetch is done. **After this change:** - read 1K, as 1K < recv_max_prefetch, we prefetch 4K, and the 1K read itself is hit in the cache after the prefetch is done. - read 5K, the first 3K is hit in the cache and the cache is now empty and we have 5K-3K = 2K to read, as 2K < recv_max_prefetch, we prefetch again and get 2K from the cache after prefetch is done, the cache has 2K data remaining. - read 2K, which is directly hit in the cache. From the above example, we need exactly 2 (prefetch)reads now instead of 3 reads which we need before. See-also: ceph#10344 Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
We shall apply prefetch policy based on the residual length aftering
checking cache instead of the original request length.
E.g., if the reading sequences are 1K, 5K, 2K, the improved logic
will trigger another prefetch of 4K(as 5K - 3K(from recv_buf) == 2K, and we
now have 8K prefetched data total) by the second 5K reading(which we
don't do this according to the old logic), and thus the last reading request
which asks for 2K data can be also benefited from this prefetch,
which is good for performance.
Signed-off-by: xie xingguo xie.xingguo@zte.com.cn