News for hackers. Stuff that matters.
Re:Ntimed – NTPD replacement by SrslyJosh on Sunday December 21, 2014 @09:18PM (#8781671)
That sounds like you're implying that safety has no value, the only "overhead" worth considering is CPU cycles (what about the programmer's time/effort/sanity?), and that abstractions have negative value.

I don't think that's how you're supposed to software.

Re:Ntimed – NTPD replacement by threeseed on Sunday December 21, 2014 @09:48PM (#8781746)
It's a core operating system component not some web app.

Overhead is important since Linux is designed to run on a whole spectrum of devices. Abstractions mean you are bringing in more code i.e. greater complexity, space, overhead. And frankly nobody could care less about programmer's time/effort/sanity in this case. It is a tightly focused, specific utility that shouldn't see too many changes after a certain point.

Re:Ntimed – NTPD replacement by moe on Sunday December 21, 2014 @10:38PM (#8781855)
Overhead is important since Linux is designed to run on a whole spectrum of devices.

Like the difference between a ntpd.c vs ntpd.go is going to matter for anyone...

If you really find yourself stuck with an embedded device small enough that a few megabytes of RAM matter then you can still use the old C implementations, it's not like they are going away.

Abstractions mean you are bringing in more code i.e. greater complexity, space, overhead.

In this case abstractions mean you can probably write the whole thing in under 2 kloc, get memory safety for free, and base it on a network stack that other people actually use and debug independently.

It is a tightly focused, specific utility that shouldn't see too many changes after a certain point.

Umm. Yea. Right. Tell that to the ntpd guys with their 100kloc codebase...

Re:Ntimed – NTPD replacement by mcgoo on Monday December 22, 2014 @09:22AM (#8783112)
The jitter introduced by garbage collection in a go implementation could well be significant, even with the new "never pause the mutator for more than 1ms" guarantee.
Re:Ntimed – NTPD replacement by moe on Monday December 22, 2014 @11:04AM (#8783563)
How much of the code is actually sensitive to interruptions?

Why not write that part in C and leave the rest to the more suitable language?

I would guess that's a rather small portion of the codebase, essentially the callouts to adjtime().

I don't buy into the low-latency FUD. C isn't a magical realtime language either; what happens when the system is under high load? What about delays in the kernel/network stack?

As a layman I would think incoming frames will have to be stamped with a hardware high resolution timestamp at arrival anyway, regardless of the language. And yes, this internal timestamp will have to be compared immediately before setting the hwclock. I would argue this is the only part that really needs to be written in a GC free language.

I might be wrong on this, but I'd like to see a stronger argument than "could well be significant" for writing yet another generation of a baseline system daemon in an unsafe language...

And speaking of latency: If this really is such an issue, why hasn't NTP long been moved into the kernel?

Re:Ntimed – NTPD replacement by jeltz on Sunday December 21, 2014 @11:58PM (#8782062)
Overhead matters, but languages like Rust, D, and Nim add little overhead if any and should be perfectly possible to use as systems languages.
Re:Ntimed – NTPD replacement by zzzcpan on Sunday December 21, 2014 @09:33PM (#8781699)
Yeah. Especially considering that CPU overhead has very little value for time syncing program.
Re:Ntimed – NTPD replacement by phkamp on Monday December 22, 2014 @04:18AM (#8782527)
It's always a good idea to do a quick back-of-the-envelope calculation before generalizing like that:

About 2 million servers were sold world-wide in 2014Q2

Assume 25% runs UNIX and NTPD -> half a million servers

Assume NTPD uses 0.1% of machine resources -> 500 fully loaded servers.

Assume 100W/server -> 50 kW

50kW for half a year -> 220,000 kWh

Assume 500g CO2/kWh -> 110 tons of CO2

QED: I think CPU overhead is a very relevant concern for time synching programs.

Re:Ntimed – NTPD replacement by lazyjones on Monday December 22, 2014 @04:27AM (#8782538)
> Assume NTPD uses 0.1% of machine resources -> 500 fully loaded servers.

Bold assumption. It uses 0.0006% on my slow 6 years old box (over 13 days uptime). Let's be generous and say it's 0.001%, then you get 1.1 ton of CO2, which is the equivalent of the production of about 32.8 Kg of beef. I don't think such dramatic conclusions can be made from those facts.

Re:Ntimed – NTPD replacement by phkamp on Monday December 22, 2014 @04:54AM (#8782579)
First, I doubt your kernels statistics actually account correctly at that level of precision. (If it does, that alone would waste a lot of CPU cycles!)

Second, have you checked the memory footprint of NTPD ? "machine resources" is more than CPU cycles.

And don't forget: That number was one quarters purchase of servers, running for half a year. All the servers bought in 2010, 2011, 2012, 2013 and the other half of the year were not included.

Things add up.

Re:Ntimed – NTPD replacement by lazyjones on Monday December 22, 2014 @11:34AM (#8783705)
> Second, have you checked the memory footprint of NTPD ? "machine resources" is more than CPU cycles.

284K, which is a whopping 0.04% of available memory. I don't see how this increases CO2 output though.

> Things add up

To a still very insignificant number, dwarfed by the beef consumption of the people reading this.

I'd say there are better arguments in favour of using dated languages than this.

Re:Ntimed – NTPD replacement by phkamp on Monday December 22, 2014 @02:25PM (#8784610)
I can't change how much beef people eat.

I can change how their computers synchronize time.

Re:Ntimed – NTPD replacement by zzzcpan on Monday December 22, 2014 @10:00AM (#8783247)
I think you missed something in your calculations.

Removing 0.1% load from the machine will not result in 0.1% of energy savings, very very far from it if in any at all. And that's not even what we want to calculate. We want the difference with hypothetical alternative in a safer language, which is hard to guess, but is unlikely to be in the same order or two with your calculations.

Re:Ntimed – NTPD replacement by StillBored on Monday December 22, 2014 @12:15AM (#8782107)
but latency, and jitter, are important in this application. Two things that discount most of the "safer" languages. After ignoring inmature ones, the field is pretty barren.
Re:Ntimed – NTPD replacement by jnbiche on Monday December 22, 2014 @01:53AM (#8782290)
Yes, but if you're building an app for the future, then what excuse is there for not using Rust, which is both very low latency and very close to a 1.0 release?

I get that sometimes you just want to hack in a language that's familiar to you, but then call your project a fun side project and not the "NTPD replacement" (and yes, I know who phk is).

Re:Ntimed – NTPD replacement by jnbiche on Monday December 22, 2014 @10:41AM (#8783443)
It's a little bit sad that at -3 votes, this is the lowest voted comment I've ever had in my ~4 years on HN, lower than a number of controversial political comments.

To clarify, I'm not claiming that everyone should start using Rust. Now was I claiming that PHK is somehow unqualified for the task, far from it. I'm not even saying C is a bad language (I like C), or that people should stop using C altogether. But if you're building an security-critical application designed to be used in the future across millions of servers, and one that requires low-latency, I simply don't understand why you wouldn't strongly consider Rust, which offers strong guarantees about memory and type safety along with low latency and a very modern and complete standard library. Or Ada. Or OCaml.

Re:Ntimed – NTPD replacement by xorcist on Monday December 22, 2014 @05:04AM (#8782594)
Please start by showing us the PLL in Rust (details are available at phk's blog) and reason about how those changes affects the workings of the program. Is it more readable? Less? More exact? That I would be interested in.
Re:Ntimed – NTPD replacement by nwmcsween on Sunday December 21, 2014 @09:49PM (#8781752)
Safety has value it just doesn't imply overhead. Abstractions are a negative, they make reasoning burdensome.
Re:Ntimed – NTPD replacement by cbd1984 on Sunday December 21, 2014 @10:55PM (#8781906)
Abstractions are what make it possible to reason about complex systems. Being able to ignore parts of your codebase is the only way to make changes to it once it gets beyond a trivial size.

The whole of the Unix philosophy is enforcing this policy of strong abstractions by making each part of a complex overall system its own binary, such that they can only communicate using the file I/O abstraction, possibly via pipes. C was therefore designed for a system which promotes abstractions.

Re:Ntimed – NTPD replacement by rab_oof on Monday December 22, 2014 @12:28AM (#8782138)
Lifting up constants into defines/consts and DRYing up C code makes for shorter, less error-prone and easier-to-understand codebases. Eg there's no reason to continue writing code like it's 1960's because we can steal good software eng and maintainability lessons from everything that has come since. (If one must maintain absolute portability.)

PS: I would like to see a toolchain for Go that emits portable C instead of statically linking in a giant runtime... Lightweight camping vs. YAGNI hoarding. Seriously, the weight of runtimes would be the biggest barrier to serious systems deployment, outshining the slowdown, productivity and safety tradeoffs. (Eg Go would need to play nice with embedded constraints including memory usage as well.).

Re:Ntimed – NTPD replacement by nwmcsween on Monday December 22, 2014 @01:00AM (#8782194)
It's not "writing like 1960's programming' gratuitous abstraction just creates a burden for the programmer to dig through, it makes reasoning a pain.
Re:Ntimed – NTPD replacement by rab_oof on Tuesday December 23, 2014 @09:34PM (#8791295)
That's taking things literally too far. Common sense says take some giant unsigned long long constant used in multiple places that cannot be vertically aligned and give it the semantic meaning it deserves. The goal of reducing LoC is to not obscure meaning but to write less code that states its behavior more clearly. Abstractions are garbage if they are confusing / hide meaning, but abstractions are immensely valuable if they perform complex operations in a clear manner (say an well-designed http client lib in C.)
[deleted]
Re:Ntimed – NTPD replacement by cbd1984 on Monday December 22, 2014 @12:23AM (#8782128)
Even if your comment both made sense and was factually accurate, it wouldn't have much relevance to the kind of C programming I'm talking about: For example, mmap(2) isn't defined in the C standard but in POSIX, but it's universal in the Unix and Unix-like OS world to the extent programs can safely rely on it.

Standards are good and useful things, but they're only fully written down in retrospect.

Re:Ntimed – NTPD replacement by tedunangst on Sunday December 21, 2014 @11:49PM (#8782035)
Section 7.19.3.
Re:Ntimed – NTPD replacement by function_seven on Monday December 22, 2014 @12:39AM (#8782160)
I'm getting 7.21.3, reading here[1], but that's the draft spec for C11. I couldn't find the official one anyhere.

[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

Re:Ntimed – NTPD replacement by tedunangst on Monday December 22, 2014 @12:53AM (#8782184)
Oh, I'm still bumming around with a copy of C99. Now that I'm here, I'll add the definition of streams in the previous section is probably the more interesting part, since that's the term used for the idea of abstracting tapes and terminals.