MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / Recording

Method Recording

src/flightRecorder.cpp:266–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264
265 public:
266 Recording(int fd, const char* master_recording_file, Arguments& args) : _fd(fd), _thread_set(), _method_map() {
267 _master_recording_file = master_recording_file == NULL ? NULL : strdup(master_recording_file);
268 _chunk_start = lseek(_fd, 0, SEEK_END);
269 _start_time = OS::micros();
270 _start_ticks = TSC::ticks();
271 _base_id = 0;
272 _bytes_written = 0;
273 _memfd = -1;
274 _in_memory = false;
275
276 _chunk_size = args._chunk_size <= 0 ? MAX_JLONG : (args._chunk_size < 262144 ? 262144 : args._chunk_size);
277 _chunk_time = args._chunk_time <= 0 ? MAX_JLONG : (args._chunk_time < 5 ? 5 : args._chunk_time) * 1000000ULL;
278
279 _available_processors = OS::getCpuCount();
280
281 writeHeader(_buf);
282 writeMetadata(_buf);
283 writeRecordingInfo(_buf);
284 writeSettings(_buf, args);
285 if (!args.hasOption(NO_SYSTEM_INFO)) {
286 writeOsCpuInfo(_buf);
287 writeJvmInfo(_buf);
288 }
289 if (!args.hasOption(NO_SYSTEM_PROPS)) {
290 writeSystemProperties(_buf);
291 }
292 if (!args.hasOption(NO_NATIVE_LIBS)) {
293 _recorded_lib_count = 0;
294 writeNativeLibraries(_buf);
295 } else {
296 _recorded_lib_count = -1;
297 }
298 flush(_buf);
299
300 if (args.hasOption(IN_MEMORY) && (_memfd = OS::createMemoryFile("async-profiler-recording")) >= 0) {
301 _in_memory = true;
302 }
303
304 _cpu_monitor_enabled = !args.hasOption(NO_CPU_LOAD);
305 if (_cpu_monitor_enabled) {
306 _last_times.proc.real = OS::getProcessCpuTime(&_last_times.proc.user, &_last_times.proc.system);
307 _last_times.total.real = OS::getTotalCpuTime(&_last_times.total.user, &_last_times.total.system);
308 }
309
310 _heap_monitor_enabled = !args.hasOption(NO_HEAP_SUMMARY) && VM::_totalMemory != NULL && VM::_freeMemory != NULL;
311 _last_gc_id = 0;
312
313 if (args._proc > 0) {
314 _process_sampler.enable(args._proc * 1000000);
315 }
316 }
317
318 ~Recording() {
319 off_t chunk_end = finishChunk();

Callers

nothing calls this directly

Calls 2

hasOptionMethod · 0.80
enableMethod · 0.45

Tested by

no test coverage detected