Live data from Hacker News

Why is BIND 10 written in C++ and Python?

isc.org

31–40 of 136 posts

Re: Why is BIND 10 written in C++ and Python?

#31

> "C lacks good memory management" C lets you manage memory without possibly inefficient or even broken magical black box automated processes or garbage collectors. Maybe what the author meant to say was "C lacks easy memory management."

Funny you mention "black box automated process" because, what do you think malloc is?

There are two ways of allocating memory directly from the kernel (IIRC), brk and mmap.

There's some management malloc does, and if it's good or not depends on you application.

For example, size, number and behaviour of your allocations. Depending on your situation you may want to do your own memory management.

Re: Why is BIND 10 written in C++ and Python?

#32

This doesn't look good for Python: "Whenever possible, we use Python" "When necessary, we use C++" "As of right now, it ends up that about 75% of our code is C++ and 17% is Python (link) since it turns out that a lot of BIND 10 is performance-critical."

I don't think you are interpreting that correctly. Python is never pushed as "fast". That is exactly how I would use it. Python wherever I could and C++ (or whatever) when performance is crucial.

Re: Why is BIND 10 written in C++ and Python?

#33
post #23

based on the given criteria, wondering why Java wasn't considered.

Probably because of memory usage and garbage collection and the fact that java needs to be installed on most systems whereas C++ needs no dependencies and python comes preinstalled on the usual linux server (probably not python3 but i assume it will be some years before bind10 sees adoption for such critical infrastructure). Also he mentions specialized data structures and memory management. Atleast i wouldn't sleep…

Probably because of memory usage and garbage collection and the fact that java needs to be installed on most systems whereas C++ needs no dependencies

Well, GCC (as in the compiler collection) has had a ahead-of-time compiler for ages:

http://gcc.gnu.org/java/

There is also work in the LLVM camp on AOT Java compilation:

http://vmkit.llvm.org/

Atleast i wouldn't sleep well if i know that the heart of the internet was running Java :P

Well lucky you, only many other vital body parts are running on the JVM via Java, JRuby, and increasingly Scala ;).

Re: Why is BIND 10 written in C++ and Python?

#34
post #5

Earlier quoted context omitted.

Why doesn't it look good for python? As far as I'm aware, Python has never been advertised as a top-performance language, and part of the advantage has always been that you can rewrite performance-critical paths in c. Adding to this, the fact that BIND is something pretty performance-intensive, I don't think this makes it look bad at all.

Because the stated goal was to use Python "whenever possible" and judging by the python2 bashing at the end of the article, the author is a true believer yet the best he could do was 17% of the total code. This also clashes with the belief in the Python community that performance is not an issue because you just rewrite those few critical sections in C/C++. How's 75% as one possible definition of "few"?

Bashing might be a bit harsh. Looks like the author is expressing legitimate concern about the proliferation of Python 2 over 3 and, let's face it, there are a lot of differences while 3 "is the future" as it says.

The percentages may or may not be simply a case of C++ verbosity, but without actually browsing the source, we shouldn't jump the gun on exactly what percentage of "heavy lifting" C++ is doing vs. Python.

Re: Why is BIND 10 written in C++ and Python?

#35
post #7

There's a comment in the post: "As of right now, it ends up that about 75% of our code is C++ and 17% is Python (link) since it turns out that a lot of BIND 10 is performance-critical." Which could easily be taken the wrong way. I believe the right way to think about it is "How much _more_ C++ code would there be, if there wasn't that 17% in Python?".

Hum, I don't think interpreting this comment as Python is not adequate for performance critical applications is misinterpretation. The author makes it very clear in some other part of the text: > [Python] has all of the features that we were looking for… except performance. Now your interpretation is also valid since they could have written everything in C++ but they didn't.

There is a python DNS server running on pypy that seems to get a pretty big speedup over CPython.

Here is the benchmark result: http://speed.pypy.org/timeline/#/?exe=3,6,1,5&base=2+472...

0.002 for pypy VS 0.015 for CPython, which is 6.66 times faster.

