Revert "[RFC] Fix memory tracking with min_bytes_to_use_mmap_io"

This commit is contained in:
alexey-milovidov 2021-04-19 01:30:53 +03:00 committed by GitHub
parent 04fa079855
commit 1d5a4cfa32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1 additions and 36 deletions

View File

@ -1,5 +1,4 @@
#include <IO/MMapReadBufferFromFileWithCache.h> #include <IO/MMapReadBufferFromFileWithCache.h>
#include <Common/CurrentMemoryTracker.h>
namespace DB namespace DB
@ -75,16 +74,4 @@ off_t MMapReadBufferFromFileWithCache::seek(off_t offset, int whence)
return new_pos; return new_pos;
} }
void MMapReadBufferFromFileWithCache::track(size_t bytes_)
{
CurrentMemoryTracker::alloc(bytes_);
tracked_bytes = bytes_;
}
MMapReadBufferFromFileWithCache::~MMapReadBufferFromFileWithCache()
{
if (tracked_bytes)
CurrentMemoryTracker::free(tracked_bytes);
}
} }

View File

@ -16,27 +16,13 @@ public:
/// Map till end of file. /// Map till end of file.
MMapReadBufferFromFileWithCache(MMappedFileCache & cache, const std::string & file_name, size_t offset); MMapReadBufferFromFileWithCache(MMappedFileCache & cache, const std::string & file_name, size_t offset);
~MMapReadBufferFromFileWithCache() override;
off_t getPosition() override; off_t getPosition() override;
std::string getFileName() const override; std::string getFileName() const override;
off_t seek(off_t offset, int whence) override; off_t seek(off_t offset, int whence) override;
/// Track memory with MemoryTracker.
///
/// NOTE: that this is not the size of mmap() region, but estimated size of
/// data that will be read (see MergeTreeReaderStream).
/// And from one point of view it should not be accounted here, since the
/// kernel may unmap physical pages, but in practice firstly it will mmap it,
/// RSS will grow, total_memory_tracker will be synced with RSS and the
/// allocations will start to fail.
void track(size_t bytes_);
private: private:
MMappedFileCache::MappedPtr mapped; MMappedFileCache::MappedPtr mapped;
size_t tracked_bytes = 0;
void init(); void init();
}; };

View File

@ -50,7 +50,6 @@ std::unique_ptr<ReadBufferFromFileBase> createReadBufferFromFileBase(
try try
{ {
auto res = std::make_unique<MMapReadBufferFromFileWithCache>(*mmap_cache, filename_, 0); auto res = std::make_unique<MMapReadBufferFromFileWithCache>(*mmap_cache, filename_, 0);
res->track(estimated_size);
ProfileEvents::increment(ProfileEvents::CreatedReadBufferMMap); ProfileEvents::increment(ProfileEvents::CreatedReadBufferMMap);
return res; return res;
} }

View File

@ -23,6 +23,6 @@ SELECT marks FROM system.parts WHERE table = 'adaptive_table' and database=curre
-- If we have computed granularity incorrectly than we will exceed this limit. -- If we have computed granularity incorrectly than we will exceed this limit.
SET max_memory_usage='30M'; SET max_memory_usage='30M';
SELECT max(length(value)) FROM adaptive_table SETTINGS min_bytes_to_use_mmap_io=0; SELECT max(length(value)) FROM adaptive_table;
DROP TABLE IF EXISTS adaptive_table; DROP TABLE IF EXISTS adaptive_table;

View File

@ -1,5 +0,0 @@
drop table if exists data_01818;
create table data_01818 (key Int, value String) engine=MergeTree() order by key settings min_bytes_for_wide_part=0 as select number, randomPrintableASCII(100) from numbers(1e6);
select * from data_01818 format Null settings min_bytes_to_use_mmap_io=1, max_memory_usage='20Mi', max_threads=1; -- { serverError 241 }
select * from data_01818 format Null settings min_bytes_to_use_mmap_io=1e9, max_memory_usage='20Mi', max_threads=1;

View File

@ -2,8 +2,6 @@ SET max_bytes_before_external_group_by = 200000000;
SET max_memory_usage = 1500000000; SET max_memory_usage = 1500000000;
SET max_threads = 12; SET max_threads = 12;
SET min_bytes_to_use_mmap_io = 0;
SELECT URL, uniq(SearchPhrase) AS u FROM test.hits GROUP BY URL ORDER BY u DESC, URL LIMIT 10; SELECT URL, uniq(SearchPhrase) AS u FROM test.hits GROUP BY URL ORDER BY u DESC, URL LIMIT 10;
SET max_memory_usage = 300000000; SET max_memory_usage = 300000000;