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

Function jemalloc_get_stat

cpp/src/arrow/memory_pool_jemalloc.cc:164–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162#undef RETURN_IF_JEMALLOC_ERROR
163
164Result<int64_t> jemalloc_get_stat(const char* name) {
165 size_t sz;
166 int err;
167
168 // Update the statistics cached by mallctl.
169 if (std::strcmp(name, "stats.allocated") == 0 ||
170 std::strcmp(name, "stats.active") == 0 ||
171 std::strcmp(name, "stats.metadata") == 0 ||
172 std::strcmp(name, "stats.resident") == 0 ||
173 std::strcmp(name, "stats.mapped") == 0 ||
174 std::strcmp(name, "stats.retained") == 0) {
175 uint64_t epoch;
176 sz = sizeof(epoch);
177 mallctl("epoch", &epoch, &sz, &epoch, sz);
178 }
179
180 // Depending on the stat being queried and on the platform, we could need
181 // to pass a uint32_t or uint64_t pointer. Try both.
182 {
183 uint64_t value = 0;
184 sz = sizeof(value);
185 err = mallctl(name, &value, &sz, nullptr, 0);
186 if (!err) {
187 return value;
188 }
189 }
190 // EINVAL means the given value length (`sz`) was incorrect.
191 if (err == EINVAL) {
192 uint32_t value = 0;
193 sz = sizeof(value);
194 err = mallctl(name, &value, &sz, nullptr, 0);
195 if (!err) {
196 return value;
197 }
198 }
199
200 return arrow::internal::IOErrorFromErrno(err, "Failed retrieving ", &name);
201}
202
203Status jemalloc_peak_reset() {
204 int err = mallctl("thread.peak.reset", nullptr, nullptr, nullptr, 0);

Callers

nothing calls this directly

Calls 1

IOErrorFromErrnoFunction · 0.85

Tested by

no test coverage detected