So, for the last couple of years they have been wrong - since PyPy has shown pretty good performance in a DNS benchmark, so Python can have pretty good performance ;)

Re: Why is BIND 10 written in C++ and Python?

#36
post #23

Earlier quoted context omitted.

Probably because of memory usage and garbage collection and the fact that java needs to be installed on most systems whereas C++ needs no dependencies and python comes preinstalled on the usual linux server (probably not python3 but i assume it will be some years before bind10 sees adoption for such critical infrastructure). Also he mentions specialized data structures and memory management. Atleast i wouldn't sleep…

Probably because of memory usage and garbage collection and the fact that java needs to be installed on most systems whereas C++ needs no dependencies Well, GCC (as in the compiler collection) has had a ahead-of-time compiler for ages: http://gcc.gnu.org/java/ There is also work in the LLVM camp on AOT Java compilation: http://vmkit.llvm.org/ Atleast i wouldn't sleep well if i know that the heart of the internet was…

Those implementations have quite weak garbage collection implementations (boehm conservative, but I'm not sure), which would just kill the performance. Hotspot JVM has a very sofisticated Incremental Generational garbage collector, which does have a _very_ good performance. I'm pretty sure they had their reasons for not using Java (I actually do have mine too), but, garbage collection is not one of those.

Re: Why is BIND 10 written in C++ and Python?

#37
post #25

Why isn't it written in Node.js?

After careful consideration, as the article mentions, ISC decided a combination of C++ and Python as being more appropriate to the goals of the project. That being safety, stability, established familiarity, speed and of course a level of guaranteed future-proof platform availability. Read: "This is one of the cornerstones of the internet that we didn't want to piss away on novelty". That sounded rude, and I'm sorry…

I think it was a joke.

Re: Why is BIND 10 written in C++ and Python?

#38

> "C lacks good memory management" C lets you manage memory without possibly inefficient or even broken magical black box automated processes or garbage collectors. Maybe what the author meant to say was "C lacks easy memory management."

Consider realloc. Seems like a sensible function, with its ability to extend memory blocks in-place. Except, you can't try to extend a memory block in-place, but not move it if it can't be extended.

malloc and friends really are a quite poor way of managing a memory space if you want to do even slightly clever things I find, unfortunatly

Re: Why is BIND 10 written in C++ and Python?

#39
post #35

Earlier quoted context omitted.

Hum, I don't think interpreting this comment as Python is not adequate for performance critical applications is misinterpretation. The author makes it very clear in some other part of the text: > [Python] has all of the features that we were looking for… except performance. Now your interpretation is also valid since they could have written everything in C++ but they didn't.

There is a python DNS server running on pypy that seems to get a pretty big speedup over CPython. Here is the benchmark result: http://speed.pypy.org/timeline/#/?exe=3,6,1,5&base=2+472... 0.002 for pypy VS 0.015 for CPython, which is 6.66 times faster. So, for the last couple of years they have been wrong - since PyPy has shown pretty good performance in a DNS benchmark, so Python can have pretty good performance ;)

As much as I respect and appreciate Pypy, BIND is one of the core foundational pieces of the internet. It needs to be bulletproof and robust. I don't think Pypy itself qualifies as a mainstream enough language for them to build BIND on. This isn't a slight on Pypy, because the core problem is simply that it hasn't been around for long enough and subjected to enough stress to earn entry into the highest of the high tiers of reliable software. That's not a bad thing per se, and it can be fixed, but in the meantime, ISC has to take the situation as it is now, not how it might be in five years.

Re: Why is BIND 10 written in C++ and Python?

#40

> "C lacks good memory management" C lets you manage memory without possibly inefficient or even broken magical black box automated processes or garbage collectors. Maybe what the author meant to say was "C lacks easy memory management."

Unless you're the most complete full stack engineer ever, at some point you're going to be relying on a magic black box. The trick is to know what is acceptable as a black box or not. At this point in time, I'd say most memory management systems are pretty competent enough to warrant usage.
Post reply on HN