LWN: Comments on "Go filesystems and file embedding" https://lwn.net/Articles/827215/ This is a special feed containing comments posted to the individual LWN article titled "Go filesystems and file embedding". en-us Mon, 10 Nov 2025 17:00:29 +0000 Mon, 10 Nov 2025 17:00:29 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Go filesystems and file embedding https://lwn.net/Articles/828832/ https://lwn.net/Articles/828832/ HelloWorld <div class="FormattedComment"> Passing a context around is trivial in purely functional programming, it&#x27;s called the Reader Monad. It&#x27;s built right into some modern effect systems like ZIO...<br> </div> Fri, 14 Aug 2020 17:43:38 +0000 Go filesystems and file embedding https://lwn.net/Articles/827730/ https://lwn.net/Articles/827730/ Cyberax <div class="FormattedComment"> Inheritable thread locals work just fine in Java. The problem is that Java is a bit old-fashioned regarding threading, so a lot of parallel stuff is done in shared global thread pools because thread creation is expensive. This kinda makes inheritable thread-locals a moot point.<br> <p> On the other hand, in Go pretty much nobody uses long-lived goroutine pools so GLS variables can work just fine. Moreover, pprof labels already work this way (there&#x27;s no way to read them, you can only set them).<br> </div> Fri, 31 Jul 2020 19:56:35 +0000 Go filesystems and file embedding https://lwn.net/Articles/827666/ https://lwn.net/Articles/827666/ ibukanov <div class="FormattedComment"> By cancelable in my initial response I meant ability to interrupt a given blocked call so it returns immediately. Timeouts are a subset of that.<br> <p> What would be ideal if FileHandle can be used as a pseudo-channel in the select statements in Go. But that requires very non-trivial implementation especially on Linux.<br> </div> Fri, 31 Jul 2020 14:28:04 +0000 Go filesystems and file embedding https://lwn.net/Articles/827655/ https://lwn.net/Articles/827655/ gray_-_wolf <div class="FormattedComment"> Context is not used just for cancellation. For example, we are passing logger in it. So for those cases it would still be useful even if you cannot actually cancel the operation.<br> </div> Fri, 31 Jul 2020 12:35:46 +0000 Go filesystems and file embedding https://lwn.net/Articles/827647/ https://lwn.net/Articles/827647/ benhoyt <div class="FormattedComment"> By cancellation in this context, do you mean timeouts/deadlines? Or actually being able to cancel a read/write at any given time? If it&#x27;s timeouts, does it work to specify a read/write timeout when you open the filesystem client (or Open() a file), rather than for example having a ctx/timeout on every Read call? Similar to what Russ Cox asks here: <a href="https://www.reddit.com/r/golang/comments/hv976o/qa_iofs_draft_design/fywmc1h/">https://www.reddit.com/r/golang/comments/hv976o/qa_iofs_d...</a><br> </div> Fri, 31 Jul 2020 09:14:38 +0000 Go filesystems and file embedding https://lwn.net/Articles/827644/ https://lwn.net/Articles/827644/ smurf <div class="FormattedComment"> Define &quot;does not work&quot;. My experience (async Python code with contextvars) says otherwise.<br> <p> </div> Fri, 31 Jul 2020 08:35:17 +0000 Go filesystems and file embedding https://lwn.net/Articles/827639/ https://lwn.net/Articles/827639/ ibukanov <div class="FormattedComment"> Automatic inheritance for thread locals does not work. Java, where new threads are not created as often as in Go, provides interface to manually deal with the inheritance but even with that subtle bugs are possible.<br> <p> And any thread-local with a mutable state that is shared between threads pretty much implies that it uses some form of locking internally. At which point using a global map with a mutex looks like a reasonable replacement for a thread-local especially for such heavy thing as Context.<br> <p> Note I agree that it sucks that a language with GC does not provide a simple way to associate a piece of data with its threads, but at least one can see where the resistance is coming from.<br> </div> Fri, 31 Jul 2020 07:54:54 +0000 Go filesystems and file embedding https://lwn.net/Articles/827641/ https://lwn.net/Articles/827641/ Cyberax <div class="FormattedComment"> Not all filesystems are local. Cancellation is very much possible for NFS (for which I&#x27;m actually already using a Go-based client).<br> </div> Fri, 31 Jul 2020 07:38:25 +0000 Go filesystems and file embedding https://lwn.net/Articles/827638/ https://lwn.net/Articles/827638/ ibukanov <div class="FormattedComment"> On the other hand Linux still lacks a good story with cancelable local file reads. Adding context to file-related API would be a lie on a most popular server system. <br> </div> Fri, 31 Jul 2020 07:23:05 +0000 Go filesystems and file embedding https://lwn.net/Articles/827633/ https://lwn.net/Articles/827633/ Cyberax <div class="FormattedComment"> There&#x27;s no other choice than to carry explicit context object in absence of GLS. I don&#x27;t mind the absence at all, actually. It leads to cleaner code, because developers stop doing things like storing database transactions in thread locals.<br> <p> And quite a few companies actually have code style that enforces context as the last (or first) parameter to every method in the exported interfaces.<br> </div> Fri, 31 Jul 2020 04:31:51 +0000 Go filesystems and file embedding https://lwn.net/Articles/827618/ https://lwn.net/Articles/827618/ benhoyt I'm in two minds about context. It's definitely useful, but I agree with <a href="https://faiface.github.io/post/context-should-go-away-go2/">Michal Štrba's 2017 article</a> that it's like a virus that starts polluting all your APIs with "ctx context.Context" (which apart from being something you have to add everywhere, the naming is stutter-y). I personally wouldn't mind "goroutine local storage" for values, though I think that can be solved in other ways too (eg: in an HTTP context, a map of *http.Request to data). And of course there's the very hack-ish libraries that add GLS, like <a href="https://github.com/jtolio/gls">jtolio/gls</a>. As for timeouts, those can <i>usually</i> be done more explicitly, or with an overall timeout per client. For cancellation, I have much less experience and don't know if there's a good solution there. Fri, 31 Jul 2020 00:02:51 +0000 Go filesystems and file embedding https://lwn.net/Articles/827594/ https://lwn.net/Articles/827594/ Cyberax <div class="FormattedComment"> Each goroutine would have its own TLS context (GLS?), with potential automatic inheritance for new goroutines.<br> <p> In other words, exactly like pprof labels work right now: <a href="https://rakyll.org/profiler-labels/">https://rakyll.org/profiler-labels/</a><br> </div> Thu, 30 Jul 2020 19:10:24 +0000 Go filesystems and file embedding https://lwn.net/Articles/827593/ https://lwn.net/Articles/827593/ ehiggs <div class="FormattedComment"> How would TLS even work in the face of goroutines that can be scheduled in different threads?<br> </div> Thu, 30 Jul 2020 19:08:12 +0000 Go filesystems and file embedding https://lwn.net/Articles/827582/ https://lwn.net/Articles/827582/ mgk <div class="FormattedComment"> While there are places contexts don&#x27;t make sense, I&#x27;m 100% behind you that there&#x27;s a lot coming out without context support, that is a head scratcher: Like filesystems. I had hoped we stopped assuming filesystems were always available, always fast, never hung, etc. back in the 90&#x27;s... <br> </div> Thu, 30 Jul 2020 17:48:56 +0000 Go filesystems and file embedding https://lwn.net/Articles/827579/ https://lwn.net/Articles/827579/ Cyberax <div class="FormattedComment"> The inconsistency from Go team is frustrating. On one hand they are stoically opposed to any kind of thread-local storage (which I don&#x27;t mind at all), on the other hand they are introducing new APIs that don&#x27;t accept contexts.<br> <p> And without contexts it&#x27;s not possible to do context-based logging at all.<br> </div> Thu, 30 Jul 2020 17:40:14 +0000