Replies: 3 comments 3 replies
-
|
So I'm somewhat biased by the REST point of view, but leaning into that for a second, if you require writing something to |
Beta Was this translation helpful? Give feedback.
-
|
It doesn't bother me much that you stray from the Plan 9 way of doing things, but I'd always prefer the Plan 9 way given that I use (actually, I dual-boot, because |
Beta Was this translation helpful? Give feedback.
-
|
It's worth pointing out that a I'm not an active plan 9 user, so I cannot test this, but I suspect that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The one bit of feedback I've gotten regarding the design of Wanix and its patterns has been about what Plan 9 calls "the clone dance". Some people (including myself!) don't like read operations having side-effects, which is how allocation works. You read a file either called
newor under a directory callednew, it allocates it and returns the ID.When I first implemented this, I noticed sometimes resources would unexpectedly be allocated. At the time, allocation was done when the file was open for reading, which depending how the FS is implemented can happen when just doing a stat. Many programs (including the shell) will do this causing one or more allocations. I changed it so allocation doesn't happen until there is an explicit read on the open file, which resolved it enough to prevent stats causing allocation.
As I mentioned, this is loosely modeled after how Plan 9 does it. And actually parts of Linux use this same pattern (like
/dev/net/tun). But both Plan 9 and Linux do it a little differently: when you close the file, the resource is cleaned up. In other words:You keep the file descriptor open for the duration of your use of the resource. Meaning you don't just keep the resulting ID, you keep the FD as well. Two stateful things, more complexity. Plus, what if using the resource spans multiple processes? An ID is just data. Whereas a FD is scoped to the current process.
A lot of Plan 9 isn't documented. I think they ended up using their own primitives to solve problems as they came up, establishing patterns that became institutional knowledge. I would think a side effect read would bother them too. Perhaps it was an early established pattern that looking back they would maybe do differently. Talking to a Plan 9 person, they pointed out that at least when the file is closed, the resource is cleaned up. So if some program unintentionally allocated by opening the file, at least the resource (which would only be allocated, not necessarily initialized) wouldn't be around very long and it would likely be gone by the time the program finished.
As much as that makes sense to me, it does make it quite a bit harder to pull off in Plan 9's shell, let alone common shells of today. Not even sure you can do this in some of them (probably):
So I simplified it. I'm not trying to exactly re-create Plan 9 or make a strictly compatible system. I'm just defaulting to their choices to get into a similar design headspace. I'm open to straying from Plan 9 when it makes sense. I decided to keep the basic idea, but make it as simple as creating a REST resource, which is more widely understood and familiar these days.
I'd like to get some feedback. I have thoughts on alternatives, but I don't want to propose anything if this isn't a big deal. Let me know if you have thoughts here, or at the very least, please answer this poll...
3 votes ·
Beta Was this translation helpful? Give feedback.
All reactions