| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,11 @@ The available categories are: | |||
| 26 | 26 | * `node.net.native`: Enables capture of trace data for network. | |
| 27 | 27 | * `node.environment`: Enables capture of Node.js Environment milestones. | |
| 28 | 28 | * `node.fs.sync`: Enables capture of trace data for file system sync methods. | |
| 29 | + * `node.fs_dir.sync`: Enables capture of trace data for file system sync | ||
| 30 | + directory methods. | ||
| 31 | + * `node.fs.async`: Enables capture of trace data for file system async methods. | ||
| 32 | + * `node.fs_dir.async`: Enables capture of trace data for file system async | ||
| 33 | + directory methods. | ||
| 29 | 34 | * `node.perf`: Enables capture of [Performance API][] measurements. | |
| 30 | 35 | * `node.perf.usertiming`: Enables capture of only Performance API User Timing | |
| 31 | 36 | measures and marks. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,18 +42,57 @@ using v8::Object; | |||
| 42 | 42 | using v8::ObjectTemplate; | |
| 43 | 43 | using v8::Value; | |
| 44 | 44 | ||
| 45 | + static const char* get_dir_func_name_by_type(uv_fs_type req_type) { | ||
| 46 | + switch (req_type) { | ||
| 47 | + #define FS_TYPE_TO_NAME(type, name) \ | ||
| 48 | + case UV_FS_##type: \ | ||
| 49 | + return name; | ||
| 50 | + FS_TYPE_TO_NAME(OPENDIR, "opendir") | ||
| 51 | + FS_TYPE_TO_NAME(READDIR, "readdir") | ||
| 52 | + FS_TYPE_TO_NAME(CLOSEDIR, "closedir") | ||
| 53 | + #undef FS_TYPE_TO_NAME | ||
| 54 | + default: | ||
| 55 | + return "unknow"; | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 45 | 59 | #define TRACE_NAME(name) "fs_dir.sync." #name | |
| 46 | 60 | #define GET_TRACE_ENABLED \ | |
| 47 | - (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ | ||
| 48 | - (TRACING_CATEGORY_NODE2(fs_dir, sync)) != 0) | ||
| 61 | + (*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( \ | ||
| 62 | + TRACING_CATEGORY_NODE2(fs_dir, sync)) != 0) | ||
| 49 | 63 | #define FS_DIR_SYNC_TRACE_BEGIN(syscall, ...) \ | |
| 50 | 64 | if (GET_TRACE_ENABLED) \ | |
| 51 | - TRACE_EVENT_BEGIN(TRACING_CATEGORY_NODE2(fs_dir, sync), TRACE_NAME(syscall), \ | ||
| 52 | - ##__VA_ARGS__); | ||
| 65 | + TRACE_EVENT_BEGIN(TRACING_CATEGORY_NODE2(fs_dir, sync), \ | ||
| 66 | + TRACE_NAME(syscall), \ | ||
| 67 | + ##__VA_ARGS__); | ||
| 53 | 68 | #define FS_DIR_SYNC_TRACE_END(syscall, ...) \ | |
| 54 | 69 | if (GET_TRACE_ENABLED) \ | |
| 55 | - TRACE_EVENT_END(TRACING_CATEGORY_NODE2(fs_dir, sync), TRACE_NAME(syscall), \ | ||
| 56 | - ##__VA_ARGS__); | ||
| 70 | + TRACE_EVENT_END(TRACING_CATEGORY_NODE2(fs_dir, sync), \ | ||
| 71 | + TRACE_NAME(syscall), \ | ||
| 72 | + ##__VA_ARGS__); | ||
| 73 | + | ||
| 74 | + #define FS_DIR_ASYNC_TRACE_BEGIN0(fs_type, id) \ | ||
| 75 | + TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(TRACING_CATEGORY_NODE2(fs_dir, async), \ | ||
| 76 | + get_dir_func_name_by_type(fs_type), \ | ||
| 77 | + id); | ||
| 78 | + #define FS_DIR_ASYNC_TRACE_END0(fs_type, id) \ | ||
| 79 | + TRACE_EVENT_NESTABLE_ASYNC_END0(TRACING_CATEGORY_NODE2(fs_dir, async), \ | ||
| 80 | + get_dir_func_name_by_type(fs_type), \ | ||
| 81 | + id); | ||
| 82 | + | ||
| 83 | + #define FS_DIR_ASYNC_TRACE_BEGIN1(fs_type, id, name, value) \ | ||
| 84 | + TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(fs_dir, async), \ | ||
| 85 | + get_dir_func_name_by_type(fs_type), \ | ||
| 86 | + id, \ | ||
| 87 | + name, \ | ||
| 88 | + value); | ||
| 89 | + | ||
| 90 | + #define FS_DIR_ASYNC_TRACE_END1(fs_type, id, name, value) \ | ||
| 91 | + TRACE_EVENT_NESTABLE_ASYNC_END1(TRACING_CATEGORY_NODE2(fs_dir, async), \ | ||
| 92 | + get_dir_func_name_by_type(fs_type), \ | ||
| 93 | + id, \ | ||
| 94 | + name, \ | ||
| 95 | + value); | ||
| 57 | 96 | ||
| 58 | 97 | DirHandle::DirHandle(Environment* env, Local<Object> obj, uv_dir_t* dir) | |
| 59 | 98 | : AsyncWrap(env, obj, AsyncWrap::PROVIDER_DIRHANDLE), | |
@@ -132,7 +171,8 @@ inline void DirHandle::GCClose() { | |||
| 132 | 171 | void AfterClose(uv_fs_t* req) { | |
| 133 | 172 | FSReqBase* req_wrap = FSReqBase::from_req(req); | |
| 134 | 173 | FSReqAfterScope after(req_wrap, req); | |
| 135 | - | ||
| 174 | + FS_DIR_ASYNC_TRACE_END1( | ||
| 175 | + req->fs_type, req_wrap, "result", static_cast<int>(req->result)) | ||
| 136 | 176 | if (after.Proceed()) | |
| 137 | 177 | req_wrap->Resolve(Undefined(req_wrap->env()->isolate())); | |
| 138 | 178 | } | |
@@ -151,6 +191,7 @@ void DirHandle::Close(const FunctionCallbackInfo<Value>& args) { | |||
| 151 | 191 | ||
| 152 | 192 | FSReqBase* req_wrap_async = GetReqWrap(args, 0); | |
| 153 | 193 | if (req_wrap_async != nullptr) { // close(req) | |
| 194 | + FS_DIR_ASYNC_TRACE_BEGIN0(UV_FS_CLOSEDIR, req_wrap_async) | ||
| 154 | 195 | AsyncCall(env, req_wrap_async, args, "closedir", UTF8, AfterClose, | |
| 155 | 196 | uv_fs_closedir, dir->dir()); | |
| 156 | 197 | } else { // close(undefined, ctx) | |
@@ -196,7 +237,8 @@ static MaybeLocal<Array> DirentListToArray( | |||
| 196 | 237 | static void AfterDirRead(uv_fs_t* req) { | |
| 197 | 238 | BaseObjectPtr<FSReqBase> req_wrap { FSReqBase::from_req(req) }; | |
| 198 | 239 | FSReqAfterScope after(req_wrap.get(), req); | |
| 199 | - | ||
| 240 | + FS_DIR_ASYNC_TRACE_END1( | ||
| 241 | + req->fs_type, req_wrap, "result", static_cast<int>(req->result)) | ||
| 200 | 242 | if (!after.Proceed()) { | |
| 201 | 243 | return; | |
| 202 | 244 | } | |
@@ -256,6 +298,7 @@ void DirHandle::Read(const FunctionCallbackInfo<Value>& args) { | |||
| 256 | 298 | ||
| 257 | 299 | FSReqBase* req_wrap_async = GetReqWrap(args, 2); | |
| 258 | 300 | if (req_wrap_async != nullptr) { // dir.read(encoding, bufferSize, req) | |
| 301 | + FS_DIR_ASYNC_TRACE_BEGIN0(UV_FS_READDIR, req_wrap_async) | ||
| 259 | 302 | AsyncCall(env, req_wrap_async, args, "readdir", encoding, | |
| 260 | 303 | AfterDirRead, uv_fs_readdir, dir->dir()); | |
| 261 | 304 | } else { // dir.read(encoding, bufferSize, undefined, ctx) | |
@@ -298,7 +341,8 @@ void DirHandle::Read(const FunctionCallbackInfo<Value>& args) { | |||
| 298 | 341 | void AfterOpenDir(uv_fs_t* req) { | |
| 299 | 342 | FSReqBase* req_wrap = FSReqBase::from_req(req); | |
| 300 | 343 | FSReqAfterScope after(req_wrap, req); | |
| 301 | - | ||
| 344 | + FS_DIR_ASYNC_TRACE_END1( | ||
| 345 | + req->fs_type, req_wrap, "result", static_cast<int>(req->result)) | ||
| 302 | 346 | if (!after.Proceed()) { | |
| 303 | 347 | return; | |
| 304 | 348 | } | |
@@ -325,6 +369,8 @@ static void OpenDir(const FunctionCallbackInfo<Value>& args) { | |||
| 325 | 369 | ||
| 326 | 370 | FSReqBase* req_wrap_async = GetReqWrap(args, 2); | |
| 327 | 371 | if (req_wrap_async != nullptr) { // openDir(path, encoding, req) | |
| 372 | + FS_DIR_ASYNC_TRACE_BEGIN1( | ||
| 373 | + UV_FS_OPENDIR, req_wrap_async, "path", TRACE_STR_COPY(*path)) | ||
| 328 | 374 | AsyncCall(env, req_wrap_async, args, "opendir", encoding, AfterOpenDir, | |
| 329 | 375 | uv_fs_opendir, *path); | |
| 330 | 376 | } else { // openDir(path, encoding, undefined, ctx) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments