News for hackers. Stuff that matters.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by frollo on Monday April 27, 2020 @06:29AM (#22994555)
After working on a monorepo and then the split up repos for the same codebase, I cannot fathom why somebody would want to take small repos and merge them in a single repo. The mess and complexity just increase.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by namelosw on Monday April 27, 2020 @09:40AM (#22995687)
It's about having boundaries that make sense. The best scenario is having multiple codebases, while when someone wants to change something, it can be done by just modifying code in one repo.

However, the worst scenario is also having multiple codebases, but when someone wants to change something, they end up having to go through many codebases and have to deal with all the environment setup, coordination, and possibly the worst of them all - the versions.

Monorepo is a straightforward way to avoid the best and worst scenario at the same time. So you'll give up the codebase splitting game and never worry about them, then focus on things that matter more.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by auxym on Monday April 27, 2020 @06:47AM (#22994652)
I worked in a company where a million line project was split in about 130 repos. Features or bug fixes frequently required syncing PRs between multiple repos. We needed scripts to create feature branches in all repos, or bump up the version everywhere.

4 or 5 repos would probably have been sane. 130 was hell to manage.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by bluGill on Monday April 27, 2020 @08:18AM (#22995094)
If that happens often you have the wrong repo split. This isn't a condemnation of the multi repo approach, only your architecture.

Note that this is about trade offs. If you have a monorepo this problem goes away but now you need to manage the problems of monorepos. If you have multiple repos you get this and other problems instead. Pick the right tradeoffs for your own needs. The only things wrong is claiming your answer is the right one for everyone else.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by auxym on Monday April 27, 2020 @09:09AM (#22995448)
> If that happens often you have the wrong repo split.

Yes, but: you pick out a nice, clean perfectly segregated architecture. Two years later, things have evolved, and a new feature that no one initially thought of is asked and involved refactoring 25 repos. Oops.

Side note: not my architecture. I only worked there for a short while. I have no skin in the game either way, I'm sure I agree with you that mono and multi- repos are the right solution for different problems.

Just trying to expose problems I've seen happen in a massive multirepo approach. Everyone thought it was the correct solution after being burned by a massive monolith that over two decades became an entangled mess. They thought they had the perfect architecture, the "correct repo split". In practice it's almost impossible, which is a major tradeoff to be considered.

Minimizin the number of repos and splitting only when absolutely necessary at least has a chance of reducing that complexity. The default should be "as few repos as possible", not "we're going multirepo, let us break this down into as many small parts as possible as our first step", which might be what the architects were used to in modular program architecture (small, reusable functions/classes).

Re:Monorepoize – Bash scripts for creating a monorepo out of... by vorpalhex on Monday April 27, 2020 @10:25AM (#22996094)
> The default should be "as few repos as possible"

In any corporate/enterprise-y environment with multiple teams, the default should be the smallest piece likely to change ownership.

When we see a pattern where a feature involves refactoring a bunch of repos, then your initial system breakdown was horrendously off-track and you lost sight of your domains. Been there, it is fixable but it takes a bit.

> Everyone thought it was the correct solution

There is no correct solution, there is the best solution for your problem set. Sometimes that's a monolith, and sometimes that's several small repos. Every once in a while, it's even a monorepo.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by throwaway894345 on Monday April 27, 2020 @11:14AM (#22996602)
Even with the best architecture, you probably have some shared libraries that are used across teams. These will often need to be updated, and they will affect several other packages (other repos, in the multirepo case). The only way to avoid this is to duplicate all code. Moreover, you can have a great architecture, but your teams are "feature-oriented" instead of service oriented (or some other vertically oriented team structure) in which case they'll need to touch many different repos (I don't imagine feature-oriented repos are a good idea) per ticket.

I'm increasingly convinced that the monorepo approach is the right one, but the tooling needs to get better. Bazel is a hydra of incidental complexity and Nix has the right core idea but suffers from a variety of other problems (poor documentation, gratuitously and unnecessarily unfamiliar, too few escape hatches, etc). These issues aren't fundamental to the domain, and there's no reason these tools couldn't change course nor is there a reason that another tool couldn't come in and eat their lunch.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by beagle3 on Monday April 27, 2020 @10:22AM (#22996066)
> you need to manage the problems of monorepos

If have not seen a problem on monorepos that does not exist on multirepos, other than more quickly reaching tools' repo size limits (but this is becoming less of a problem all the time on e.g. git and mercurial, and supposedly was never a problem with perforce).

I have seen many problems multirepos have that monorepos do not - such as that multirepos can (and almost always do) have a wrong split, and monorepos by definition cannot.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by yokaze on Monday April 27, 2020 @03:54PM (#22999317)
> If have not seen a problem on monorepos that does not exist on multirepo

How do you refer to a library in a monorepo from a different repo?

The workflow seems to me to entail an all-or-nothing approach.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by beagle3 on Monday April 27, 2020 @04:21PM (#22999582)
I never tried it, but if I needed it, I would easier use sparse submodule checkout (if it’s possible - I don’t know if that’s true), or submodule the entire repo, and the symbolic link into the internal part I need.

If all else fails (e.g. you need 50 files out of a 100GB repo, which makes things too slow), I would set up a git subtree extract as a checkin hook, which would mean there exists another repo/branch automatically updated on checkin - and which you could use any way you want, e.g, simple submodule.

Do note that’s just what I said: the problem, “I only need a small part of the repo” is independent of it being a monorepo or multirepo.

You would only avoid this problem in a multirepo if you cut it to pieces in exactly the right places. it’s just a matter of whether the parts of the repo you don’t need are too large to make this comfortable — more likely in a monorepo as it is larger - but will happen in a big enough multirepo as well.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by mumblemumble on Monday April 27, 2020 @09:20AM (#22995554)
I worked in a company that had at least 100 repos, often with interdependencies, and was managing it well using svn.

Then we migrated to Git, which doesn't have a good equivalent to svn's externals, and things kind of went to heck for a while. We eventually hacked together an in-house system that brought back some of what we were missing, but it never worked as smoothly as svn externals did.

I was originally one of the advocates of moving to Git. Hindsight being 20/20, after the dust settled I realized we would have been fine staying on svn, anyway. With such a high number of individual repositories, blocking on each other and nasty merge conflicts were rarely a problem in practice because we had over 100 swim lanes clearly marked in the pool. Lots more swim lanes than we had developers.

FWIW, one team dealt with it by migrating just their stuff to their own monorepo, and I wasn't too impressed by that outcome, either. They started seeing an outsize rate of technical debt accumulation as things that previously were easier to keep well modularized started naturally getting more tangled together. I realize that is a problem that can easily be managed with just a little effort. But, like every other dev problem that can easily be managed with just a little effort, it wasn't.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by pierrebai on Monday April 27, 2020 @10:21AM (#22996062)
git has submodules.

A repo can thus host any number of sub-repos. Using modules can also be pretty much like having a monorepo if you have a master repo with all others under it. This way, you can still publish things like public API as a repo.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by mceachen on Monday April 27, 2020 @10:52AM (#22996388)
Submodules don't allow for atomic commits that span repos, though. Atomic cross-project commits are the most compelling selling feature for monorepos IMHO.

(A common case for this is changing a function's API, and fixing all downstream consumers, in one tidy, holistic PR).

Re:Monorepoize – Bash scripts for creating a monorepo out of... by JoshTriplett on Monday April 27, 2020 @01:44PM (#22998062)
> Submodules don't allow for atomic commits that span repos, though.

They can, but there's little tooling support to help you do so.

You can make a new commit in one repo, and then in one atomic commit, you can pull that new commit into a parent repo's submodule and fix the users calling into that submodule.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by mumblemumble on Monday April 27, 2020 @10:52AM (#22996384)
They don't work quite the same way as svn externals, though, in a way that didn't work for us. In particular, they leave no good way to deal with merging in upstream changes in a submodule's code if you've also made some of your own (provisional) edits.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by leethargo on Monday April 27, 2020 @06:49AM (#22994662)
Often there are implicit dependencies between (versions of) the many repos. E.g. where I work, it was decided to put test data in a separate from the code (to keep the latter repo small in size). But now, when you add a new test case, it will fail on older versions of the code.

With a monorepo, you can always check out a consistent version of all parts.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by oconnor663 on Monday April 27, 2020 @10:17AM (#22996023)
And when your CI fails, it blames to a specific commit, rather than "the commit that triggered it, plus any commit in a dependency repo around the same time." And if you need to maintain old release branches, each one is a single branch, and your tooling doesn't need to know anything special about what branches of other repos to check out. And `git bisect` works.

All of these things are possible without a monorepo, by using higher-level tooling to manage the relationship between repos. It could be `git submodules`, or Repo, or whatever. But all of those things have their own downsides.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by pierrebai on Monday April 27, 2020 @10:26AM (#22996105)
git submodules tracks the version of the sub repos.

So if you organize that your releases are a master repo with all needed repos as sub-modules, your sub-repo version tracking is already done fr you.

All that while still allowing sub-repo to move forward faster than other repos. With a mono-repo, you can only allow some sub-system to go forward faster than others by making them live permanently in separate branches.

Basically, in monorepo you have to use branches to do what separate repo do normally for free.

(Then there is the issue that with a monorepo, any screw up screws everybody. You're all on the same boat, all the time.)

Re:Monorepoize – Bash scripts for creating a monorepo out of... by leethargo on Tuesday April 28, 2020 @01:18AM (#23003654)
Yeah, we have set up a "parent" repo with git submodules for all the individual repos. But it was an afterthought and our workflow has not really caught up to the new possibilities.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by alexbanks on Monday April 27, 2020 @01:11PM (#22997728)
I feel like the library needed is actually the opposite. Take a monorepo, do some code analysis, split into many repositories. Monorepos are fool's gold unless you can have a team whose sole job is managing monorepo complexity, and even then I might ask "Why waste a team on monorepos?"
Re:Monorepoize – Bash scripts for creating a monorepo out of... by danenania on Monday April 27, 2020 @01:38PM (#22998010)
The problem is that we have crammed many related but distinct concepts--versioning, package management, access control, issue tracking, project management, licensing, etc.--into a single envelope called the "repo".

Having a single top level version and commit-log for all an organization's code is a huge win. But that doesn't mean you necessarily want to manage those other more granular concerns at the top level too. With tooling that does a better job drawing these boundaries, we should be able to have the best of both worlds (instead of the worst, which is where we are with the currently dominant repo-management tools).

Re:Monorepoize – Bash scripts for creating a monorepo out of... by alexbanks on Monday April 27, 2020 @02:14PM (#22998371)
I don't really agree. Rather than stuffing all your code into one envelope and then building tooling to decipher it, why not build tooling that allows commit log and versioning information for an arbitrary amount of repositories? Why does code have to live side-by-side to manage metadata about it?
Re:Monorepoize – Bash scripts for creating a monorepo out of... by danenania on Monday April 27, 2020 @03:40PM (#22999187)
That works too. I think you could arrive at the ideal setup from either direction: a monorepo with appropriate boundaries or multi-repos with an “umbrella” versioning layer for all of them. The end result is more or less the same.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by alexbanks on Monday April 27, 2020 @04:51PM (#22999903)
I guess I think one of those scenarios comes with all of the benefits but very few of the drawbacks than the other. But you're right, you can skin a cat however you want.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by cryptonector on Monday April 27, 2020 @11:07AM (#22996524)
The biggest barrier to monorepos is size, which is a problem for `git log` and related (e.g., `git blame`). The Microsoft work on Git will make a lot of that trouble go away, but I suppose there will always be some issues to working with a huge monorepo.

Q: But what's the alternative? A: A repo forest, or a repo web.

Well, repo forests/webs have similar issues crop up anyways. You could say that whether a mega-codebase is spread over a mega-monorepo or a mega-repoforest doesn't change the fact that it's a mega-codebase -- big comes with problems no matter what.

And many enterprises can't help getting to have megacodebases. Operating systems (including distros in the Linux case) are huge. So are ecosystems for various popular programming languages. Enterprise apps easily add up to more in large enterprises.

So once you're dealing with mega-codebases... if you can find a mega-monorepo that works, that's probably where you want to be.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by xorcist on Monday April 27, 2020 @07:17AM (#22994763)
On the contrary, you should provide a (good) argument before splitting a project. One such argument might be that those parts, for example configuration code, is on such a difference cadence that it should have a different branch and release model. Or that some parts must be kept unreadable for most developers. Or that the project has simply grown too large.

A good rule of thumb can be how much larger your project is than the Linux kernel itself. The kernel seems to constantly get near the number of objects that git can confortably handle without any major speedbumps.

Until then, do not bother. Be prepared that splitting a project in multiple repos will always require some sort of external tooling as soon as tickets or pull request workflows span multiple repos.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by wst_ on Monday April 27, 2020 @10:13AM (#22995981)
Depends what are you working on. Kernel is nothing alike enterprise environment. If you have services in your architecture, deployed separately, that is perfect argument to split your repository.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by koonsolo on Monday April 27, 2020 @06:39AM (#22994600)
In git I fully agree, and I wonder which company successfully runs a monorepo in git.

For me, I prefer git submodules, which seem to have the benefit of both monorepo and separate repo's.

Re:Monorepoize – Bash scripts for creating a monorepo out of... by Kipters on Monday April 27, 2020 @06:50AM (#22994666)
> I wonder which company successfully runs a monorepo in git.

Microsoft

Re:Monorepoize – Bash scripts for creating a monorepo out of... by bdcravens on Monday April 27, 2020 @12:50PM (#22997541)
Worth noting that due to the size of the Windows repo, they ended up having to extend git significantly

https://devblogs.microsoft.com/bharry/scaling-git-and-some-b...

https://github.com/microsoft/VFSForGit

Re:Monorepoize – Bash scripts for creating a monorepo out of... by koonsolo on Monday April 27, 2020 @07:33AM (#22994836)
For which product is this? It can't be all of them right?
Re:Monorepoize – Bash scripts for creating a monorepo out of... by jedieaston on Monday April 27, 2020 @08:46AM (#22995278)
Windows is in one repo at Microsoft, I believe.

https://devblogs.microsoft.com/bharry/the-largest-git-repo-o...

Re:Monorepoize – Bash scripts for creating a monorepo out of... by vorpalhex on Monday April 27, 2020 @10:28AM (#22996122)
Yeah but they basically wrote their own wrapper around it, which is to say Microsoft has fallen into one of their usual patterns:

1. Picking a trendy tool

2. Mis-using trendy tool

3. Rewriting trendy tool so it's no longer trendy tool but something custom and not quite standards-compliant with it's own weird behaviors and bugs

4. Complain the standard is wrong

Re:Monorepoize – Bash scripts for creating a monorepo out of... by Kipters on Monday April 27, 2020 @01:44PM (#22998066)
They wrote a wrapper around it because git took so much time for every basic operations, even a `git status` would take minutes. But still it's not a fork, you can either use it or not without impacting anyone else using the repo. And they also made it available to everyone, as how good open source citizens should do.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by pjmlp on Monday April 27, 2020 @07:41AM (#22994879)
Microsoft does definitely use git, monorepo I am not so sure.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by wikibob on Monday April 27, 2020 @07:49AM (#22994915)
Re:Monorepoize – Bash scripts for creating a monorepo out of... by pjmlp on Monday April 27, 2020 @08:42AM (#22995251)
That doesn't say that everything related to Windows is developed on the same repo, just the kernel and several core components.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by foobarian on Monday April 27, 2020 @11:11AM (#22996572)
How did I miss this! Can you imagine someone claiming Windows is going to be in git as few as 10 years ago? This world never ceases to amaze me. What happened to SourceSafe?
Re:Monorepoize – Bash scripts for creating a monorepo out of... by oblio on Tuesday April 28, 2020 @09:36AM (#23006793)
SourceSafe was never used for anything internal major. They had their own custom source control system, based on Perforce, I believe, and then on TFS and then they switched to git.

SourceSafe was something inflicted on SMBs :-D

Re:Monorepoize – Bash scripts for creating a monorepo out of... by foobarian on Tuesday April 28, 2020 @10:55AM (#23007584)
Interesting, didn't realize that. I haven't worked there but knew some people who did, and they were very proud of dogfooding - I guess at least the OS and IDEs, though maybe not the VCS.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by Kipters on Monday April 27, 2020 @10:24AM (#22996090)
There have been many posts in their tech blogs about why they chose a monorepo
Re:Monorepoize – Bash scripts for creating a monorepo out of... by dangoor on Monday April 27, 2020 @09:07AM (#22995436)
Khan Academy has a monorepo in git. With 10 years of history in it, it's not always pleasant but does come with some advantages.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by bdcravens on Monday April 27, 2020 @12:47PM (#22997510)
I've been looking at that approach. We have a large "app" that has a lot of boundaries (parts even being in different languages), but everything is run (love being able to docker-compose up my entire stack) and deployed in unison. However, it does make for a messy single repo.
Re:Monorepoize – Bash scripts for creating a monorepo out of... by michaelmcmillan on Monday April 27, 2020 @08:11AM (#22995042)
> I wonder which company successfully runs a monorepo in git.

Google. They're not using git, but their own scm: https://research.google/pubs/pub45424/

Re:Monorepoize – Bash scripts for creating a monorepo out of... by bregma on Monday April 27, 2020 @12:41PM (#22997453)
I read somewhere on the internet that Google uses a monorepo. I want to be like Google, so I need to use a monorepo.