Live data from Hacker News

uWebSockets: Scalable WebSocket server library for Node.js and C++11

github.com

71–80 of 87 posts

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#71
post #62

It's code like this that gives C++ a bad reputation. It's not modern in any sense. Compiling it with my default warning level in clang gives 482 warnings! Here's a summary: warning: cast from '...' to '...' increases required alignment from 1 to X [-Wcast-align] warning: declaration shadows a field of '...' [-Wshadow] warning: declaration shadows a local variable [-Wshadow] warning: implicit conversion changes signed…

So you enabled pedantic warning level, and you got a bunch of pedantic nonsense warnings. There is a reason for these not to be enabled by default. * Unused parameter -> rly? Who gives a damn? * Use of old style cast -> Well I'm old style, get over it. * No previous prototype declaration -> Again, I do this if I want to. * Shadows field -> who cares? No me. * Cast increases required alignment -> Well, obviously the p…

"Use of old style cast -> Well I'm old style, get over it."

"By using Linux I haven't been limited by the lacking Microsoft C++ compilers only supporting a fraction of the language, but instead been able to use the very latest features and tools."

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#72

Hey there. Just wrote down a few things that came to my mind after seeing this. Don't see it as criticism, but as a few hints/remarks what has to be covered by a websocket (or any other protocol) implementation. Imho the high performance part isn't too hard to achieve and shouldn't be the highest rated. The important thing is that such a server should be rock solid in implementation, otherwise it's worthless. Some th…

The server is async, so there is no blocking functions exposed.

It passes all Autobahn tests, meaning it properly handles close frames & pings etc.

Timers are used to force close connections. The C++ HTTP server does not currently time out, but the Node.js HTTP server does, so this is one issue that needs to be fixed, yes.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#73
post #62

It's code like this that gives C++ a bad reputation. It's not modern in any sense. Compiling it with my default warning level in clang gives 482 warnings! Here's a summary: warning: cast from '...' to '...' increases required alignment from 1 to X [-Wcast-align] warning: declaration shadows a field of '...' [-Wshadow] warning: declaration shadows a local variable [-Wshadow] warning: implicit conversion changes signed…

So you enabled pedantic warning level, and you got a bunch of pedantic nonsense warnings. There is a reason for these not to be enabled by default. * Unused parameter -> rly? Who gives a damn? * Use of old style cast -> Well I'm old style, get over it. * No previous prototype declaration -> Again, I do this if I want to. * Shadows field -> who cares? No me. * Cast increases required alignment -> Well, obviously the p…

It's funny that you don't mention the warnings that can be security vulnerabilities, like integer precision/signedness.

The code screams security vulnerability and I'm not only talking about the warnings.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#74

Earlier quoted context omitted.

Yes, I use uv_poll_t instead of uv_tcp_t because of massive memory and performance differences. Every decision made, has been made from a performance perspective.

I'm interested in what you've learned using libuv while tuning this library. I've read in the past that libuv makes a lot of unnecessary memory allocations. Is this true and/or have you consider writing directly to select/epoll/kqueue? Is there a lot of overhead in using libuv vs the OS provided eventing syscalls?

Libuv is definitely not as "screamingly fast" as it's marketing tells. I found the biggest flaw with libuv to be the uv_tcp_t which forces you to have a user space buffer to receive the data, something not needed when using uv_poll_t.

I do not know what the overhead of uv_poll_t is compared to epoll/kqueue but I think it's a good balance to depend on libuv in this case, and since we need to integrate with Node.js it is kind of required.

I would much rather use mTCP to further improve the performance but then this project would not be as relevant to most developers. Performance & relevance is key - it can be optimized further by using mTCP and such.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#75
post #73

Earlier quoted context omitted.

So you enabled pedantic warning level, and you got a bunch of pedantic nonsense warnings. There is a reason for these not to be enabled by default. * Unused parameter -> rly? Who gives a damn? * Use of old style cast -> Well I'm old style, get over it. * No previous prototype declaration -> Again, I do this if I want to. * Shadows field -> who cares? No me. * Cast increases required alignment -> Well, obviously the p…

It's funny that you don't mention the warnings that can be security vulnerabilities, like integer precision/signedness. The code screams security vulnerability and I'm not only talking about the warnings.

Yep, I seem to recall there was one in MySQL a while back that just involved a simple int->char conversion where the overflow would trigger a match due to a random seed that was involved in the password path.

I'm a big fan of Wall Werror with pragma for specific sections where you must work around the warnings. Does a great job of catching issues with contributions.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#76
post #62

It's code like this that gives C++ a bad reputation. It's not modern in any sense. Compiling it with my default warning level in clang gives 482 warnings! Here's a summary: warning: cast from '...' to '...' increases required alignment from 1 to X [-Wcast-align] warning: declaration shadows a field of '...' [-Wshadow] warning: declaration shadows a local variable [-Wshadow] warning: implicit conversion changes signed…

So you enabled pedantic warning level, and you got a bunch of pedantic nonsense warnings. There is a reason for these not to be enabled by default. * Unused parameter -> rly? Who gives a damn? * Use of old style cast -> Well I'm old style, get over it. * No previous prototype declaration -> Again, I do this if I want to. * Shadows field -> who cares? No me. * Cast increases required alignment -> Well, obviously the p…

Maybe using a `reinterpret_cast` would actually have better performance. A C-style cast tries to do a bunch of casts in order, starting with a static and ending with reinterpret (see http://anteru.net/blog/2007/12/18/200/).

There's no excuse for using c-style casting in C++ considering the depth of the different casts we as developers have at our disposal.

Additionally, I just looked at the code, and is there any reason it's all stuffed into a single header and source file? I don't know if I'm just being naive, but isn't this a slightly bad design? There seem to be a lot of different data structures that could easily be broken out and make it a bit easier to follow the flow of the project.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#77
post #47

Earlier quoted context omitted.

Humility and a collaborative attitude are really important to get the best results. When people attack your code, it isn't an attack on you. It makes your code better. It's one of the downsides to releasing any opinionated project (and many good projects are opinionated). For my part, I won't use software written by someone who doesn't either refute criticism or use it to improve code, and I'm not satisfied you're do…

According to logic, this quote "yeah - the C++ bits were clearly written by someone who doesn't know the language well. I'd be careful about using this code in production." is a personal attack. I get offended by this, personally. When I get offended, personally, I answer how ever I see fit. Thank you, you will be missed. I don't know what to do without you.

Welcome to Hacker News; I'm a moderator here.

The comment that provoked you was rude and dismissive and the sort of thing we ask people not to post. That said, the guidelines here ask you to remain civil even when someone else is uncivil and/or wrong. That's an important rule that we all have to abide by—though it's a challenge, especially when one's own work is being discussed—because otherwise the discussion quality will rapidly deteriorate.

So please either make substantive neutral replies if you can, or don't post anything until you can.

Re: uWebSockets: Scalable WebSocket server library for Node.js and C++11

#79
post #21

Earlier quoted context omitted.

Because Nodejs is known to be highly performant with its single thread model...

Node.js has nothing to do with the performance of this server.

My answer was directed to the comment you made about performance for Python and yet the lib you provide has binding for Nodejs which is not a very fast runtime.
Post reply on HN