News for hackers. Stuff that matters.
Re:A hybrid thread / fiber task scheduler written in C++ 11 by m0zg on Sunday February 09, 2020 @04:36PM (#22284482)
Every time someone writes something like this, I just wish Google open sourced its Fibers - that thing is sublime. Unfortunately that's not going to happen as the niceties that implementation affords require a modified kernel. I think I saw a presentation describing Fibers a few years back by one of its authors, but it's darn near impossible to find because there's also "Google Fiber". If someone has a link, please share. Fibers sort of opened up my mind to what's possible in this space if you go deeper than people usually go. They're also a source of dissatisfaction with how this turns out when people don't go as deep as the authors of Fibers did.

https://github.com/abseil/abseil-cpp/issues/5

Re:A hybrid thread / fiber task scheduler written in C++ 11 by Blackthorn on Sunday February 09, 2020 @05:08PM (#22284659)
It's hard to overemphasize just how amazing that fiber implementation really is. It's completely transformed my view of programming concurrency. That it's been described in a public paper but hasn't been able to be open sourced is a damn shame.

This is the paper: https://www.linuxplumbersconf.org/2013/ocw/system/presentati...

Re:A hybrid thread / fiber task scheduler written in C++ 11 by xmo on Sunday February 09, 2020 @04:43PM (#22284517)
Had a good experience using boost::fiber https://github.com/boostorg/fiber
Re:A hybrid thread / fiber task scheduler written in C++ 11 by nwlieb on Sunday February 09, 2020 @05:43PM (#22284847)
Could you describe what makes the Google Fibers so nice?

I'm also really curious why they require modifications to the Linux kernel. My first guess would be stronger integration with the IO model at the syscall boundary (similar to io_uring).

Edit: is this the talk your referring to? https://www.youtube.com/watch?v=KXuZi9aeGTw

Re:A hybrid thread / fiber task scheduler written in C++ 11 by Blackthorn on Sunday February 09, 2020 @06:25PM (#22285057)
You know how the first time you learned about tcp sockets you made a server that spawned a new thread to handle an incoming connection (or maybe not, people learn differently nowadays).

With the fibers implementation you can just do that. It doesn't kill your performance, and you don't need to go to a painful async model just for performance reasons.

Re:A hybrid thread / fiber task scheduler written in C++ 11 by m0zg on Sunday February 09, 2020 @06:30PM (#22285086)
Pretty much. You get to pretend inside your fibers that you're actually running threads. IIRC (it's been a while) you also get proper stack trace when something barfs, the importance of which cannot be overstated.
Re:A hybrid thread / fiber task scheduler written in C++ 11 by ninkendo on Sunday February 09, 2020 @08:53PM (#22285765)
What are they though? Is this a library for an existing language? A runtime scheduler like the one that does goroutines in Go? If it were open sourced, how would I use it?
Re:A hybrid thread / fiber task scheduler written in C++ 11 by thedance on Sunday February 09, 2020 @09:36PM (#22285952)
It’s just a library that allows easier development of C++ servers in the synchronous, thread-per-requests style, similar to working in Go but a bajillion times better because it’s not in Go.
Re:A hybrid thread / fiber task scheduler written in C++ 11 by Blackthorn on Sunday February 09, 2020 @10:03PM (#22286100)
All of the above, and more -- kernel enhancements. See the linked paper, they detail what they do for the kernel side at least.
Re:A hybrid thread / fiber task scheduler written in C++ 11 by dkersten on Monday February 10, 2020 @03:31AM (#22287337)
> or maybe not, people learn differently nowadays

If by “nowadays” you mean ~2000 when I first learned socket programming (using select!)? ;-)

Re:A hybrid thread / fiber task scheduler written in C++ 11 by m0zg on Sunday February 09, 2020 @07:35PM (#22285433)
Yes, that's the one. Unfortunately it doesn't show any of the API details that a developer would be exposed to.
Re:A hybrid thread / fiber task scheduler written in C++ 11 by thedance on Sunday February 09, 2020 @06:33PM (#22285095)
Fibers should be appreciated in context. They are great at Google because in general the function running on a fiber has no need to ever enter the potentially blocking region. In fibers one has to manually annotate the fact that one is, for example, calling read on a pipe. This works within google because nobody makes system calls from application code and the relevant libraries that need to (mutex) handle it. As a xoogler what I’d like to see opened up is not fibers, which I’d need a new kernel for, but EventManager. EM would be immediately useful to many people.
Re:A hybrid thread / fiber task scheduler written in C++ 11 by Blackthorn on Sunday February 09, 2020 @10:05PM (#22286110)
I don't think that's a huge deal. A preprocessor or a clang plugin (sort of like MOC and moc-ng in QT) could find those system calls and wrap or annotate them appropriately.
Re:A hybrid thread / fiber task scheduler written in C++ 11 by dvirsky on Sunday February 09, 2020 @04:52PM (#22284579)
This is a Google project though. I haven't dug too deeply but maybe it does share something with the internal fibers? (Which I agree are just amazing)
Re:A hybrid thread / fiber task scheduler written in C++ 11 by continuations on Sunday February 09, 2020 @11:05PM (#22286358)
Facebook's folly has fiber.

Boost also has fiber.

How does Google's Fibers differ from other C++ fiber implementations? What makes it so wonderful?