<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Gambit community and Marc,</div><div dir="ltr"><br></div><div dir="ltr">This email is to draw your attention to the issue "Mitigate the bug in poll() on Mac OS X (= on OSX, "--enable-poll" causes CPU hogging currently)".</div><div><br>It basically means, the Gambit REPL on Mac OS causes the laptop fan to spin, due to that its poll() keeps returning instantly instead of waiting for IO which is its intended behavior.<br></div><div dir="ltr"><br></div><div dir="ltr">I just registered it on GitHub, <a href="https://github.com/gambit/gambit/issues/498">https://github.com/gambit/gambit/issues/498</a>. Copy of the report below so you don't even need to click the link.</div><div dir="ltr"><br></div><div>While this issue is already known from before (both in Gambit and in Mac OS), I think to help clarify what's a good fix, me and someone with a Mac will run the tests below.</div><div><br></div><div>Any thoughts and solution suggestions much appreciated.</div><div><br></div><div>Adam</div><div><br></div><div dir="ltr"> -- </div><div dir="ltr"><br></div><div dir="ltr"><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">This issue has been noticed by at least someone before, e.g. Gerbil's getting started page says "./configure […] --enable-poll # For Linux and BSD; don't use this on macOS". [1]</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">I'll now pass some references on this topic:</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><ul style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;padding-left:2em;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">
<li style="box-sizing:border-box">
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">Apple's poll() man page in the latest version today (March 2020) says "BUGS: The poll() system call currently does not support devices.". (Not sure exactly what "devices" is here however from how Gambit reacts we can reliably deduce that Gambit's use of the console on Mac OS X does count as a "device" in this definition, unless of course poll() would have even more bugs that are not listed in this page.) [2]</p>
</li>
<li style="margin-top:0.25em;box-sizing:border-box">
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">Apple's poll() has a really ugly history: until before Mac OS 10.12.2 (released Dec 2016), it always returned immediately. [3]</p>
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">For that old bug, I see at least two test scripts available, [3] and [4], the first one just uses a timeout, and the second one poll():s a pipe. The tests appear to be time-dependent.</p>
</li>
</ul><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">Now to the parts I'm not clear about and where I guess some further steps are needed:</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><ul style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;padding-left:2em;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">
<li style="box-sizing:border-box">
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">Make a minimal reproduction script in C:</p>
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">I don't have a Mac OS installation to test on. Someone else who does, told me that poll() to the STDIN FD does work as expected, meaning the Gambit CPU hog bug on Mac OS X is not tested for that route (if the test outcome is correct).</p>
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">We should figure out which FD or device is the console "device" that still today maces Mac OS' poll() return immediately.</p>
</li>
<li style="margin-top:0.25em;box-sizing:border-box">
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">Make Gambit make a debug print-out to get confirmed exactly how poll() fails:</p>
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">Just for completeness I'd love to know which return value poll() gives Gambit on Mac OS X right now, and also exactly which FD Gambit polls for. This is specifically with a fresh "gsi" with default IO settings, that is waiting for console input only.</p>
</li>
<li style="margin-top:0.25em;box-sizing:border-box">
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">Isolate the issue in Gambit:</p>
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">We should do some alternative testing in Gambit where Gambit is <em style="box-sizing:border-box">not</em> poll():ing the console, to get validated that for Gambit it's the console specifically that poll() doesn't work for i.e. for network descriptors and files it does what it should.</p>
</li>
<li style="margin-top:0.25em;box-sizing:border-box">
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">Guess about how the solution should look:</p>
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">I guess the solution is that Gambit's ./configure on Mac OS X should ignore --enable-poll .</p>
<p style="margin-top:16px;margin-bottom:16px;box-sizing:border-box">If anyone likes to compile binaries for all platforms including Mac OS X that will never poll() the console, maybe those guys should do their |compile-file| with the C define correspondent of --enable-poll, that should be something like "-DENABLE_POLL", need to check.</p>
</li>
</ul><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">So preliminarily it looks to me like that the latest version of Mac OS X does have a bug in poll(), and presuming this is correct, it's a great shame that Apple is forcing its whole ecosystem into ancient select() with all its constraints, quite incredible really.</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">I'll participate in just a bit more testing of this bug per above later. The CPU hogging is enough to turn on the fan on a Mac laptop, making it nicer to have the Gambit REPL not run than run, that is a really unnecessary annoyance.</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box"><a class="gmail-user-mention" style="color:rgb(36,41,46);font-weight:600;text-decoration:none;white-space:nowrap;box-sizing:border-box;background-color:initial" href="https://github.com/feeley">@feeley</a> what do you think & is a good solution.</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">(<a class="gmail-user-mention" style="color:rgb(36,41,46);font-weight:600;text-decoration:none;white-space:nowrap;box-sizing:border-box;background-color:initial" href="https://github.com/vyzo">@vyzo</a> after this is fixed the "# For Linux and BSD; don't use this on macOS" precaution in Gerbil should not apply anymore. That is also nice as special Gambit configure arguments for Mac OS X is an unnecessary asymmetry.)</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">Thanks!</p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">[1] <a style="color:rgb(3,102,214);text-decoration:none;box-sizing:border-box;background-color:initial" href="https://github.com/vyzo/gerbil/blob/bb287c5840fcb747c1047d8ff82c0977d8f9ca77/doc/guide/getting-started.md">https://github.com/vyzo/gerbil/blob/bb287c5840fcb747c1047d8ff82c0977d8f9ca77/doc/guide/getting-started.md</a></p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">[2] <a style="color:rgb(3,102,214);text-decoration:none;box-sizing:border-box;background-color:initial" href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/poll.2.html" rel="nofollow">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/poll.2.html</a></p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:16px;word-spacing:0px;white-space:normal;box-sizing:border-box">[3] <a style="color:rgb(3,102,214);text-decoration:none;box-sizing:border-box;background-color:initial" href="https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/" rel="nofollow">https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/</a></p><span style="font:400 14px/1.5 -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;font-size-adjust:none;font-stretch:normal;float:none;background-color:rgb(255,255,255)">
</span><p style="text-align:left;color:rgb(36,41,46);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;margin-top:0px;margin-bottom:0px;word-spacing:0px;white-space:normal;box-sizing:border-box">[4] <a style="color:rgb(3,102,214);text-decoration:none;box-sizing:border-box;background-color:initial" href="https://stackoverflow.com/questions/591826/it-really-looks-like-os-x-has-a-bug-when-using-poll-on-a-named-pipe-fifo" rel="nofollow">https://stackoverflow.com/questions/591826/it-really-looks-like-os-x-has-a-bug-when-using-poll-on-a-named-pipe-fifo</a></p><b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br></div></div></div></div></div></div></div></div>