Live data from Hacker News

Ask HN: How are pull requests integrated in a repo with high commit frequency?

news.ycombinator.com

61–70 of 71 posts

Re: Ask HN: How are pull requests integrated in a repo with high commit frequency?

#61
post #54

Earlier quoted context omitted.

The developer whose task branch had merge conflicts was responsible for resolving the merge conflicts, and doing sidebars as needed where a discussion of the approach was warranted. They would resolve those conflicts in their branch before the PR was submitted. If the conflicts happened between submission and approval then the conflicts would still be resolved on the task branch before merge.

>The developer whose task branch had merge conflicts was responsible for resolving the merge conflicts But that's exactly my point. The first PR to merge cleanly will determine whether the next PR causes a merge conflict or not. At the time of merging, none of these PRs had a merge conflict. We often have 10 conflicts between PR admission and approval.

The key is to reduce the number of developers touching a specific section of code, and line up all tickets and hand them over to a single developer (or two).

And yeah, management won't do it. Fred Brooks wrote an entire book about this in 1975 that no one reads today and everyone would certainly ignore if they did read it. Because it tells you the unvarnished truth about the nature of communication and information flow within an organization. Such is the state of things in our industry. Sweet little lies.

Re: Ask HN: How are pull requests integrated in a repo with high commit frequency?

#62
If you want to be sure, you do run a regression test, yes.

> in those 5 minutes, 10 other commits have been made

If running tests take 5 minutes, that either means you have ten different developers working on your code, or people committing to the main branch without running tests.

Seems like you have too many developers working on the code for the size of the project and/or velocity of your approval process, or a spaghetti project (edit: or your tasks are too small)

Removing developers from the project may decrease the time spent on merge conflicts so much that it makes you move faster.

Re: Ask HN: How are pull requests integrated in a repo with high commit frequency?

#63
post #5

Check out something like Bors, which implements a paradigm that fixes this class of issue: https://github.com/bors-ng/bors-ng (Homepage: https://bors.tech/ )

We use bors as well. Our repo isn’t particularly active, a few dozen committers at any one time, but it lets us have pretty aggressive checks on master without having to run them separately for each PR before it lands.

Definitely recommended. We run ours on a Heroku instance it’s cheap and almost entirely maintenance free.

Re: Ask HN: How are pull requests integrated in a repo with high commit frequency?

#65
Do you really need to solve this problem?

You should definitely make sure that every PR is being tested against a merge commit to current main and not just tested against the code in the PR that may have forked off weeks ago. If the PR has been sitting you may need to recycle the tests to test against current main before merging.

This should take care of most problems, but doesn't guarantee 100% that main is never broken.

I'd argue that isn't likely to be possible, and you need gates in between main and whatever production is and that code needs to be retested before deployment actions happen.

When you do this you should then address how often main actually breaks and what the root cause (or what the accident chain is for people who deeply hate that term). If it is really breaking a lot due to races in different orthogonal commits touching the same sensitive locations (somehow without merge conflicts), I'd argue the correct course of action might be to refactor the code rather than the pipeline, and worrying about the pipeline is the last thing.

And your pipeline probably should break and hold up the tests from time to time, that probably costs less than designing a complex solution which tries to be perfect for the sake of being perfect.

Of course for the FAANG-scale readers it is probably worth it, but most devs aren't actually FAANG-scale, and there'll be some fuzzy line in the middle where it really starts to matter.

But if something breaks once in a blue moon that doesn't necessarily mean you should always fix it, as long as you can always contain the damage. So how often is this really happening that you think you need to fix it?

Re: Ask HN: How are pull requests integrated in a repo with high commit frequency?

#66
post #45

Earlier quoted context omitted.

It tries to build all queued changes together at first. So if you don't have any conflicts, there is no throughput limit.

What about if something in the middle causes a failure? Does it have a git-bisect-like workflow to figure out the bad change?

According to the README, it bisects. It doesn't matter much for me, though - the batches in our case were never big.

https://github.com/bors-ng/bors-ng/blob/master/README.md#how...

Re: Ask HN: How are pull requests integrated in a repo with high commit frequency?

#67
post #55

Our full acceptance test run in 3 hrs (on build servers with 64 cores and 3xx GB memory) and we have PRs coming up every hour or so. We run the acceptance tests for all PRs and also the main branch after each change. So a given PR needs to be 'green', and if we merge the PR then we run the tests on the integration branch too. If the integration branchs gets broken somehow, then all merges stop -- we don't merge any f…

1000 CPU for 30 developers sounds enormous. What kind of software are you working on?

Patient portal + electronic health records.

1000 CPU cores, not CPUs. :)

Re: Ask HN: How are pull requests integrated in a repo with high commit frequency?

#69
post #28
post #2

Sounds like you want to implement something like merge trains?[0] [0]: https://about.gitlab.com/blog/2020/01/30/all-aboard-merge-tr...

Another question I got on this. What do you do with merge conflicts between the branches? Do you then provide the system with patches for the merge conflicts somehow, so that it can resolve them as needed? E.g. when merging A, B and C. C might have no conflict with master or A but it has a conflict with B. Now for the queuing to work A -> B -> C it will have to know somehow how to patch C to fit on top of B. Maybe B…

We call ours the "stage". Merge conflicts are just a "please wait" signal. The way it works is:

  - the stage is always up-to-date with the target branch (so if it updates, we re-merge all topics on top of the new target branch head)
  - topics should pass CI standalone before being staged
  - the stage is first-come first-served, so "later" topics have to wait
  - updating a topic puts it at the end of the line
  - topics should really go through the stage before landing in the target branch
Conflicts (content or logical) will cause a topic to have to wait until the conflicting topic has landed in the target branch before it can participate in the stage. This usually only affects topics working in the same area.

Our library implementing this: https://gitlab.kitware.com/utils/rust-git-topic-stage

However, given your later metric of 10+ conflicts per topic…I suspect your project is still in the "getting off the ground" phase where a stage is awfully heavy process because there aren't "bright line" distinct sections of the code yet. Or your topics are too big. Hard to say.

Post reply on HN