2021 year-end link clearance

Raymond C

It’s the annual year-end link clearance. You’ve waited a whole year for this. It probably wasn’t worth it.

8 comments

Comments are closed. Login to edit/delete your existing comments

  • Peter Cooper Jr.

    On the contrary, it was definitely worth it, as usual. Thank you!

  • 紅樓鍮

    I’m curious as to why Unity would need a “socket polling thread”; can’t other threads do the polling themselves? Maybe they have to perform garbage collection while they wait for the socket to become available? If that’s the case, they could use overlapped I/O with a signaling event.

    • Kevin Norris

      I believe they were using the word “polling” in the Unix/Linux sense of the term (i.e. referring to epoll(2), which is mostly just a better, but less portable, variant of select(2)). This family of syscalls is roughly synonymous with WaitForMultipleObjects, which ironically is the exact opposite of what most people think of when you say “polling.” I base this belief on the fact that the blog post repeatedly refers to the winsock select() function, which is nearly identical to the POSIX select().

      In other words: This is not a thread that repeatedly asks “Is there any data in the socket? How about now? How about now?” This is a thread that sits blocked inside of select() waiting for something to happen (like a message pump or event loop). You need a dedicated thread to do that, so that other threads can make forward progress.

      Incidentally, the POSIX equivalent to what they are describing is (as far as I understand) completely legal. Specifically, POSIX permits you to send yourself a signal (e.g. using raise(2)), and then from that signal, to call longjmp(2). POSIX does say that you can break things by doing this (specifically, if you interrupt a “non-async-signal-safe” function, then call another non-async-signal-safe function, POSIX says that causes UB), but POSIX also says that select(2) must be async-signal-safe and therefore must not cause UB when interrupted in this fashion. Therefore, POSIX implicitly permits you to longjmp() out of select().

      • 紅樓鍮

        I’m assuming that the threads which post sockets to the polling thread do, possibly after doing other things, actively care about when the socket becomes ready (otherwise the polling thread has no way to post the selecting results back). If that’s the case, then wherever in the code they receive a selecting result, they should be able to instead check the status of an event.

        • Kevin Norris

          It may be the case that a single thread cares about the status of multiple sockets, or that a single socket is of interest to more than one thread. Or it may be the case that they are using a thread pool, and don’t want worker threads hanging around waiting on sockets when they could be processing other work objects.

          (EDIT: Rereading it, they *are* using a thread pool. So that’s probably the reason.)

          More generally: There’s more than one way to do it, and I tend to assume they went with the “socket polling thread” approach in order to reduce the complexity of other parts of the system (lots of signaling events all over the place vs. one dedicated thread that multiplexes all of the I/O on behalf of everybody else).

  • Richard Cox

    As there is no admin contact link for devblogs, and I noticed this here first, this seems the least worse place to report that there appears to be a server side caching problem with the RSS feed.

    Go to https://devblogs.microsoft.com/oldnewthing/ in an incognito/private browsing session. Scroll down and click on the RSS link. And the returned RSS was built 22 Dec 2021, with the latest item being “How do I programmatically reposition monitors in a multiple-monitor system?”. However in a browser that has previously being logged in (and thus has various WP related cookies) the RSS feed was built Mon, 03 Jan and is complete.

    I suspect edge caching has been added at some point, with a cookie based bypass when doing more than just reading. But left a very long cache time for static content, while failing to see that RSS feeds are not static.

    • Brian Beck

      Thank you! I had noticed that my RSS reader was getting Raymond’s posts in batches but hadn’t quite figured out why.

  • Azarien

    Ah, can’t wait for this year’s “Seattle Symphony subscription season at a glance” post 🙂