Skip to content

Commit

Permalink
NC | NSFS | Add logging printing measuring tome duration
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
  • Loading branch information
shirady committed Dec 17, 2024
1 parent 970e67b commit ec36375
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/native/fs/fs_napi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Napi::Number>();
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<double, std::milli>(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");
}
Expand Down
3 changes: 3 additions & 0 deletions src/util/buffer_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit ec36375

Please sign in to comment.