News for hackers. Stuff that matters.
Re:Debian Git Monorepo by G3rn0ti on Tuesday April 02, 2024 @05:58AM (#39903958)
I know it‘s an April‘s fool. But I don’t get this recent trend of people arguing in favor of a monorepo (at my work place, too). It’s a nightmare to handle and use. What gives?
Re:Debian Git Monorepo by Cu3PO42 on Tuesday April 02, 2024 @06:13AM (#39904041)
There are real, tangible benefits to monorepos. And real, tangible downsides, too. Like everything else, it's a tradeoff.

I'm sure people advocating for them have brought up some benefits. But in case they haven't, here's an example I recently encountered at work: for an application we are developing, we needed functionality X. We knew that we'd need X in other projects, too, so we made it a library. I published it to our internal package registry and referenced it in the project. So far, so good. Turns out, feature X wasn't as well understood as we thought it was and we are still changing things around all the time. That meant: * changing the library * cutting a new release and publishing it * updating dependencies in the project and using the new feature

Since this was happening much too often for what was often a one or two line change, I moved the library into the project repo and build it as part of the project pipeline. This removes so much friction around these changes, I find it makes a significant difference. Eventually, I'll move the library back into its own repository, but for now the monorepo is the right choice in my eyes.

Re:Debian Git Monorepo by Arch-TK on Tuesday April 02, 2024 @06:31AM (#39904156)
I don't think this is really advocacy for monorepo but rather advocacy against premature solidification of abstractions. Whenever I encounter a situation like this, the first step I take is to write the code without any API or interface boundaries to worry about. Then if I still feel it would be a good idea to separate it, I will separate it while keeping it in the source tree (this isn't really vendoring or monorepo, it's just abstraction into a module). Once this thing has survived a few rounds of revisions and you're ready to use it in another project, copy paste it first. Then once two projects have both had a chance to exercise the abstraction, then you factor it out into something totally separate

This process requires that you are able to work on rewrites and refactorings without having to beg. But it's truly the best way to get from an idea of a library to an actually well designed library.

In some situations it might be you already know what you want and can separate it out from the beginning, but if you are coming up with anything remotely novel, then you want to follow this process.

A monorepo will still contain libraries like these. It will also contain vendored code (although monorepos help reduce the amount of duplicate vendored bits of code). Making such changes will be easier in a monorepo once your abstraction starts to solidify. But the process you should go through should still be similar. The reason for not having two things depend on your wobbly abstraction too early is simply that it will inevitability lead to you prematurely solidifying uncertain abstractions.

Re:Debian Git Monorepo by bluGill on Tuesday April 02, 2024 @08:53AM (#39905176)
Most people arguing one way or the other are in such a small code base that they don't face the problems the argument is really about in the first place. If you only have a a million lines of code then by all means use a monorepo as you probably aren't facing the downsides that make people reach for a multi-repo solution anyway.
Re:Debian Git Monorepo by hk__2 on Tuesday April 02, 2024 @07:57AM (#39904726)
> for an application we are developing, we needed functionality X. We knew that we'd need X in other projects, too, so we made it a library

This is the mistake: you should make it a library when you do need the functionality, not when you "know" you "would need" it.

Re:Debian Git Monorepo by bluGill on Tuesday April 02, 2024 @09:11AM (#39905355)
I disagree. If you will really need it, then just make it a library. This is not 1960 when we were still figuring out software. You are not writing something new anymore, the problem has been solved enough time that you can look around and figure out what will really be needed in other projects and what will not. This is something your architects should be doing as getting it right is important and you will regret not doing so (when you have 10 different implementations of the same thing all slightly different)

Now I will agree that developers are often wrong. We often think something we write is important than it really is and so make it reusable when it never will be. We often think something won't be reused when it really would be. This is a hard problem, but that doesn't mean you should not think about it and work hard to get things right.

Re:Debian Git Monorepo by BlackFly on Tuesday April 02, 2024 @06:41AM (#39904226)
The real problems with monorepos are that most of the benefits vanish as the scale increases unless you invest into building more monorepo tooling.

In your particular case, if your library becomes too popular, your one or two line implementation detail changes ripple out and trigger rebuilds of too many downstreams, many of which will have flakey tests and fail your MR. If most users are not actually depending on that functionality, or if you simply are doing semver properly, then you could avoid rebuilding those dependencies. Eventually the builds take too much time and CI rejects the pipelines or you continuously bump the build timeout but wait longer and longer for your changes to go live. You can solve these problems, if you invest in more monorepo tooling.

Similarly, once you are too popular a library in a monorepo, you will never do any atomic breaking API changes since it would require updating too many downstreams. Instead you will fake version it: add a new API, migrate users to it in multiple commits, delete the old version. Some of these migrations run out of steam midway in the biggest phase: phase 2. This approach does have the benefit of forcing the upstream author to make the two versions of the API co-exist.

Of course I am talking about scales where real limits start to break down. When your codebase is larger than your ram, an index won't fit into RAM anymore and every code search requires disk or network I/O. Eventually your repository doesn't fit on disk anymore and you interact with it with a special IDE and only download things you start editing or perform sparse checkouts in the first place so discoverability is again a problem.

Edit: of course some problems crop up sooner than hard limits are reached, like the flakey test issue I mentioned as well as visibility and control of changes to actual maintainers.

Re:Debian Git Monorepo by xign on Tuesday April 02, 2024 @08:50AM (#39905146)
I think in a centralized environment (workplace), it could be argued that immediately triggering all the build failures and having good hygiene in cleaning them up is actually not a bad thing. It really depends on how that's set up.

And how is sparse checkout worse for discoverability? With multiple repos it's even harder to find what you want sometimes if you are talking about 100's of random repos that aren't organized well.

Re:Debian Git Monorepo by bluGill on Tuesday April 02, 2024 @08:58AM (#39905220)
> I think in a centralized environment (workplace), it could be argued that immediately triggering all the build failures and having good hygiene in cleaning them up is actually not a bad thing.

In abstract I agree. However when I'm trying to get my code working having test failures in code that isn't even related to the problem I'm working on is annoying and I can't switch tasks to work on this new failure when the current code isn't working either.

Re:Debian Git Monorepo by JackSlateur on Tuesday April 02, 2024 @10:30AM (#39906159)
How could broken code (or broken tests) be merged in master ? That is a rhetorical question, of course it happends, and of course this is the root issue you would be facing
Re:Debian Git Monorepo by bluGill on Tuesday April 02, 2024 @04:06PM (#39910296)
As you may be aware, 100% broken code cannot be merged. However code that works 99.99% of the time can be merged and then weeks later it fails once but you rebuild and it passes. There are a lot of different ways this can happen.
Re:Debian Git Monorepo by BlackFly on Wednesday April 03, 2024 @03:54AM (#39914683)
There are multiple ways that code gets merged into master and ends up broken.

First, the one where everyone does everything correctly: CI executions do not run serially because when too many people are producing a lot of code, you need them to run at the same time. So you have two merge requests which are done around the same time A and B, they each see a commit C before each other. Say merge request A deletes a function or class or whatever that merge request B uses. Of course merge request A deleted all uses of that function but could not delete the use by B since it was not seen. A + C passes all CI checks and merges. B + C passes all CI checks and merges. A + B + C won't compile since B is using a function deleted by A. If you are lucky, they touch the same files and B doesn't merge due to a merge conflict and the rebase picks it up, otherwise broken master.

Then you will typically have emergency commits to hotfix issues which might break other things.

Then you will have hidden runtime dependencies that won't trigger retests before merge due to being hidden, but every subsequent change to that repo will fail.

Then you will have certificates, dependencies on external systems that go away.

Re:Debian Git Monorepo by ghosty141 on Tuesday April 02, 2024 @09:02AM (#39905258)
> Similarly, once you are too popular a library in a monorepo, you will never do any atomic breaking API changes since it would require updating too many downstreams.

This happens no matter which repo type. Even worse if a project chooses to update after a while, its far more painful having to do the changes after losing the context you had when you did the original changes.

If you want a monorepo, libraries being on the same version is a feature, and it keeps you from diverging.

Re:Debian Git Monorepo by BlackFly on Wednesday April 03, 2024 @03:46AM (#39914634)
This doesn't happen in a poly repo because you can just do it. You release version 2.0.0 of something and downstreams update at their own pace. Diverging as you call it.

But this isn't a problem. If 1.0.0 is a finished product then why do you ever need to move to 2.0.0 if you don't need the new features?

The issue in the monorepo is that if you are too popular the change must happen all at once or with copying (fake versioning, like people who version excel files by suffixing with dates), which places pressure on maintainers to not fix design mistakes.

It isn't a feature of the monorepo because you can still diverge by copying, forking or merely stopping support for the old library and this becomes more and more necessary at scale: you lose the feature you thought you wanted the monorepo for.

Re:Debian Git Monorepo by ghosty141 on Wednesday April 10, 2024 @07:06AM (#39989338)
> But this isn't a problem. If 1.0.0 is a finished product then why do you ever need to move to 2.0.0 if you don't need the new features?

Fair point, I assume (from personal experience at the places I've worked at) that updating the library is inevitable and doing so at a later date tends to be more painful than doing these migrations all at one.

> It isn't a feature of the monorepo because you can still diverge by copying, forking or merely stopping support for the old library and this becomes more and more necessary at scale

This is a problem if all the projects in the monorepo are not actually related. But imagine if all these subprojects are bundled as one OS image, in that case it is very rare that you want multiple library version.

At very large scale I can see your point, I don't have experience there so I can't really argue.

Re:Debian Git Monorepo by hobofan on Tuesday April 02, 2024 @09:25AM (#39905497)
Things become difficult at scale regardless of mono- or multirepo. You also have to build dedicated tooling if you heavily lean into splitting things into a lot of repositories, in order to align and propagate changes throughout them.
Re:Debian Git Monorepo by BlackFly on Wednesday April 03, 2024 @04:07AM (#39914741)
Sure, but polyrepos don't break with scale in the same way as monorepos. You only need additional tooling when you are trying to coordinate homogeneity a scale larger than your manual capability. Autonomous services don't typically do that kind of coupling without cohesion that people naturally find necessary in a monorepo and you can build cooperative and coexisting products without that kind of coupling.

When I read the white papers by google or uber on their monorepos, when I see what my company is building, it is just a custom VCS. Everything that was thrown away initially gets rebuilt over time. A way to identify subprojects/subrepositories. A way to check out or index a limited number of subprojects/subrepositories. A way to define ownership over that subproject/subrepository. A way for that subproject/subrepository to define its own CI. A way to only build and deploy a subproject/subrepository. Custom build systems. Custom IDEs.

The entirety of code on the planet is a polyrepo and we don't have problems dealing with that scale like we would have if we stuffed it all in one repo like this debian monorepo shows. Independence of lifecycle is important, and as a monorepo scales up people rediscover that importance bit by bit.

Re:Debian Git Monorepo by Archelaos on Tuesday April 02, 2024 @06:24AM (#39904107)
> Turns out, feature X wasn't as well understood as we thought it was and we are still changing things around all the time.

If you publish something as a library for someone else, you should generally commit to supporting the public interface of that library as if it were a long-term support release. Exactly how long that should be depends on many factors, of course. But as a rule of thumb, I would recommend supporting this library version for at least two years. If that doesn't make sense, don't release it or look for a subset, where it makes sense.

Re:Debian Git Monorepo by The_Colonel on Tuesday April 02, 2024 @06:36AM (#39904190)
This is exactly the friction/overhead the other person means and what monorepo works around.

(but also keep in mind this is an internal library for likely a couple of internal apps, supporting BC for 2 years is in most cases unwarranted)

Re:Debian Git Monorepo by Repulsion9513 on Tuesday April 02, 2024 @06:39AM (#39904211)
Monorepo doesn't "work around" it, it means you have to support everything (including migrating/BC) on the current version, instead of having to support old stuff on the old version.
Re:Debian Git Monorepo by sjducb on Tuesday April 02, 2024 @07:18AM (#39904442)
You can see where the “library” is used. Often the bit you want to change is only used by your project so you can change it freely. If someone else is using it you know who to talk to about changing it.
Re:Debian Git Monorepo by actionfromafar on Tuesday April 02, 2024 @06:48AM (#39904281)
You can “fork” inside the monorepo too, just take a copy.
Re:Debian Git Monorepo by surajrmal on Tuesday April 02, 2024 @06:43AM (#39904246)
This guidance is far too specific to make sense in the general case. Not every scenario has the same constraints. If I had to pay a 2 year maintenance cost for every library I write and wanted to reuse between projects I'd never end up writing it. If you can migrate all library clients over to the new version, there is no reason to maintain old versions.
Re:Debian Git Monorepo by Archelaos on Tuesday April 02, 2024 @06:53AM (#39904317)
I would not call this a "library", but a set of interrelated project with "shared moduls" instead. With a "library" I mean a piece of code where the publisher does know who is using it for what exact purpose. Of couse we could now fight over a proper general definition for "library", but this is how I would use the term in this context, because thee long term aspect is what really makes outsourcing such code meaningful -- in contrast to the parents observation that it does not make sense to incorporate foreign code that constantly changes.
Re:Debian Git Monorepo by mewpmewp2 on Tuesday April 02, 2024 @08:08AM (#39904821)
The argument then is also that monorepo allows you to use this as "shared modules" instead of published "libraries".

The point is you have some code that you want to reuse, and either within a monorepo or between multiple repositories.

Re:Debian Git Monorepo by Archelaos on Tuesday April 02, 2024 @09:35AM (#39905597)
The question is, when it is wise to do so. Changing the public interface of a "shared module" or published "library" comes with a liability. Code reuse is almost a no brainer in the case of a standard library that rarely or never changes. Using a permanently changing modul whose modifications provide no real benefits for your project makes no economic sense. The sweetspot is somewhere in between.

What the parent actually did when copying the library/module code was creating a sort of a a long-term support version for himself maintained by himself. His cost-benefit analysis told him that this is better than always trying to keep up with the changes of the library/modul.

My comment was aimed at setting the bar rather high for when to share reusable libraries. And even for my own modules I rather prefer copying code instead of reusing it in different contexts. There is a reason why the contexts differ and it is typically easier and more economic to adress this differences in its particular place instead of preparing for them in shared code.

The more up-stream a library/module is, the more general it must be, but the less liable to change it should be.

Re:Debian Git Monorepo by mewpmewp2 on Wednesday April 03, 2024 @08:41AM (#39916690)
With monorepo he wouldn't have had to worry about this decision, since the decision to go back and forth would have been much lower cost. It's low cost decision either way and low cost impact if you make a wrong decision.
Re:Debian Git Monorepo by ownagefool on Tuesday April 02, 2024 @06:45AM (#39904259)
It depends.

If you drop a library for internal usage only and you want to change the contract, and the tests, library, and api are all in the same repo, you just change them in a single PR and that's done. This works because the single commit hash contains all information. It requires people put their code in the monorepo and hookup their tests, but assuming they do, you can build a reasonable degree of confidence on a green build.

Once you separate the library different repo, and let people consume that as something in their own repos, you need to do the versioning dance as you have no idea if their still is still working.

A lot of people go for the latter because it contextually allows them to ignore the rest of the stack, and there are some pros to doing this, but testing, deploying, versioning, etc, all become more difficult, and that's something struggle with.

Thus, unless you have a crap load of code / commits, monorepos arguably have more advantages than disadvantages.

Re:Debian Git Monorepo by bluGill on Tuesday April 02, 2024 @09:16AM (#39905400)
If the same problem doesn't exist in a monorepo in a different form then your project is not large enough to be in this discussion in the first place.
Re:Debian Git Monorepo by ownagefool on Tuesday April 02, 2024 @10:36AM (#39906214)
It's actually just trade offs that we should be able to have professional discussions about, otherwise your advocating for "always use a monorepo" unless your library is for public consumption.

The reality is, at some point, having repos that are hundreds of GB with hundreds of active PRs also has its own downsides that requires tooling and workflows to combat. Meanwhile, splitting it all up introduces integration problems.

It's definitely pick your poison, though specific requirements and circumstances make specific paths more or less potent.

Re:Debian Git Monorepo by bluGill on Tuesday April 02, 2024 @11:38AM (#39906989)
The problem is many people arguing for a mono repo feel like the size of their project means breaking into multiple repos mean put each function in a separate repository - which is obviously absurd. It is good if your project is that small, but you also are not facing the same pains as large projects are.
Re:Debian Git Monorepo by Cu3PO42 on Tuesday April 02, 2024 @07:04AM (#39904379)
This isn't wrong, but somewhat orthogonal. Yes, I "published" it on our package registry, but it wasn't public. Access was still scoped to the team developing the application I was speaking about.
Re:Debian Git Monorepo by actionfromafar on Tuesday April 02, 2024 @06:46AM (#39904271)
This is orthogonal to mono-repo vs not mono-repo and indeed distribution mechanism.
Re:Debian Git Monorepo by JackSlateur on Tuesday April 02, 2024 @10:33AM (#39906190)
This is exactly why monorepo is advised : you do not need to keep and maintain useless code for years. Instead, you can "git grep", then write and submit MR to quickly change all users.

I have never encounter this use case, tho

Re:Debian Git Monorepo by efxhoy on Tuesday April 02, 2024 @06:38AM (#39904206)
I find this too at work all the time. People are very quick to branch off some “independent” feature into its own service or lib and repo. Great for them when building, tiny repos do have that greenfield clean slate feeling, but awful when you realize the integration points aren’t as simple and well understood as they first thought.
Re:Debian Git Monorepo by rrr_oh_man on Tuesday April 02, 2024 @06:27AM (#39904123)
> Since this was happening much too often for what was often a one or two line change

The famous 5 minute project.

Happens in coding, car repair, and interstellar travel.

Re:Debian Git Monorepo by Repulsion9513 on Tuesday April 02, 2024 @06:39AM (#39904213)
That's not a monorepo.
Re:Debian Git Monorepo by wongarsu on Tuesday April 02, 2024 @09:12AM (#39905356)
Obviously that depends on your language's tooling and your company's processes, but directly depending on (a specific branch or commit of) a git repository rather than a release is a great in-between solution that allows you to have separate repositories while still allowing fast iteration.

Obviously you want to switch back to a release model once the feature stabilizes, to have all the advantages your internal package registry brings you.

Re:Debian Git Monorepo by paulgdp on Tuesday April 02, 2024 @06:04AM (#39903983)
NixOS uses a monorepo and I think everyone loves it.

I love being able to easily grep through all the packages source code, and there's regularly PRs that harmonizes conventions across many packages.

Nixpkgs doesn't include the packaged software source code, so it's a lot more practical than what Debian is doing.

Creating a whole distribution often requires changes synchronized across many packages, so it really makes things simpler.

https://github.com/NixOS/nixpkgs

I think it's important to add that they both have the biggest number of packaged software and the most up-to-date software of all distributions even though they have far fewer maintainers than Debian.

https://repology.org/repositories/graphs

Re:Debian Git Monorepo by viraptor on Tuesday April 02, 2024 @08:15AM (#39904864)
Is nixpkgs really a monorepo as usually discussed? It's got packages, os modules, and some supporting scripts. Nix itself lives in a different place, so does the RFC planning, system artwork and a few other things. I would expect it all together to become a monorepo.

> even though they have far fewer maintainers than Debian.

Debian has ~1.5k contributors, nixpkgs lists >3.5k maintainers. (Although that list is not pruned over time)

Re:Debian Git Monorepo by paulgdp on Tuesday April 02, 2024 @10:48AM (#39906352)
> Is nixpkgs really a monorepo as usually discussed? It's got packages, os modules, and some supporting scripts. Nix itself lives in a different place, so does the RFC planning, system artwork and a few other things. I would expect it all together to become a monorepo.

I think we can say it's a monorepo of packages in this context. Not everything from the Nix ecosystem is there. It could also bundle the website, wiki, doc etc but I don't think it matter too much.

> Debian has ~1.5k contributors, nixpkgs lists >3.5k maintainers. (Although that list is not pruned over time)

Thanks for the info, I heard that a long time ago and never checked myself! It's probably less as you say but still probably bigger than Debian.

I guess it makes sense because it's so much easier to contribute there than to Debian.

Re:Debian Git Monorepo by thegeekpirate on Tuesday April 02, 2024 @07:24AM (#39904499)
> I think it's important to add that they both have the biggest number of packaged software and the most up-to-date software of all distributions even though they have far fewer maintainers than Debian.

Only because of https://www.reddit.com/r/NixOS/comments/zp95a2/comment/j5ko9...

I also had plenty of issues with either packages not being available or not building, last I tried. At least with the AUR, it's generally only the latter you have to worry about ;)

Re:Debian Git Monorepo by paulgdp on Tuesday April 02, 2024 @10:53AM (#39906411)
Yeah, automation in Nixpkgs is crazy and goes far beyond any other distros (that I know of).

Why spend manual time when it can be automated?

Re:Debian Git Monorepo by bjornsing on Tuesday April 02, 2024 @06:39AM (#39904218)
> Nixpkgs doesn't include the packaged software source code, so it's a lot more practical than what Debian is doing.

This is the key difference. OpenWRT is a “monorepo” too, but it downloads tar balls etc of the upstream software. Makes sense.

Putting the source code of the upstream software in a monorepo sounds like a nightmare…

Re:Debian Git Monorepo by jiripospisil on Tuesday April 02, 2024 @06:09AM (#39904015)
Having to switch branches in different repos to feature-xyz, remember to build it, and then finally work/test is more of a nightmare to me. In a monorepo, you just switch to the branch once, the build system builds everything that needs building, and you are ready to go.
Re:Debian Git Monorepo by Xeamek on Tuesday April 02, 2024 @06:58AM (#39904343)
> It’s a nightmare to handle and use.

Why? If all Your work and knowledge is confined in one repo, there still is a way to work only on that part. Or at least there should be.

But if You want/need to have access to other parts, it's much easier to use monorepo then to search trough 100 of github repos that are somehow dependent but it's not obvious in what way.

Re:Debian Git Monorepo by ithkuil on Tuesday April 02, 2024 @06:26AM (#39904118)
The opensource tooling to handle large monorepos is just not there.

The monorepo at Google with the massively distributed build system and all other tooling make it very effective to work with.

You cannot just take one part of that system and expect to magically reap the benefits.

The main benefit I see in practice is that you can immediately see which parts of the system are broken by your change immediately as you test your change (as opposed to waiting when integration happen later when dependencies between modules are bumped in a multi-repo)

Re:Debian Git Monorepo by necrobrit on Tuesday April 02, 2024 @08:05AM (#39904799)
>You cannot just take one part of that system and expect to magically reap the benefits.

Yeah, specifically people only focus on the "repo" bit. Build system, PRs, history browsing, etc all get handwaved away after you stick all the code in a single repo. These are the extra hard parts though!

I think if you were to properly implement "monorepos" in git world it would actually look a lot like a Github _organisation_, rather than a Github repository. Each git "repo" in the "org" would be a workspace with it's own segregated UI so that you can for example check out just that workspace, or see only that workspaces commits or issues -- but some features such as github actions workflow triggers and PRs would be able to span multiple workspaces.

Github doesn't really seem to have put much thought into really supporting monorepos though. They have added some support (e.g. codeowners) to support "repo"-as-monorepo, but have also added some features that could go towards supporting "org"-as-monorepo (e.g. dependabot dependency updates and the dependency graph). But it all stops well short of a complete monorepo toolset.

Re:Debian Git Monorepo by IshKebab on Tuesday April 02, 2024 @07:55AM (#39904713)
I agree it's definitely an underserved tooling area. But so is a maze of submodules which is the realistic alternative. Open source just doesn't care too much about whole-company level projects because those don't really exist in the open source world.

That said, you can definitely make it work with Git & Bazel. Beats submodules by a mile.

Re:Debian Git Monorepo by ithkuil on Tuesday April 02, 2024 @09:32AM (#39905569)
Oh yes.

Also another thing: often people end up with the worst of both worlds: one (or two!) big monorepos plus a swarm of many little repos. Now you only pay the price of the monorepo but rarely ever notice the benefits

Re:Debian Git Monorepo by gtirloni on Tuesday April 02, 2024 @07:36AM (#39904560)
> It’s a nightmare to handle and use

Quite the opposite, IMHO. Juggling dozens of PRs across many repos for a simple change is the definition of a nightmare.

Re:Debian Git Monorepo by sethammons on Tuesday April 02, 2024 @08:57AM (#39905210)
that tells me you prematurely split something. I worked at a high scale, high available system with multiple dozens of teams, each with several repos. If we had to sync changes across repos, we joined the repos because they were, well, joined. In the early days, we had shared libraries and keeping those in sync was a pita. Then we realized we should not be doing what we were doing.

The flow should be: (1) update a library and release it, preferring backwards compatible changes or a new major version; (2) code that wants/needs the new functionality updates the usage at its leisure. If you are having to keep multiple repos "in sync" with each other, yes, you picked the wrong abstraction. If the downstream repo(s) need to always be on the latest and greatest version of the library, the library code should be vendored with the calling code.

Re:Debian Git Monorepo by gtirloni on Tuesday April 02, 2024 @09:24AM (#39905483)
> (2) code that wants/needs the new functionality updates the usage at its leisure.

That's how you end up with infinite support costs in a large org. I think the point is that these changes are done atomically.

Re:Debian Git Monorepo by sethammons on Tuesday April 02, 2024 @09:29AM (#39905535)
that is the theory. The reality is that your team can work on fixing an issue now, but the consuming team might be able to get to it next quarter due to competing priorities. Getting multiple teams to agree to work together at the same time is much, much harder than allowing teams to update on their own schedule. You do eventually have to press the organization and deprecate the older thing.

The alternative is you do the work for them - which you may or may not have the expertise for, and the other team may not even have time for the needed code review.

Re:Debian Git Monorepo by erik_seaberg on Tuesday April 02, 2024 @10:41PM (#39913094)
You can't deploy a distributed system atomically, and the closer you get the more risk you're taking with prod. The old and new versions need to coexist for at least a couple of weeks in case of rollbacks.
Re:Debian Git Monorepo by radicality on Tuesday April 02, 2024 @11:31AM (#39906889)
Agreed. For the last three years I’ve been working at a company with literal thousands of repos, and it’s an actual nightmare compared to a well maintained monorepo (eg Facebook/Meta). Sometimes updating some library code means I do 50+ PRs across random repos.
Re:Debian Git Monorepo by layer8 on Tuesday April 02, 2024 @04:47PM (#39910703)
You’re comparing two extremes, and your last sentence just indicates that the modules don’t seem to be properly divided along stable abstraction boundaries.
Re:Debian Git Monorepo by dijit on Tuesday April 02, 2024 @06:09AM (#39904008)
it requires a lot of discipline for sure.

"It depends" is thrown around a lot; what I've seen working for large companies and on large projects (mostly AAA games, which do use a monorepo typically) is that having a single repo means your dependencies are more likely to be vendored, and updating the vendoring re-runs all tests across all services because dependencies are mapped across the whole project.

Incremental build is also something that becomes more possible, rather than constantly building all source from scratch as we tend to do for smaller projects.

There's a lot to be said for atomic commits, no "merge trains"[0] and things like a "common library" (that everyone ends up building in a large enough team) are just includes and not entire dependencies with all that entails (versioning, updating dependencies etc;).

Having everything in one place also tends to force people to put documentation near their code instead of something else like confluence.

It's pros and cons, and the pro's are kind of meek-sounding until you've experienced it.

[0]: https://docs.gitlab.com/ee/ci/pipelines/merge_trains.html

Re:Debian Git Monorepo by Muromec on Tuesday April 02, 2024 @06:09AM (#39904007)
Linux kernel is a monorepo and somehow works. On the other side of the spectrum we have leftpad nonsense and latest xz thing.
Re:Debian Git Monorepo by andyferris on Tuesday April 02, 2024 @06:04AM (#39903985)
It probably depends on your project size, but I am one of those that find them easier to handle.

What do you find nightmarish?

Re:Debian Git Monorepo by surajrmal on Tuesday April 02, 2024 @06:51AM (#39904295)
I struggle to understand the upside of avoiding monorepos. A lot of people think it means you can't decouple releases, modularize builds and similar with a monorepo, but that's simply not true. The efficiency at which you can refactor and upgrade your codebase cannot be understated.
Re:Debian Git Monorepo by IshKebab on Tuesday April 02, 2024 @08:00AM (#39904755)
The main upsides I see are:

* you can pretend you don't need a proper sandboxing build system like Bazel, Buck etc. and stick to Make/CMake etc.

* you don't need to learn how to use sparse checkouts

It basically lets you avoid learning how to solve the problems you'll inevitably run into for a little while. Not a great reason, but it is a reason.

Re:Debian Git Monorepo by sethammons on Tuesday April 02, 2024 @09:00AM (#39905231)
every monorepo I've seen suffers from a shit CI solution. Other teams break your builds. Builds get longer and more complex. Feedback loops slow down. Engineering velocity slows down. It works at Google because they spent, literally, hundreds of millions of dollars getting it working.
Re:Debian Git Monorepo by knallfrosch on Tuesday April 02, 2024 @10:26AM (#39906111)
It's not even clear whether a monorepo stretches across teams or not. I think many people are argueing about different things.
Re:Debian Git Monorepo by baq on Tuesday April 02, 2024 @06:06AM (#39903994)
a hundred small repos are a different kind of nightmare.

the truth is, having a large code base is just hard no matter which way you handle it. you'll end up with custom repo tooling for the monorepo or blown up CI/CD infrastructure for many small repos either way. complexity will be conserved; it can be transferred, but can't be removed.

Re:Debian Git Monorepo by fragmede on Tuesday April 02, 2024 @06:33AM (#39904169)
baq's law of code thermo dynamics: complexity cannot be removed. it can be transferred but can not be removed. your CI/CD system will be as complicated as your repo structure isn't.
Re:Debian Git Monorepo by actionfromafar on Tuesday April 02, 2024 @06:51AM (#39904299)
Saving
Re:Debian Git Monorepo by pheatherlite on Tuesday April 02, 2024 @06:16AM (#39904068)
Most developers jump on the hype train and don't stop to think about ramifications or requirements or purpose. Having said that, monorepos have their use cases, and they help eliminate the need to have convoluted tool chains whose entire purpose is to ensure version compatibility between various components of the system... before you can even start making a line of change on the dev machine.. or some asinine docker abstraction that you must spin up... essentially, if everything is in one place (and not conceived by antisocial pranksters), you bet it's meant to be together. This makes it easier for any number of different life cycle teams to pick up a project and not waste time chasing down silly time wasting issues.
Re:Debian Git Monorepo by frizlab on Tuesday April 02, 2024 @06:00AM (#39903966)
Glad to see I’m not the only one thinking that.
Re:Debian Git Monorepo by Double_a_92 on Tuesday April 02, 2024 @07:32AM (#39904543)
It's much nicer to have everything you could ever need in one place, instead of having to know what is in what repo. Especially when you have versions that need to correspond in the different repos...
Re:Debian Git Monorepo by jillesvangurp on Tuesday April 02, 2024 @08:41AM (#39905072)
Having lots of small repos also generates overhead they need to be checked out separately, tagged individually, built individually, etc.

The reason that this is a bad April first joke is that the idea actually has merit. Google runs their company like this. The unthinkable bit is not doing this technically but Debian rearchitecting the way it works. Doing this with Git is a separate topic. It's probably not great for this. But mono repos at this scale are not impossible.

Re:Debian Git Monorepo by SOLAR_FIELDS on Tuesday April 02, 2024 @09:00AM (#39905233)
There was an article by some well known CTO that hits the nail on the head for me. Essentially they said that monorepo makes sense at small scale and enormous scale (eg Google) but anywhere in between that microservices make more sense. Knowing when you are going to be at those scales is key.

In any event, as has been alluded to in this thread already, any complaint about microservices vs monorepo and switching between them is almost always a tooling complaint. Companies will invest in one of these “philosophies” around code organization then won’t take the time to build the appropriate tooling to support them and then three years down the road some enterprising architect will switch from one to the other and the cycle begins anew

Re:Debian Git Monorepo by Shacklz on Tuesday April 02, 2024 @09:01AM (#39905248)
There have already been a lot of points by other commenters, one point that I'd like to add:

It allows to solve "problems of scale" with technical solutions rather than process solutions.

For example: Let's say there's application app-A and app-B, and they decide they want a library lib-1 that they can share.

If they are in separate repositories, this means multiple pull-requests, it means separate pipelines where the pipeline of lib-1 likely won't include the tests of the applications, it means there will be pull-requests to the library which won't immediately be integrated into the applications so that some poor sod has to take care of breaking changes down the road, etc.

If they are in a monorepo, each application can set up tests that need to be fine with the library-code "as is", so any change to the library needs to work against existing application-tests. The price one pays however are pipelines that perform well - nobody wants to wait hours to get pipeline-feedback and such. A monorepo also allows ambitious folks to shine - it's easy to touch many things at once, or to touch things used by everyone, on a pull-request with high visibility, which is an easy platform to get "street creds" as an ambitious engineer.

Re:Debian Git Monorepo by jmmv on Tuesday April 02, 2024 @09:15AM (#39905386)
It’s a nightmare only if you think of the monorepo as just throwing everything in one place (aka just a technical choice).

A monorepo requires org changes. It requires staffing teams to handle processes and tooling for everyone else. (And it may require something else than git… but git will work OK for reasonably large ones anyway.)

I wrote about some of this here: https://jmmv.dev/2023/08/costs-exposed-monorepo-multirepo.ht...

Re:Debian Git Monorepo by mhh__ on Tuesday April 02, 2024 @11:30AM (#39906867)
FWIW "Monorepo requires people to work on it" is organisationally a bit of a cop out because everything requires this kind of work, its just a difference between each team dedicating some time to it in there little bubble (in which they do things slightly differently) versus doing it once at a larger scale centrally - this requires some investment in the form of salary but you would still spend this money in the first place, you just don't notice.

Boiling frogs and all that.

You'd also be surprised just how little work this actually is if you get it right, versus having to fix 50 different hacked up solutions across your company. It does put strain onto some tooling, but these days git seems to be fine well beyond kernel-scale - when you are this size you have "made it" anyway.

Re:Debian Git Monorepo by knallfrosch on Tuesday April 02, 2024 @10:21AM (#39906059)
We have 4 interal-only projects that all kind-of depend on each other and are all rolled out at the same time:

backend, frontend and two shell wrappers for the frontend (electron for windows, cordova for ipad)

The total code base is still small enough for network/file system to not care (~10 devs working 10 years.)

Since we're on Azure Devops, we currently have to create a pull requests for every project. If you change the naming of an API variable, you'll have to create two pull requests. You'll have to review those individually. The automatically triggered test runs will fail against the respective "old" version of each other and create noise.

If, instead, we'd have a structure like this, the changes could be together: /src - backend (C#) - frontend (TypeScript) - ...

Note that we're not planning to have a "shared" library or "common" editorconfig files, or changing _anything_ about code internals. Just tracking the folders in git together.

Re:Debian Git Monorepo by mhh__ on Tuesday April 02, 2024 @11:27AM (#39906851)
All of the fastest moving, easiest to contribute to, projects I've seen use monorepos or at least understand the basic principle that things that are released together and ship together (and probably depend on eachother) should be developed together)

So many of the supposed problems with monorepos (other than those of pure scaling) seem to basically boil down to "Dr Dr it hurts when I do this"

For example:

"What happens if two teams depend on different versions of the same internal library" - sounds like a reasonable concern no? No! This situation is fundamentally a disaster. On many levels.