From ec3637574d562c3368c3c0853b7ab1e586634185 Mon Sep 17 00:00:00 2001 From: shirady <57721533+shirady@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:40:42 +0200 Subject: [PATCH] NC | NSFS | Add logging printing measuring tome duration Signed-off-by: shirady <57721533+shirady@users.noreply.github.com> --- src/native/fs/fs_napi.cpp | 5 +++++ src/util/buffer_utils.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/native/fs/fs_napi.cpp b/src/native/fs/fs_napi.cpp index af7bfcf137..5a5418c177 100644 --- a/src/native/fs/fs_napi.cpp +++ b/src/native/fs/fs_napi.cpp @@ -2240,9 +2240,14 @@ register_gpfs_noobaa(const Napi::CallbackInfo& info) static Napi::Value dio_buffer_alloc(const Napi::CallbackInfo& info) { + auto start_time = std::chrono::high_resolution_clock::now(); + double _took_time; int size = info[0].As(); uint8_t* buf = 0; int r = posix_memalign((void**)&buf, DIO_BUFFER_MEMALIGN, size); + auto end_time = std::chrono::high_resolution_clock::now(); + _took_time = std::chrono::duration(end_time - start_time).count(); + DBG2("dio_buffer_alloc took: " << _took_time << " ms"); if (r || (!buf && size > 0)) { throw Napi::Error::New(info.Env(), "FS::dio_buffer_alloc: failed to allocate memory"); } diff --git a/src/util/buffer_utils.js b/src/util/buffer_utils.js index 25576a03ae..5b46f29d73 100644 --- a/src/util/buffer_utils.js +++ b/src/util/buffer_utils.js @@ -212,7 +212,10 @@ class BuffersPool { if (this.buffers.length) { buffer = this.buffers.shift(); } else { + const start = performance.now(); buffer = this.buffer_alloc(this.buf_size); + const end = performance.now(); + dbg.log2(`get_buffer: Time taken to execute buffer_alloc function with buf_size ${this.buf_size} is ${end - start} ms.`); } if (this.warning_timeout) { const err = new Error('Warning stuck buffer_pool buffer');