MCPcopy Create free account
hub / github.com/apache/arrow / ASSERT_OK_AND_ASSIGN

Function ASSERT_OK_AND_ASSIGN

cpp/src/arrow/memory_pool_test.cc:274–313  ·  view source on GitHub ↗

Read statistics into std::string

Source from the content-addressed store, hash-verified

272
273 // Read statistics into std::string
274 ASSERT_OK_AND_ASSIGN(std::string stats, jemalloc_stats_string("Jax"));
275
276 // Read statistics into std::string with a lambda
277 std::string stats2;
278 auto write_cb = [&stats2](const char* str) { stats2.append(str); };
279 ASSERT_OK(jemalloc_stats_print(write_cb, "Jax"));
280
281 ASSERT_EQ(stats.rfind("{\"jemalloc\":{\"version\"", 0), 0);
282 ASSERT_EQ(stats2.rfind("{\"jemalloc\":{\"version\"", 0), 0);
283 ASSERT_EQ(stats.substr(0, 100), stats2.substr(0, 100));
284#else
285 std::string stats;
286 auto write_cb = [&stats](const char* str) { stats.append(str); };
287 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("thread.peak.read"));
288 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("stats.allocated"));
289 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("stats.allocated"));
290 ASSERT_RAISES(NotImplemented, jemalloc_get_stat("stats.allocatedp"));
291 ASSERT_RAISES(NotImplemented, jemalloc_peak_reset());
292 ASSERT_RAISES(NotImplemented, jemalloc_stats_print(write_cb, "Jax"));
293 ASSERT_RAISES(NotImplemented, jemalloc_stats_print("ax"));
294#endif
295}
296
297class TestCappedMemoryPool : public ::arrow::TestMemoryPoolBase {
298 public:
299 MemoryPool* memory_pool() override { return InitPool(/*limit=*/1'000'000'000LL); }
300
301 MemoryPool* InitPool(int64_t limit) {
302 proxy_memory_pool_ = std::make_shared<ProxyMemoryPool>(default_memory_pool());
303 capped_memory_pool_ =
304 std::make_shared<CappedMemoryPool>(proxy_memory_pool_.get(), limit);
305 return capped_memory_pool_.get();
306 }
307
308 protected:
309 std::shared_ptr<MemoryPool> proxy_memory_pool_;
310 std::shared_ptr<CappedMemoryPool> capped_memory_pool_;
311};
312
313TEST_F(TestCappedMemoryPool, MemoryTracking) { this->TestMemoryTracking(); }
314
315TEST_F(TestCappedMemoryPool, OOM) {
316 // CappedMemoryPool rejects the huge allocation without hitting the underlying

Callers 1

TESTFunction · 0.70

Calls 9

default_memory_poolFunction · 0.85
substrMethod · 0.80
TestMemoryTrackingMethod · 0.80
jemalloc_stats_printFunction · 0.70
jemalloc_get_statFunction · 0.70
jemalloc_peak_resetFunction · 0.70
memory_poolFunction · 0.50
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected