MCPcopy Create free account
hub / github.com/apache/impala / TEST

Function TEST

be/src/kudu/util/process_memory-test.cc:38–73  ·  view source on GitHub ↗

Microbenchmark for our new/delete hooks which track process-wide memory consumption.

Source from the content-addressed store, hash-verified

36// Microbenchmark for our new/delete hooks which track process-wide
37// memory consumption.
38TEST(ProcessMemory, BenchmarkConsumptionTracking) {
39 const int kNumThreads = 200;
40 vector<thread> threads;
41 atomic<bool> done(false);
42 atomic<int64_t> total_count(0);
43
44 // We start many threads, each of which performs 10:1 ratio of
45 // new/delete pairs to consumption lookups. The high number
46 // of threads highlights when there is contention on central
47 // tcmalloc locks.
48 for (int i = 0; i < kNumThreads; i++) {
49 threads.emplace_back([&]() {
50 int64_t local_count = 0;
51 while (!done) {
52 for (int a = 0; a < 10; a++) {
53 // Mark 'x' volatile so that the compiler does not optimize out the
54 // allocation.
55 char* volatile x = new char[8000];
56 delete[] x;
57 }
58 process_memory::CurrentConsumption();
59 local_count++;
60 }
61 total_count += local_count;
62 });
63 }
64 double secs = 3;
65 SleepFor(MonoDelta::FromSeconds(secs));
66 done = true;
67
68 for (auto& t : threads) {
69 t.join();
70 }
71
72 LOG(INFO) << "Performed " << total_count / secs << " iters/sec";
73}
74
75} // namespace kudu

Callers

nothing calls this directly

Calls 3

CurrentConsumptionFunction · 0.85
SleepForFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected