> I think the actual issue with TLS is that compilers will happily hoist TLS address computations across function calls.
TLS has its own issues, but in every situation where this optimisation is fine with TLS, it's fine with FLS too.¹
If you call a function in a fibers / stackful coroutines environment, and the function has a context switch inside (say it does some blocking I/O), by the time the function returns the original context is valid again.
> I do not think that FLS (at least by default) is the right solution as it would consume a lot of memory,
Depends on what you store in FLS. As with TLS, there are situations when it's beneficial for memory, compared with storing replicated copies of data all over the place in arguments and data structures, and situations when it isn't beneficial.
In some it will consume less memory than stackless coroutines, which store copies of the same data in async structures anyway.
> increase the switch overhead
If we're still discussing the article's case that stackless coroutines are better, FLS switch overhead is usually lower than stackless/async overhead.
In the stackless/async version you have compiler-generated loads and stores to context-specific structs that need to be executed every time something context switches for an await.
FLS overhead is updating a single pointer. Even that may be free, because you're going to update some kind of context structure pointer anyway. Even in the base case, stackless will update an equivalent pointer at absolute minimum, but often more.
This is really the same argument for TLS being sometimes useful in threaded programs specifically for performance, as opposed to explicitly passing around copies of pointers and storing them in data structures all over the place. (Of course there are non-performance reasons why people choose TLS or avoid it too.)
> add complexity for little benefit
The benefit is faster programs, and a simpler programming model. You may reasonably disagree :-)
But consider, the Linux kernel is basically all fibers with FLS, and that's a top performer :-)
With regard to programming model: In Linux, it was found to be very much simpler to use fibers (called "tasks" in Linux) than to build an async I/O state machine for filesystems. This is why Linux didn't get useful async I/O in filesystems for a long time, because the state machine version of filesystem operations, though people attempted, was just far too complex in practice to implement for all corner cases, so its async properties were unreliable.
--
¹ At least no problems that are specific to FLS. If you're pointing out there are issues with TLS (without fibers) due to shared library loading/unloading or lazy memory instantiation, that's an issue but it does not support the article's implication that TLS is ok while FLS is not.