Skip to content

Commit

Permalink
Fix writer OOM by reducing initial flush buffer reservation (facebook…
Browse files Browse the repository at this point in the history
…incubator#10147)

Summary:
Initial memory reservation is based on the tracked ratio maintained by RatioTracker. The one for flush is used for computing memory to reserve before flushing. For initial ratio it was default to 1.0f which ends up writer to reserve >2x (reservation headroom * ratio for flush) of raw memory from writes. This default ratio is used in the first iteration and is too large. Reduced it to 0.1 for better memory utilization. This helps to reduce in many cases writer memory usage by more than 60%.

Pull Request resolved: facebookincubator#10147

Reviewed By: xiaoxmeng

Differential Revision: D58440137

Pulled By: tanjialiang

fbshipit-source-id: c715f99e9a081cc1947cde4f2d1b9c9fbe020b50
  • Loading branch information
tanjialiang authored and facebook-github-bot committed Jun 12, 2024
1 parent 4a85913 commit 73fb02e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/test/RatioTrackerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TEST(RatioTrackerTest, BasicTests) {
{{10, 11}, {20, 1}, {30, 1}, {40, 1}, {50, 1}},
0.1f},
TestCase{std::make_shared<CompressionRatioTracker>(), {}, 0.3f},
TestCase{std::make_shared<FlushOverheadRatioTracker>(), {}, 1.0f},
TestCase{std::make_shared<FlushOverheadRatioTracker>(), {}, 0.1f},
TestCase{std::make_shared<AverageRowSizeTracker>(), {}, 0.0f},
};

Expand Down
2 changes: 1 addition & 1 deletion velox/dwio/dwrf/writer/RatioTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <glob.h>

constexpr float kCompressionRatioInitialGuess = 0.3f;
constexpr float kFlushOverheadRatioInitialGuess = 1.0f;
constexpr float kFlushOverheadRatioInitialGuess = 0.1f;
// TODO(T79660637): make write cost estimate more granular.
constexpr float kAverageRowSizeInitialGuess = 0.0f;

Expand Down

0 comments on commit 73fb02e

Please sign in to comment.