Live data from Hacker News

How we decreased GitLab repo backup times from 48 hours to 41 minutes

about.gitlab.com

201–210 of 273 posts

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#201

Earlier quoted context omitted.

This is not a complicated algorithm. A hash map (dictionary) or a hash set is how you would always do deduplication in Python, because it is easiest to write / least keystrokes anyway. That is not the case in C though, as it is much easier to use arrays and nested loops instead of hash maps.

> That is not the case in C though, as it is much easier to use arrays and nested loops instead of hash maps. I am confused. There are plenty of open source, fast hash map impls in C.

Yes, the problem is getting them into your project.

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#202

Earlier quoted context omitted.

You should if you expect your readers to be normal humans who understand obvious context, and not pedantic HN readers who understand obvious context but delight in nit-picking it anyway.

>pedantic Who the fuck do you think is the intended audience for an article about an algorithm in `git bundle create`? I spent approximately two minutes of my life trying to figure out where the O(n^2) algorithm was being invoked in such a way that it influenced an exponential. Exponential was bolded in the same sentence as a big-O. 50/50 troll/author oversight.

Maybe not 'morepedantic

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#203

Earlier quoted context omitted.

I would say C makes this sort of thing far more likely because it's usually a ton of effort to obtain suitable containers. In C++ or Rust they have plenty of things like `unordered_set`/`HashSet` built in, so people are much more likely to use it and not go "eh, I'll use a for loop". In this case Git already had a string set, but it's still not standard so there's a good chance the original author just didn't know ab…

I've seen this exact problem in C code many times in my life, especially in kernel space where data structures and memory allocations are fun. Ironically, this is much _faster_ for small sets. Sometimes the error is intentional, because the programmer believes that all inputs will be small. IME, those programmers were wrong, but that's the inverse of survival bias.

And in fairness I can understand not considering someone might eventually be bundling a repository with tens of thousands of refs back in early 2009.

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#204
post #68
post #47

Earlier quoted context omitted.

You shouldn't use a word that can carry a precise mathematical meaning in a sentence that literally uses mathematical notation in order to speak precisely and then expect readers not to interpret the word in the precise mathematical way.

I somewhat agree, but for lack of a better word, what would you use? Quadratically doesn't have the same punch

Quadratically doesn't have the same punch because it is actually exponentially less than exponentially. So doing it for extra punch (as opposed to not knowing the correct word) in a technical context would just be lying. It'd be like a paper saying they had a result with p less than one in a trillion for "extra punch" when they actually had p=0.1.

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#205
post #134
post #6

"fixed it with an algorithmic change, reducing backup times exponentially" If the backup times were O(n^2), are they now O(n^2 / 2^n)? I would guess not.

The algorithm complexity went down in the function they patched (6x improvement in their benchmark), but in the context of how they benefited with how they were using the algorithm the impact was much larger (improved to taking 1% of the time), which is plausibly exponential (and figuring out the actual complexity is neither relevant nor an economic use of time).

> figuring out the actual complexity is neither relevant nor an economic use of time

The fix was replacing a nested loop with a map. Figuring out that this goes from O(n^2) to O(n) (modulo details like bucket count) is immediate if you know what the words mean and understand enough to identify the problem and make the fix in the first place.

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#206
post #62
post #6

"fixed it with an algorithmic change, reducing backup times exponentially" If the backup times were O(n^2), are they now O(n^2 / 2^n)? I would guess not.

If you replace an n^2 algorithm with a log(n) lookup you get an exponential speed up. Although a hashmap lookup is usually O(1), which is even faster.

They're still using the map in a loop, so it'd be nlogn for a tree-based map or n for a hash map.

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#207

IME, it has always turned out to be the correct decision to eliminate any n^2 operation in anything I’ve written. I don’t write exotic algorithms, but it’s always astounding how small n needs to be to become observably problematic.

Modern computers are pretty great at scanning small blocks of memory repeatedly, so n^2 can be faster than the alternative using a map in cases for small N. I spent a lot of time fixing n^2 in blink, but there were some fun surprises: https://source.chromium.org/chromium/chromium/src/+/main:thi... For large N without a cache :nth-child matching would be very slow doing n^2 scans of the siblings to compute the index.…

This is true. But unless you are sure that current and future inputs will always be small I find it is better to start with the algorithm that scales better. Then you can add a special case for small sizes if it turns up in a hot path.

This is because performance is typically less important for the fast/small case and it is generally acceptable for processing twice as much to be twice (or slightly more than twice) as slow, but users are far more likely to hit and really burned by n^2 algorithms in things you thought would almost always be small and you never tested large enough sizes in testing to notice.

I wrote more on this topic here https://kevincox.ca/2023/05/09/less-than-quadratic/

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#208
post #95

Cool discovery but the article could have been about 1/10 as long and still communicated effectively. At least they didn't post it as a video, so it was easy to skim to the important details.

Yes. I read the whole article thinking that this must have been generated by LLM, because at least the style remembers it.

Don't take my bullet points away from me

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#209
post #47

Earlier quoted context omitted.

You shouldn't use a word that can carry a precise mathematical meaning in a sentence that literally uses mathematical notation in order to speak precisely and then expect readers not to interpret the word in the precise mathematical way.

We simplify the big O notation in computer science. This is standard practice.

Just drop the constants, it doesn't matter /s

Production systems running and melting here...

Re: How we decreased GitLab repo backup times from 48 hours to 41 minutes

#210
post #95

Earlier quoted context omitted.

Yes. I read the whole article thinking that this must have been generated by LLM, because at least the style remembers it.

Don't take my bullet points away from me

They came for the em dashes, and I did not speak up. Then they came for the bullet points, and I did not speak up..
Post reply on HN