Open jcrben opened 2 months ago
I have now tested it once in a similar environment. Bitlocker + Win11 + Node (without VFox) and could not reproduce this problem. The hint that repeated execution speeds up the runtime actually points to a problem outside of httpyac. My app does not cache anything and always executes the same actions. He also seems to spend most of his time in node. You may be able to narrow down the problem
node.index.js
console.info("hello world");
Maybe try adding some IO access, to this script.
getNearestPackageJson
is a function of node. The logic is simple, just needs IO. Do you have slow IO? Try adding a package.json next to the httpy file.
On a Windows work machine - which is a bit locked down and secured with MS Defender but generally not too slow -
httpyac
with no arguments takes about 30 seconds on the first run, and that time is similar on both powershell and msys2 bash (my preferred shell on Windows). On subsequent runs it takes about 2.5 seconds which is OK but not great.That 2.5 seconds would be acceptable, but the Windows paging cache seems to expire rather quickly - so I'm back to a 20-30 second run before too long. Not sure if there's a way to increase it - looking into that.
Fortunately, I do have WSL bash, which takes around half a second, but I'd like to be able to run this without loading the virtual machine.
On my personal Windows laptop, which is a bit more powerful - Lenovo Slim Pro X - it's similarly super slow on the first run but then usually around 0.8 seconds.
I can't really share details from my work machine given security requirements, but I did profile it on my personal machine using the node 22 built-in profiler and asked github copilot what was slow. It didn't have too much to say unfortunately.
Steps:
Copilot Q&A
Copilot A:
The profile analysis you've provided indicates that most of the CPU time is spent in the shared libraries, specifically in node.exe and ntdll.dll. This suggests that the performance bottleneck might be in the Node.js runtime or in system-level operations, rather than in your JavaScript code.
The JavaScript functions listed in the profile (getNearestParentPackageJSON, normalizeString, and various built-in functions) each only account for a small fraction of the total CPU time.
Here are a few possibilities for why your program might be slow:
I/O operations: If your program is doing a lot of disk or network I/O, this could be slowing it down. I/O operations are often the bottleneck in Node.js programs.
CPU-intensive tasks: If your program is doing a lot of CPU-intensive tasks, this could be slowing it down. However, the profile suggests that this is not the main issue.
Node.js runtime: There could be some inefficiency in the Node.js runtime or in the way it's interacting with the system. The fact that a lot of time is spent in node.exe and ntdll.dll suggests this possibility.
To further diagnose the issue, you could try the following:
Use the --prof flag with the --log-timer-events flag to get more detailed timing information. Use a profiling tool like the Chrome DevTools profiler or the v8-profiler npm package to get a more detailed profile of your program. Look at the specific operations your program is doing when it's slow. Are there any I/O operations, network requests, or other potentially slow operations? Try running your program on a different system or with a different version of Node.js to see if the issue is specific to your current environment.
Copilot Q:
this is a profile analysis from the command node --prof-process which analyses isolate-00000210A0651000-10672-v8.log
why is this slow?
prof-process-analysis.txt: