Skip to content

Commit

Permalink
Improve warning message in reusable_pool.h
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 682307063
  • Loading branch information
MediaPipe Team authored and copybara-github committed Oct 4, 2024
1 parent 31592e7 commit a3596e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions mediapipe/gpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ cc_library(
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/log:absl_log",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
],
)
Expand Down
11 changes: 8 additions & 3 deletions mediapipe/gpu/reusable_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "absl/functional/any_invocable.h"
#include "absl/log/absl_log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include "absl/synchronization/mutex.h"
#include "mediapipe/framework/port/ret_check.h"
#include "mediapipe/framework/port/status_macros.h"
Expand Down Expand Up @@ -141,9 +142,13 @@ void ReusablePool<Item>::TrimAvailable(
std::vector<std::unique_ptr<Item>>* trimmed) {
size_t keep = std::max(keep_count_ - in_use_count_, 0);
if (available_.size() > keep) {
ABSL_LOG_FIRST_N(WARNING, 1)
<< "Maximum number of pooled buffers reached. Consider increasing "
"MultiPoolOptions.keep_count";
ABSL_LOG_FIRST_N(WARNING, 1) << absl::StrFormat(
"Maximum number of pooled buffers reached (set to keep at most %d "
"buffers of the same type and size). MP buffer allocation patterns can "
"be observed with Perfetto by inspecting the "
"PerfettoScopedMemoryObjectCounters-based GpuBuffer and AhwbBuffer "
"counters. Then consider adjusting the MultiPoolOptions.keep_count",
keep_count_);
auto trim_it = std::next(available_.begin(), keep);
if (trimmed) {
std::move(trim_it, available_.end(), std::back_inserter(*trimmed));
Expand Down

0 comments on commit a3596e3

Please sign in to comment.