News for hackers. Stuff that matters.
Re:Datacenter RPCs can be general and fast by baybal2 on Monday March 18, 2019 @06:51AM (#19420045)
Been working on something similar as a sub-sub-sub contractor for Alibaba's DCs.

The physical latency is nowhere near as scary as latency of a shitty NIC and software... 20 metre roundtrip is only 200 nanoseconds, or about the same as pulling something from DRAM.

Re:Datacenter RPCs can be general and fast by CoolGuySteve on Monday March 18, 2019 @07:47AM (#19420296)
The Linux network stack needs to get its shit in order. Kernel bypass libraries like EVFI transmit UDP in 250ns whereas the kernel typically takes several usec.

Transitioning into kernel space shouldn’t take that long so a lot of needless instructions must be getting executed.

Re:Datacenter RPCs can be general and fast by ignoramous on Monday March 18, 2019 @08:05AM (#19420382)
For any meaningful elastic deployment at scale, Linux's (or rather any OS) TCP/IP stack will have to be bypassed through user-space programs: It has all of the upsides and few of the downsides.

Ref: https://opennetworking.org

Not just the datacenters, but even 5G deployments, which would be exclusively IPv6 based, would sport user-space processing of packets and flows.

Ref: https://opencord.org

Re:Datacenter RPCs can be general and fast by CoolGuySteve on Monday March 18, 2019 @08:07AM (#19420394)
Exactly my point, the kernel shouldn’t have to be bypassed. It should just be fast.
Re:Datacenter RPCs can be general and fast by convolvatron on Monday March 18, 2019 @12:33PM (#19422574)
there are a couple pretty core assumptions that make that hard:

read() interfaces expect the kernel to put the data where you asked. its hard but not impossible to coordinate with the NIC to demultiplex the packet and get it into the right place without a copy. almost all of the time you just want to see the data, you dont care that it lands in this particular spot.

getting control flow in and out of the kernel is expensive. target address need to be checked. registers often need to be saved.

things like the kernel firewall take a certain amount of work to determine the packet status

there are lots of mitigations, but at some point you run into a conflict between general purpose multi-process functions and performance.

if you ran your application on a dedicated arm next to the nic I bet you'd see a difference. maybe that shouldn't be so hard.

Re:Datacenter RPCs can be general and fast by CoolGuySteve on Monday March 18, 2019 @02:21PM (#19423615)
That still doesn't add up though. System call overhead is something like 500ns to 1usec depending on the call. Copying a large 1500 byte UDP MTU from ram is pessimistically along the lines of 2.5 usec (1500 bytes / 64 byte cacheline * 100ns L3 access).

So a simple UDP recv() + copy from network card buffer to userspace should be about 3-4usec. In the real world, it's more like 6 or 7usec the last time I timed it.

Admittedly, the unix API could use a refresh. A lot of unix calls like getaddrinfo are perfectly happy to allocate and give you a buffer. A "fast_recv" could easily do the same and just hand you a page from a kernel page pool directly that you then have to free.

By avoiding the buffer copying, you could get something in the same ballpark as kernel bypass but without all the bespoke code and frameworks in every application. And in the end, that's kind of the point of having an "Operating System" in the first place.

Re:Datacenter RPCs can be general and fast by ignoramous on Monday March 18, 2019 @04:01PM (#19424632)
> So a simple UDP recv() + copy from network card buffer to userspace should be about 3-4usec. In the real world, it's more like 6 or 7usec the last time I timed it.

Not sure where the Linux kernel lags (may be at scale it kind of tails out?)-- if you read Google's paper on their network load balancer, Maglev, where section 5.2.1 specifically calls out 30% performance degradation without bypass on smaller packet sizes.

> By avoiding the buffer copying, you could get something in the same ballpark as kernel bypass but without all the bespoke code and frameworks in every application.

May be this article from Cloudflare helps paint a proper picture of why certain kind of applications may need to keep bypassing the kernel forever because their requirements are very specific and not because the kernel can't be made to go faster (ex: a virtual router/switch, or a load-balancer): https://blog.cloudflare.com/why-we-use-the-linux-kernels-tcp...

Re:Datacenter RPCs can be general and fast by TomMarius on Monday March 18, 2019 @01:17PM (#19422984)
Merely passing from user to kernel space is time consuming, it is correct to bypass the kernel.
Re:Datacenter RPCs can be general and fast by pixl97 on Monday March 18, 2019 @01:53PM (#19423330)
No. Dont play games with userspace/kernelspace translation. This always ends in security flaws that allow complete take over of the machine.
Re:Datacenter RPCs can be general and fast by ignoramous on Monday March 18, 2019 @09:35AM (#19420854)
(not an expert, just someone keeping abreast with development in the networking world)

There are inherent problems with relying on the OS in an elastic environment. Kernel's TCP/IP stack could be made to expose very specific APIs to help with NetworkFunctionVirtualization (NFV) and Software-defined Networking (SDN), but the advantages are not clear:

1. Vendors to rely on Kernel devs to do the their biding for their NFV/SDN deployments, and wrestle with various other priorities Kernel might already have.

2. Build/deploy the updated Kernel fleet wide, with those changes (which now include other Kernel changes vendor may or may not want).

3. Cater to strict Kernel community guidelines and expect to be driven by the established processes governed by designated gatekeepers, costing vendors time and speed to market.

With a userspace solution, esp since it allows vendors to be performant by simply interfacing with NICs, the vendors have a measure of control on their own destiny:

1. Deploy at will, at pace.

2. Ability to do custom packet/flow (virtualization), on-the-fly (SDN) even, without requiring any assistance from any other part of the system not in their control.

3. Reduce external factors that might influence their timelines or priorities.

The generic problem, however, with the Kernel's TCP/IP stack needing improvement is orthogonal to this. That effort will have little to no bearing on the direction the Networking industry is moving, imo.

---

Google Maglev (network load balancer): https://ai.google/research/pubs/pub44824

Dropbox MagicPocket (bypassing OS' VirtualFileSystem for storage at scale): https://blogs.dropbox.com/tech/2016/05/inside-the-magic-pock...

Facebook Haystack (an example of problems working with VFS at scale and a solution to it): https://code.fb.com/core-data/needle-in-a-haystack-efficient...

NFV: https://www.electronics-notes.com/articles/connectivity/nfv-...

VNF: https://www.electronics-notes.com/articles/connectivity/nfv-...

Re:Datacenter RPCs can be general and fast by peterwwillis on Monday March 18, 2019 @02:38PM (#19423799)
Everything should just be fast, but it usually isn't. So how are you going to deal with that as a business? Hire kernel hackers and spend expensive time and money to fine-tune one version of a kernel that'll never go upstream? Or pay a vendor for a really fast NIC and integrate it into your app?

(If you're Google, you hire the kernel hackers, but if you're trying to make money off a product and ship it next quarter, you buy the NIC)

Re:Datacenter RPCs can be general and fast by CoolGuySteve on Monday March 18, 2019 @02:56PM (#19423983)
Well right now everyone who cares about latency (including me) is spending time integrating some kind of kernel bypass library into their application that's custom and/or proprietary to a single card vendor and often pretty finicky to configure and integrate correctly.

It's a massive waste of resources. If the kernel could figure out DRI for graphics then they can figure out universal passthrough networking. All the bypass libraries seem to use the same buffer pool + spinlock slot architecture already.

And by your logic, how does anything ever get into the kernel? Nobody should ever contribute anything because "upstream".

Re:Datacenter RPCs can be general and fast by peterwwillis on Monday March 18, 2019 @03:23PM (#19424260)
I'm just saying that fixing the kernel is unlikely to happen unless it's in someone's business interest, and it's usually not. Hell, I bet there's kernel forks out there where people have already solved this, but it won't go upstream, because lawyers.
Re:Datacenter RPCs can be general and fast by baybal2 on Monday March 18, 2019 @07:53AM (#19420328)
Linux net stack is tooo fat, and have to support a gazillion features that are only needed by less than 10 companies in the world each.

That's lack of leadership for you... Kernel people should be pushing back more on such features

Re:Datacenter RPCs can be general and fast by syn0byte on Monday March 18, 2019 @09:52AM (#19420973)
Why would they stop companies from contributing optional code to Linux for their products when you can just (not) compile what you want of it?

The linux eco-system does not begin and end with a RHEL/Ubuntu binary distribution built to run on every crappy PC in the last decade.

Re:Datacenter RPCs can be general and fast by baybal2 on Monday March 18, 2019 @10:12AM (#19421108)
1. not all minority feature commits are config disableable

2. focus - kernel keeps accumulating abandonware code for gimmick features/drivers

Re:Datacenter RPCs can be general and fast by justicezyx on Monday March 18, 2019 @07:35AM (#19420239)
Nice, although they need to went into production to prove any worth.

This type of innovation is pretty much appeared on a daily basis in every senior engineer's head. Not dismissing, it's just a matter of fact in real world systems.