News for hackers. Stuff that matters.
Re:Much faster incremental apt updates by orf on Sunday December 27, 2015 @08:34AM (#10797394)
This is crazy, apt has been reading diffs a byte at a time? Think of the millions of hours that have been wasted due to this.
Re:Much faster incremental apt updates by joosters on Sunday December 27, 2015 @10:08AM (#10797604)
That's unfair. Pick any big program and you'll find examples of really dumb inefficient code. We all write it, no matter how smart we think we are.

Instead, think of all the millions of satisfied users of the software, none of whom bothered to fix up this problem until now.

Re:Much faster incremental apt updates by jlarocco on Sunday December 27, 2015 @10:54AM (#10797745)
I wouldn't even call it dumb, it's just what happens when a big group of people are writing software together. Somebody writes a function, other people see it and start using it in ways the original author didn't intend.

One byte at a time could've been a quick hack that was "good enough" in the original author's use case, because he wasn't reading a lot of data or only calling it once or something. Somebody else saw "readline" and decided it was exactly what he needed and decided to use it everywhere.

Re:Much faster incremental apt updates by jberryman on Sunday December 27, 2015 @02:08PM (#10798369)
OT, but that's one reason comments are important. Also in the alternative hypothetical where reading a byte at a time was required: if that's not documented someone might come along and thing that was merely incidental or even buggy behavior and change it. That's why I'm not sympathetic to programmers who think that they write "self-documenting" code or something. If you don't document (even briefly) what your code is supposed to do then bugs become diffuse things that no one is responsible for, and which are difficult to spot. </ramble>
Re:Much faster incremental apt updates by molyss on Sunday December 27, 2015 @05:04PM (#10798919)
I profoundly disagree with that. Comments always end up not following the actual implementation. In this example, "self documenting" the code would be to name the function "unbufferedRead" or something similar that shows that not having a buffer is part of the contract. You make it buffered, you're breaking the contract. Anything else is merely applying temporary (because they'll rot), hidden (because if someone is reading code that calls myVeryWellDocumentedFunction, they won't see the documentation, especially if the function is just incompletely named) and inaccurate (because the only accurate thing is the code) band aids. There's a reason it's said that naming stuff is one of the hardest things in programming.
Re:Much faster incremental apt updates by jlarocco on Sunday December 27, 2015 @11:14PM (#10799824)
I disagree. Even with the name "ReadOneUnbufferedByteAtATime", the code doesn't (and can't) explain why the author is doing it that way instead of reading multiple bytes at once. If that decision is important then there needs to be a comment explaining it.

In my experience, "self documenting" code is brittle and hard to change because nobody knows (or remembers) which implementation details are important and which aren't, so they're afraid to change it. Is it reading a byte at a time for a reason? Or does it not matter and it's just happens to be done that way?

There's more to software development than just churning out code, and being disciplined about keeping comments up to date is one of those things that just needs to be done, IMO.

Re:Much faster incremental apt updates by jberryman on Monday December 28, 2015 @01:43AM (#10800198)
I agree that naming things well is a great way to document them. However I think that in most of the codebases I've worked on it is quite common for a function/method to do many things some of which are incidental and some necessary, and it would be difficult to include the full set of these in the method's name. (comments also help to make it obvious when a function is, perhaps, too complex and arbitrary).

In addition to good naming, strong static types and functional purity help a great deal (but I won't try to evangelize haskell here :))

> ...hidden (because if someone is reading code that calls myVeryWellDocumentedFunction, they won't see the documentation, especially if the function is just incompletely named)

what is your proposed alternative? Ideally a function would do the only possible sensible thing imaginable, but that is frequently not attainable.

> ...inaccurate (because the only accurate thing is the code)

Well when the code doesn't match the spec in the comments, we've found a bug in the code, or a bug in the spec. Either way we can find someone to blame. This is vastly better than finding a bug and not knowing whether the function or the caller should be fixed.

Re:Much faster incremental apt updates by grandinj on Sunday December 27, 2015 @08:57AM (#10797446)
No, they made the right choices. (1)Make it work. (2)Make it correct. (3)Make it fast.

Can take a long time to get to step 3 with something as safety critical as an update tool.

Re:Much faster incremental apt updates by rektide on Sunday December 27, 2015 @01:33PM (#10798264)
Sometime between the start and the end, there's often a mandatory burn it all down step required to more fully satisfy either (2) or (3). Watching hundreds of MB of data getting written to my HD for an apt-get update makes me 90% certain that Debian indeed needs to burn it all down.

To their credit, they started really early. And burning it all down seems to be an increasingly better option for purely extrinsic reasons; the late mover advantage keeps increasing, and better and better options keep emerging. A LMDB-based refactor perhaps? This is probably a pipe dream, alas: Debian developers must have a hundred different programs that all build and extend forward the original "make it work" technology, to make it survivable. And that's really my final counter to your cute linear notion of ongoing improvement: the mold is set, and there are dozens of things bound up in what has happened.

Re:Much faster incremental apt updates by julian-klode on Tuesday December 29, 2015 @12:17PM (#10807681)
Where do you want LMDB? apt has a super fast binary cache, the repositories and dpkg store their package lists as text files.

RPM systems have the advantage IIRC that they can basically just download a bunch of sqlite3 databases, which means they do not have to parse any data.

Re:Much faster incremental apt updates by hyc_symas on Sunday January 10, 2016 @05:17PM (#10877493)
AFAIK RPM uses BerkeleyDB, though it will probably switch to LMDB https://bugzilla.redhat.com/show_bug.cgi?id=1086784
Re:Much faster incremental apt updates by k__ on Sunday December 27, 2015 @09:25AM (#10797514)
> implying apt is a young tool and the maintainers didn't have many years to go from 1 to 3
Re:Much faster incremental apt updates by baghira on Sunday December 27, 2015 @09:46AM (#10797557)
According to the developer the bug was present only in the 1.1 series, which is just a few months old (it was pre-released at debconf 2015, and is not in Jessie if i'm not mistaken).
Re:Much faster incremental apt updates by r0muald on Sunday December 27, 2015 @12:32PM (#10798077)
Furthermore pdiffs were introduced in ~2006: https://www.debian-administration.org/article/439/Avoiding_s...