C++ Asynchronous Framework
userver.tech
userver.tech
I'd like to see versions of all the usual Linux system calls exposed through io_uring instead of having to use different async options or threadpools for everything. I don't know how close we are to that now. I don't know whether userver uses io_uring at all, but it would be nice if it does.
There is a comparison chart with several other such frameworks in various languages, Seastar is not in the chart, but it would be nice if it was.
DPDK is not mentioned unless I missed it (which is possible). I don't know if it is still supposed to be faster than Linux kernel networking. Seastar has good support for it.
The coroutines are stackful and it looks like you have to allocate space for them on instantiation. I don't know if there is any attempt to catch stack overflows. The obvious approaches using mmap might help though they aren't really sound. There is a hardware extension (CHERI) for pointer ownership on ARM and RISC-V that might be cool for this, so I hope it gets traction.
I've never gotten into the deep weeds of cooperative multitasking, but people who have say it gets ugly as the program gets more complicated, and that it tends to give way to OS's with preemption and processes for that reason. C++ itself is also famously fraught with hazards.
Overall userver looks useful and worth looking into so I'm glad to hear about this release.
Right, I meant cooperative yielding (which fibers are), but accidentally called it the exact opposite. Whoops.
>I don't see a mention of what the actual coroutine mechanism is, and I don't see any mention of Boost or C++20 coroutines
It's boost coroutines. The /uboost_coro directory is a vendored copy. It's used in /core/src/engine/coro/pool.hpp
io_uring is a threadpool, and to get performance above epoll, it probably needs to expose the pools and the scheduling choices. eBPF for sceduling? All the simplicity of io_uring basically goes out the window wit that. I added ZEROCOPY to an io_uring instance and it wasn't a fun experience.
It is a very strange interface for networking code. Sending is already mostly async for TCP, and for UDP almost useless (esp without send/recv mmsg calls - you have to make all the packet ordering explicit when create the requests - complete pain in the ass. On the receiving end you have to have an outstanding read request even though you have no idea how much you are going to read (reminds me of the HTTP async hack). The Mmap Packet interface on that is better, just dropping packets off in your address space - for the most part read is a useless call for high perforamnce stuff - you're always reading and buffering. Reading UDP sucks also since no mmsg call and you feel like you're pickign up thousands of pennies off the ground because the asshole wouldn't give you a $10 bill.
It doesn't compose well, hard to debug, etc. There are other interfaces (besides the old, decrepit 200+ verb RDMA/RoCe/iWarp crapfest coming out of the latest standards running jokes). Do something besides BSD sockets on the high end. Anybody rememebr SysV IPC - that might be intereting to try again. BSD netowrking is not the end all of networking APIs.
With io_uring the kernel is doing that for you (you have control of the affinity and how aggressively the kernel thread polls), and copying it to another ring buffer, which is then picked up by userland.
You still get sub-microsecond latency even with this two-level approach, and the advantage is that it works on every NIC that linux has a driver for.
io_uring does pretty much nothing to help reducing this number. It reduces the syscall overhead, but that one actually isn't that high in those applications. What it also will do is moving the actual cost and latency of system calls from when the actual IO is attempted to the time when `io_uring_enter` is called, which essentially batches all IO. For some applications that might be useful to reduce overhead - for others it will just mean `io_uring_enter` becomes an extremely high latency operation which stalls the eventloop. This symptom can be avoided by using kernel-side polling for IO operations which doesn't require `io_uring_enter` anymore. But due to polling overhead this will only be a viable way for a certain set of operations too.
Kernel bypass (AF_XDP/dpdk/etc) will directly avoid the 30% overhead, at the cost of a reduced amount of tooling and observability.
For TCP the story might be slightly different, since the kernel overhead there is usually lower due to more offloads being available. But I think even there, there hasn't been a lot of proof that this actually provides a much different performance profile than existing nonblocking APIs.
second, there should be no spurious copies if you set it up right; it is designed with zero-copy capabilities in mind.
third, whether or not it evalutes ebpf or wastes other time in the kernel stack is a matter of configuration and tuning.
fourth, there are several articles that already demonstrate that it achieves performance close to that of DPDK, with a much easier and more flexible setup.
I like that a lot of the stuff they write about and open-source has a fairly strong focus on efficiency + performance. I also find the supporting docs (those that detail the problem space, how it solves the problem, etc) quite well written and often a lot more comprehensible than docs from other mainstream tech companies (MS docs are the worst, followed by Google).
I’m not sure why this is the case though, is it a different development culture? Different project management culture (provisions time for documentation?) something else?
In short, it's my impression it's an engineering culture problem in large part caused by bad leadership at the types of companies where these projects could be possible.
It really depends on the perspective you're looking at the situation from. If you're concerned with better competitive advantages and the final bottom line for company X or Y, in this current market, in the short term, sure, that sounds amazing, sign me up on that moon rocket!
If your concern is a bit more hard to quantify, for example maximizing human potential, allowing individuals access to high quality technological infrastructure so that we may develop as a species and reach new heights, then you might feel like this approach is a bit short sighted.
unless the company doing this can reap exclusively those new heights, no one will be altruistic enough to make such an investment to the betterment of mankind!
This role is left up to the publicly funded institutions such as gov'ts.
Amorphous long term ideals are great but if you go broke tomorrow you aren’t doing much OSS development next month.
I'm not looking to be a shill in this thread but we might be what you're looking for, and even if it isn't, I'd love to keep in touch as my own life goals involve leveling humanity up in some capacity.
Happy to share details and answer questions if you want to shoot me an email (info is on my user page).
Their concern was the low velocity which felt insane to me because velocity was huge but in an unfocused direction. I am scared of this new world where paper CEO think truly grand visions come to life by half-assing it and playing the part only to the surface level; like I get it if that's your thing, mooning a company and exiting, it's just so hypocritical to act like you believe in the mission statement when you can't even verbalize it, let alone push it forward.
I am hopeful for a new wave of Venture Capitalism with a focus on fundamentals and truly hard problems that are not going to bring in a 3000% ROI in 2 - 3 week-long sprints.
Disclosure: used to work there.
For example, both Go and .NET are very well written engineering achievements with thorough documentation. Many, many other deeply influential projects have also been absorbed by the Apache Foundation or other FOSS initiatives.
Furthermore, every software megacorp has boat loads of teams working on hundreds even thousands (!) of different open source projects. The quality naturally varies.
Let me pick two more esoteric projects as a point of comparison.
Yandex Odyssey [0] an advanced multi-threaded PostgreSQL connection pooler and request router. Figuring out how exactly and when to use this is not quite clear. There is no "getting started" guide for this package. There is barely any explanation for how it works or what it does.
pg_auto_failover [1] run by Citus (owned by Microsoft) monitors and manages automated failover for a Postgres cluster. This repo even has diagrams explaining the workflow and complete instructions.
Frankly, it's unreal just how much code is open nowadays especially from the giants.
Visual Studio, for example, had been under lockdown for 20 years. Now Visual Studio Code is being developed in the open and has extremely thorough documentation that walks developers through the entire build process in painstaking detail.[2] This is a blazing fast editor written in JavaScript of all things! Or consider TypeScript, an incredible engineering feat. There is an entire repo dedicated to engineering notes on how the compiler works with links to interesting feature contributions and a video! [3]
I'm only picking Microsoft here as the primary example since you dumped on them the hardest.
*No other industry does this. It is absolutely wild how much copyleft influenced software culture.*
[0]: https://github.com/yandex/odyssey
[1]: https://github.com/citusdata/pg_auto_failover
[2]: https://github.com/microsoft/vscode/wiki/How-to-Contribute
[3]: https://github.com/microsoft/TypeScript-Compiler-Notes/
Welcome to Russian software or hardware. Nginx is an exception with okayish documentation.
[0] https://spia.news.chass.ncsu.edu/2022/05/13/john-allison-rec...
1) everyone knows you and what you have written and that makes you the authority (not true, obviously, and kind of makes you look like a top hat)
2) what you have written applies to the situation (not true; Russia is an authoritarian dictatorship where every business entity is potentially a state actor)
Most of the more recent library documentation they have is not great though -- seems like autogenerated junk, mostly.
It is either telling or a glaring oversight (let's assume the latter) that there is no comparison with Seastar, which supports both C++20 coroutines and callbacks, with helpful syntax sugar for latter (coroutines are still nicer though!), has green threads too (which it calls "threads"), and can use io_uring, dpdk, etc. Seastar is free, actively developed, and is used by real software with demanding performance and scaling requirements, so in light of Seastar existing I'd expect any new C++ async framework to approach the task of "selling" itself more seriously than "it's like Go or Python but in C++!".
Seastar it's something like multi process architecture, where every process doesn't have synchronization, except n spsc queue per process (used to communicate between cores) and have only cooperative multitasking
So it good scales, if you don't have a lot of data to share, and have a very good work load balancer
But commonly you haven't, so go-like approach more and more easy
That sounds great. Can someone with more experience with C++ tell how good this framework actually is?
Apparently it isn't using C++ 20 co-routines to avoid limiting it as existing support it is still pretty much WIP.
Is there a speed comparison to Go?
Using libgo for 3 year, still cool. Most important: you add it, add some convenience methods on top of it, and forget about it.
Where does it actually get implemented?
I once did cooperative multi-tasking, which I thought this library did as well, in the 1980s in Turbo Pascal under MS-DOS, and wondered how things have changed.
[1] "Definite and indefinite articles (corresponding to 'the', 'a', 'an' in English) do not exist in the Russian language. The sense conveyed by such articles can be determined in Russian by context." https://en.wikipedia.org/wiki/Russian_grammar
No matter how good this product is , Yandex as company is extremely toxic. Contributing to this product you are indirectly contribute in killing people.
They are advertising ( online ) recruitment process of an extremely poor and depressed regions to go and fight in ukraine.
They are one of the major propaganda engine of a regime who combined 18th century imperialist where they are excited to capture new territories and praise it will be good for their isolated economy.
80% of Russians Support war. Hence yandex as company is in charge of something even more frightful actions. They are actually hate ukrainains getting to the level of nazzis that considered some the west european countries a broken version of Germans. To compare. Soviet Union had thousands of Schools in ukrainian, printed good quality books in Ukrainian, they only didn't tolerate politics. Russians don't recognize ukraine as a nation with any rights and opened educational camps. The first thing they do on captured territories they destroy Ukrainain books, schools materials and any relations with culture. They import brainwashed teachers from Russia and forcefully educate kids.
School Teachers are backbone of their regime. Guess who provide them software? Yandex .
Yandex software is definitely used to run filtration camps, forcefully re-educate kids from their native language into Russian and other things no one could imagine would exist in 21st century.
So no, this is not yet another proxy war between two big powers. This a war of reborn 18th century imperialism combined with fascist way of mobilizing russian people.
Is up to you to support their project or not, but one day this new world order can come into your house.
Yandex is very much a part of this strategy. It started out as a domestic competitor to Google and as Russia has been banning and censoring Google and other foreign services domestically, it became more important.
So, this parent comment while obviously very political given current circumstances, is actually very on topic. Yandex is part of the information war on the ground in the Ukraine right now. And not just the Ukraine. Russia's sphere of influence spreads quite wide.
A few practical considerations:
- Would you use native libraries like this as part of your architecture that are controlled by people with a history of infiltrating e.g. voting machines, infrastructure used by media companies, etc. Believe what you will but that would be solid no for me just from a security point of view. There's just no way to know what piggybacks along with that code base.
- Given the above, would you contribute to such a project and help the people behind it and further their goals?
I'm sure it's technically great stuff, but no thanks.
Thanks for openly admitting your technical incompetence in the domain.
If you are trying to find something obscure, yandex is always my final option, before I give up.
Google is basically a Amazon pipeline at this point, I save every useful URL because I know I won't be able to find it again.
If you are trying to buy something google is easily the best, or anything local, or news related.
Bing is a better general search engine, for quick searches.
As my comment notes yandex has its place in the western search world, and is very useful for long tail searches.
Hardly off topic, while your snide response is.
I apologise