Closed amitv87 closed 4 years ago
Thanks, will have a look
Great find, it is fixed in https://github.com/uNetworking/uWebSockets.js/commit/4be2f2bfc2d508dd4b90933fe226c7136e3501bf
However, if you actually go ahead and make a request with your browser it now fails like so:
> domain.js:129
domain.enter();
^
TypeError: domain.enter is not a function
at topLevelDomainCallback (domain.js:129:12)
I haven't kept up to date with what the Node.js crazy people have been up to, so I don't really get this whole async_context nonsense they introduced. I just pass {0, 0} as async_context - obviously it doesn't work with domains, but wasn't domains deprecated or something?
Okay, you're supposed to init an async_context for every callback or collection of callbacks you might call "async" in the future.
Like so:
node::async_context async_context = node::EmitAsyncInit(args.GetIsolate(), args.Holder(), "app yo", node::AsyncHooksGetTriggerAsyncId(args.GetIsolate()));
Where async_context is two doubles. This is done once, up front.
This solves the REPL case, however just like anything the Node.js team touches, this horrendously cuts performance to hell:
In REPL mode with async_context:
Running 10s test @ http://localhost:9001
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 180.44us 55.69us 641.00us 86.73%
Req/Sec 27.60k 3.49k 33.09k 63.37%
554657 requests in 10.10s, 41.79MB read
Requests/sec: 54917.63
Transfer/sec: 4.14MB
In REPL mode with EXPERIMENTAL_FASTCALL:
Running 10s test @ http://localhost:9001
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 95.35us 32.05us 0.88ms 83.37%
Req/Sec 51.90k 6.45k 65.34k 70.30%
1043230 requests in 10.10s, 78.60MB read
Requests/sec: 103294.77
Transfer/sec: 7.78MB
That is a loss of 48% performance. Seriously what the fuck are they even doing?
Meanwhile in Python land:
Running 10s test @ http://localhost:3000
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 80.46us 28.18us 326.00us 80.75%
Req/Sec 61.31k 7.61k 114.14k 75.12%
1225572 requests in 10.10s, 84.15MB read
Requests/sec: 121353.90
Transfer/sec: 8.33MB
Some 120% higher..
Okay I'm not going to support REPL mode right now, or in the future unless someone forces me to. At least I now know what needs to be done to support it, should I have to.
Thanks for reporting.
Got it, thanks for the explanation.
Run the below mentioned code from node in REPL mode
Node throws exception when
server.listen()
is invoked