File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,10 @@ class posix_data_source_impl final : public data_source_impl {
105105 lw_shared_ptr<pollable_fd> _fd;
106106 temporary_buffer<char > _buf;
107107 size_t _buf_size;
108+ static constexpr size_t min_buf_size = 1 << 9 ;
109+ static constexpr size_t max_buf_size = 1 << 19 ;
108110public:
109- explicit posix_data_source_impl (lw_shared_ptr<pollable_fd> fd, size_t buf_size = 8192 )
111+ explicit posix_data_source_impl (lw_shared_ptr<pollable_fd> fd, size_t buf_size = 1 << 13 )
110112 : _fd(std::move(fd)), _buf(buf_size), _buf_size(buf_size) {}
111113 future<temporary_buffer<char >> get () override ;
112114 future<> close () override ;
Original file line number Diff line number Diff line change @@ -316,6 +316,11 @@ posix_data_source_impl::get() {
316316 return _fd->read_some (_buf.get_write (), _buf_size).then ([this ] (size_t size) {
317317 _buf.trim (size);
318318 auto ret = std::move (_buf);
319+ if (_buf_size == size) {
320+ _buf_size = std::min (max_buf_size, _buf_size << 2 );
321+ } else if (size < (_buf_size >> 2 )) {
322+ _buf_size = std::max (min_buf_size, _buf_size >> 2 );
323+ }
319324 _buf = temporary_buffer<char >(_buf_size);
320325 return make_ready_future<temporary_buffer<char >>(std::move (ret));
321326 });
You can’t perform that action at this time.
0 commit comments