News for hackers. Stuff that matters.
Re:uWebSockets: Scalable WebSocket server library for Node.j... by hendzen on Friday May 20, 2016 @09:43AM (#11737669)
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.

EDIT: Specifically I'm referring to the usage of raw pointers, unchecked pointer arithmetic, goto for flow control and raw new/delete calls. The author says they have run tests under valgrind, but that doesn't say anything unless the inputs were malicious. Ideally it should be compiled with ASAN and run under something like afl-fuzz.

Also - why do you take a libuv dependency - then use uv_poll_t directly with raw send/recv calls instead of using uv's provided TCP primitives?

Re:uWebSockets: Scalable WebSocket server library for Node.j... by alexhultman on Friday May 20, 2016 @09:49AM (#11737728)
Also - this server passes the entire Autobahn with no fails, passes Engine.IO tests, Primus tests and exits gracefully with no Valgrind issues. Also, it builds with no warnings. Also, it has been running for weeks stable.
Re:uWebSockets: Scalable WebSocket server library for Node.j... by IIlllIllIIIIlII on Friday May 20, 2016 @09:57AM (#11737793)
Can I ask why you choose to implement your own queue when many exist within C++? (e.g. using queue<T> or list<T>)
Re:uWebSockets: Scalable WebSocket server library for Node.j... by alexhultman on Friday May 20, 2016 @10:06AM (#11737852)
Memory footprint and performance.

This implementation is way, way more lightweight. And it assumes that the buffer being queued has a struct Message in its head, so it doesn't have to allocate a node - one memory allocation is therefore skipped.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by alexhultman on Friday May 20, 2016 @09:46AM (#11737704)
If you allocate the buffer as a char * you should delete it as a char *. Thank you for the kind words.
Re:uWebSockets: Scalable WebSocket server library for Node.j... by babuskov on Friday May 20, 2016 @10:43AM (#11738161)
> usage of raw pointers, unchecked pointer arithmetic, goto for flow control and raw new/delete calls

But without all that you would lose performance which seems to be the main goal of this project.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by alexhultman on Friday May 20, 2016 @10:48AM (#11738216)
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.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by infamouscow on Friday May 20, 2016 @12:28PM (#11739178)
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?
Re:uWebSockets: Scalable WebSocket server library for Node.j... by alexhultman on Friday May 20, 2016 @01:30PM (#11739749)
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.j... by alexhultman on Friday May 20, 2016 @10:42AM (#11738150)
1. It has been compiled with ASAN. 2. What you suggest would blow the memory footprint 16x.

Thanks for giving your infinite enlightenment, after looking at my code for 10 minutes. I guess your 10 minutes of reading the code is infinitely much more valuable than my 3 months work on it?

Get over yourself.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by ddlerk on Friday May 20, 2016 @11:00AM (#11738332)
If you want people to take you and your projects seriously, you are going to have to stop being so antagonistic. I've seen you act this way here, on Reddit, and on GitHub...

The sarcasm, childish comments, and resorting to insults the second someone criticizes your code isn't giving me any hope that you can competently maintain a project like this.

Take a look over the HN Guidelines [1] and the "Approach to comments"[2] sections of the site.

[1] https://news.ycombinator.com/newsguidelines.html

[2] https://news.ycombinator.com/newswelcome.html

Re:uWebSockets: Scalable WebSocket server library for Node.j... by Klathmon on Friday May 20, 2016 @11:04AM (#11738384)
There's no need to resort to insults in-reply to questions or criticisms.

It's a valid question (that i think you did answer, but not very well). Dropping to very unsafe "lower levels" should only be done when absolutely necessary as a single mistake here could cause massive security issues.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by smt88 on Friday May 20, 2016 @11:13AM (#11738455)
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 doing either of those.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by alexhultman on Friday May 20, 2016 @11:29AM (#11738615)
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.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by dang on Friday May 20, 2016 @02:27PM (#11740260)
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.j... by FilterSweep on Friday May 20, 2016 @12:13PM (#11739030)
It has been said posting code on HN a literal "Trial By Fire",

But reading the comments in this thread this has gone overboard....to the point I, as a casual observer, had to say something.

I agree, "clearly written by someone who doesn't know the language well", _IS_ a direct attack on the developer and not the code. And I couldn't comprehend the mental gymnastics it would take to explain otherwise.

There is a major difference between:

"Why did you implement your own Queue here?" and "This guy doesn't understand C++. Don't use his code."

Don't let them win by giving into replying with a "Redditor" form of rebuttal filled with snark.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by k__ on Friday May 20, 2016 @12:12PM (#11739022)
Hey man, don't let them troll you.

When reading your comments and code on the web, it seems like you're really an awesome dev, but you give in to hate comments by such people too easily.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by vvanders on Friday May 20, 2016 @12:15PM (#11739046)
You obviously have strong options about this. That said let me offer you a bit of advice.

I don't care how good your code/framework is if you blow up on just a minor bit of criticism. This is a great example where some comments in code could help teach people who don't know better.

Long gone are the days where the solo programmer could make important software without interacting with the rest of the outside world. Knowing when to check your ego at the door is just as important as getting the technical bits right.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by toomim on Friday May 20, 2016 @01:01PM (#11739481)
I agree, the original post was an attack. But then you attacked back. Now you're both mudslinging uglyshit.

Also, your work looks good. I want to use it.

Re:uWebSockets: Scalable WebSocket server library for Node.j... by jacobwcarlson on Friday May 20, 2016 @08:05PM (#11742473)
There are many improvements that could be made to this code. However the developer is extremely antagonistic and unwilling to accept criticism so I doubt that the issues will ever be fixed.