summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/chunked_output_stream.cpp
diff options
context:
space:
mode:
authornadya02 <[email protected]>2025-05-16 18:45:35 +0300
committernadya02 <[email protected]>2025-05-16 19:44:30 +0300
commit8857f43bd0eb89296985141abff839ef374917cf (patch)
treece9e5ceb5185eaf169dc445d87a0d791c6969c76 /library/cpp/yt/memory/chunked_output_stream.cpp
parent6874f105db56a0af55bf7595fe5e9316d8173bcd (diff)
YT-24913: Split memory tracker
commit_hash:af573daeadda0ee67ff6c0a595b6dc3ad6314c51
Diffstat (limited to 'library/cpp/yt/memory/chunked_output_stream.cpp')
-rw-r--r--library/cpp/yt/memory/chunked_output_stream.cpp23
1 files changed, 4 insertions, 19 deletions
diff --git a/library/cpp/yt/memory/chunked_output_stream.cpp b/library/cpp/yt/memory/chunked_output_stream.cpp
index d2654209477..90ec36fe23f 100644
--- a/library/cpp/yt/memory/chunked_output_stream.cpp
+++ b/library/cpp/yt/memory/chunked_output_stream.cpp
@@ -8,12 +8,9 @@ namespace NYT {
TChunkedOutputStream::TChunkedOutputStream(
TRefCountedTypeCookie tagCookie,
- IMemoryUsageTrackerPtr memoryUsageTracker,
size_t initialReserveSize,
size_t maxReserveSize)
- : MemoryUsageTracker_(std::move(memoryUsageTracker))
- , CurrentChunkMemoryUsageGuard_(TMemoryUsageTrackerGuard::Build(MemoryUsageTracker_))
- , MaxReserveSize_(RoundUpToPage(maxReserveSize))
+ : MaxReserveSize_(RoundUpToPage(maxReserveSize))
, CurrentReserveSize_(RoundUpToPage(initialReserveSize))
, CurrentChunk_(tagCookie, /*size*/ 0)
{
@@ -26,8 +23,7 @@ TChunkedOutputStream::TChunkedOutputStream(
std::vector<TSharedRef> TChunkedOutputStream::Finish()
{
- FinishedChunks_.push_back(TrackMemory(MemoryUsageTracker_, TSharedRef::FromBlob(std::move(CurrentChunk_))));
- CurrentChunkMemoryUsageGuard_.Release();
+ FinishedChunks_.push_back(TSharedRef::FromBlob(std::move(CurrentChunk_)));
YT_ASSERT(CurrentChunk_.IsEmpty());
FinishedSize_ = 0;
@@ -53,10 +49,9 @@ void TChunkedOutputStream::ReserveNewChunk(size_t spaceRequired)
{
YT_ASSERT(CurrentChunk_.Size() == CurrentChunk_.Capacity());
FinishedSize_ += CurrentChunk_.Size();
- FinishedChunks_.push_back(TrackMemory(MemoryUsageTracker_, TSharedRef::FromBlob(std::move(CurrentChunk_))));
+ FinishedChunks_.push_back(TSharedRef::FromBlob(std::move(CurrentChunk_)));
CurrentReserveSize_ = std::min(2 * CurrentReserveSize_, MaxReserveSize_);
CurrentChunk_.Reserve(std::max(RoundUpToPage(spaceRequired), CurrentReserveSize_));
- UpdateCurrentChunkMemoryUsage();
}
void TChunkedOutputStream::DoWrite(const void* buffer, size_t length)
@@ -73,7 +68,6 @@ void TChunkedOutputStream::DoWrite(const void* buffer, size_t length)
ReserveNewChunk(spaceRequired);
CurrentChunk_.Append(static_cast<const char*>(buffer) + spaceAvailable, spaceRequired);
}
- UpdateCurrentChunkMemoryUsage();
}
size_t TChunkedOutputStream::DoNext(void** ptr)
@@ -90,7 +84,6 @@ size_t TChunkedOutputStream::DoNext(void** ptr)
YT_ASSERT(spaceAvailable > 0);
*ptr = CurrentChunk_.End();
CurrentChunk_.Resize(CurrentChunk_.Capacity(), /*initializeStorage*/ false);
- UpdateCurrentChunkMemoryUsage();
return spaceAvailable;
}
@@ -98,7 +91,6 @@ void TChunkedOutputStream::DoUndo(size_t len)
{
YT_VERIFY(CurrentChunk_.Size() >= len);
CurrentChunk_.Resize(CurrentChunk_.Size() - len);
- UpdateCurrentChunkMemoryUsage();
}
char* TChunkedOutputStream::Preallocate(size_t size)
@@ -106,13 +98,12 @@ char* TChunkedOutputStream::Preallocate(size_t size)
size_t available = CurrentChunk_.Capacity() - CurrentChunk_.Size();
if (available < size) {
FinishedSize_ += CurrentChunk_.Size();
- FinishedChunks_.push_back(TrackMemory(MemoryUsageTracker_, TSharedRef::FromBlob(std::move(CurrentChunk_))));
+ FinishedChunks_.push_back(TSharedRef::FromBlob(std::move(CurrentChunk_)));
CurrentReserveSize_ = std::min(2 * CurrentReserveSize_, MaxReserveSize_);
CurrentChunk_.Reserve(std::max(RoundUpToPage(size), CurrentReserveSize_));
}
- UpdateCurrentChunkMemoryUsage();
return CurrentChunk_.End();
}
@@ -120,12 +111,6 @@ void TChunkedOutputStream::Advance(size_t size)
{
YT_ASSERT(CurrentChunk_.Size() + size <= CurrentChunk_.Capacity());
CurrentChunk_.Resize(CurrentChunk_.Size() + size, false);
- UpdateCurrentChunkMemoryUsage();
-}
-
-void TChunkedOutputStream::UpdateCurrentChunkMemoryUsage()
-{
- CurrentChunkMemoryUsageGuard_.SetSize(CurrentChunk_.Capacity());
}
////////////////////////////////////////////////////////////////////////////////