mfornet / acmx

Competitive programming made simple. VSCode extension.
MIT License
148 stars 9 forks source link

Stress is slow #90

Closed archit120 closed 4 years ago

archit120 commented 4 years ago

I'm using the version from the store so I don't know if this is fixed in master. Running on Windows

mfornet commented 4 years ago

Stress will generate by default 10 test cases and run you solution against each of them, if your solution is taking time running sol.cpp/gen.py/brute.cpp then the slowness is on your side and is expected, however, if those three files run fast enough then there is something happening that need to be investigated. If you can confirm that your case is the latter please let me know, so I can explore further. In that case please, share with me your sol.cpp, gen.py and brute.cpp to run it locally.

What do you mean by doesn't save any changes in sol.cpp? If you mean that file is not saved before stressing, that is a bug, which I expect to be solved in current version on the store.

archit120 commented 4 years ago

What do you mean by doesn't save any changes in sol.cpp? If you mean that file is not saved before stressing, that is a bug, which I expect to be solved in current version on the store. - yes I mean exactly that. I'm running version 0.3.1.

The code shouldn't be slow. I was generating test cases of size ~10 and the time complexity is NlogN and N^2. I'll update with a more trivial example

Salil03 commented 4 years ago

Even I have experienced this. And the culprit (according to me) is gen.py. It takes highest time to generate input testcase

mfornet commented 4 years ago

@archit120 I'll track the issue for saving on stress at #94

mfornet commented 4 years ago

I explore this issue together with @dgc9715, and we believe the culprit might be spawnSync in javascript, which might have a big overhead (mostly on windows). See here and here. We ran a+b code, and stress it, on my machine time reported was <6ms, but on @dgc9715 it reported ~1000ms (which is crazy).

One possible improvement is launching one binary that handles the stressing and communicate with the extension about the progress, but I prefer not to pursue this idea for now since it is much more complex, and it is not clear if it will solve the problem at all. I'm closing this issue for now, but it would still be useful if you provide the source codes of your setup, to check if there is anything else happening.

If you believe, this issue is not related to spawnSync but to something else feel free to open it.

Salil03 commented 4 years ago

Try using https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options instead of spawnsync. How much time does it take?. You can also check this:https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback.

mfornet commented 4 years ago

Just tested both of this functions, and couldn't find any noticeable difference on two different machines (one with Ubuntu and other with OSX)