Progress on pyntpq
Eric S. Raymond
esr at thyrsus.com
Sun Oct 16 19:48:43 UTC 2016
Hal and Gary talking about improving ntpq refocused my attention.
I don't have any pressing things to do right now (that's good - that
means our hard work has brought the code close to a 1.0 state) so I
took another whack at adding some capabilities to pyntpq in order to
scope the job of turning it into a complete replacement for the C
The good news is the iostats command works now.
The better news is that the machinery I put in place for that should
make getting sysinfo, kerninfo, sysstats, monstats, authinfo, and
pstats to work pretty easy; all I need to do is add handlers for a
couple of data-format codes.
The even better news than that is that I found out why pyntpq
transactions with ntpd have been flaky up to now. My client-packet
engine in pylib/ wasn't padding the packets it shipped to a 4-byte
boundary, and it turns out ntpd takes that requirement seriously.
I think we can make rapid progress on pyntpq now. If you crank ntpq
debug up to 4 you get to see the mode 6 packet exchanges, and they're
simple enough that you can often figure out how to write Python to do
the same thing without looking much at the rather opaque code that
implements it in C ntpq.
Furthermore, Python's compression ratio over C is pretty amazing for
this kind of code. I'm seeing huge swathes of tricky list-traversal
pointer-dancing logic compact down into one-line Python comprehensions.
All of which means this: Please don't sink effort into fixing the C
ntpq code - we're going to throw it away, probably within the next
three months. Our time would be better spent getting pyntpq to the
functionality C ntpq has now, then fixing pyntpq's UI.
I'm not just saying this will be more efficient, I'm saying the C
ntpq code is so headachy that it will probably be *faster*. Even
if you have to learn Python first...
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
"Guard with jealous attention the public liberty. Suspect every one
who approaches that jewel. Unfortunately, nothing will preserve it
but downright force. Whenever you give up that force, you are
inevitably ruined." -- Patrick Henry, speech of June 5 1788
More information about the devel