News for hackers. Stuff that matters.
Re:Why Google Stores Billions of Lines of Code in a Single R... by adamrt on Tuesday July 24, 2018 @09:13PM (#17606236)
We moved to a monorepo about 2 years ago and it has been nothing but success for us.

We have quite a few projects but only 4 major applications. Maybe it is that a few of our projects intertwine a bit so making spanning changes in separate repositories was a pain. Doing separate PRs, etc. Now changes are more atomic. Our entire infrastructure can be brought up in development with a single docker-compose file and all development apps are communicating with each other. I don't think we've had any issues that I can recall.

We are a reasonably small team though, so maybe that is part of it.

Re:Why Google Stores Billions of Lines of Code in a Single R... by Tloewald on Tuesday July 24, 2018 @11:12PM (#17606675)
My previous had a monorepo for the website and backend (but not the mobile apps) which was insane to work with (as a coder I had a dedicated 128 core box to work on, some engineers had more than one, less intense engineers shared one) and a substantial amount of my time was spent just finding code. I guess most engineers just end up working in some nook and so that searching code constantly becomes less of an issue (it never did for me) but the code / debug cycle was dreadful.

I should add that a huge amount was invested in tooling. We had an in-house IDE with debug tools that could step through serverside code. We had a highly optimized code search tool. We had modified a major version control system so it could handle our codebase. (Indeed we picked our version control system because we needed to fork it and the other major version control system was less amenable to our PRs.)

My current job we have a micro service architecture and lots of small, focused repos. Each repo is self-documented. Anyone can checkout and build anything. We don’t need obscene dev servers. We have not hugely invested in tools or workflow.

Client apps are unavoidably larger repos than the services apps.

Based on my personal experience, I think monorepos are nuts.

Re:Why Google Stores Billions of Lines of Code in a Single R... by ebikelaw on Wednesday July 25, 2018 @12:08AM (#17606840)
You seem to have conflated a bunch of different things and confused them with a monolithic repository. There's no reason why a monorepo requires you to have a gigantic development box ... you identify and compile only the transitive dependencies of your target, not every line of code in the repo.
Re:Why Google Stores Billions of Lines of Code in a Single R... by mcny on Wednesday July 25, 2018 @12:10AM (#17606849)
I recently saw a question on quora asking whether the free food at Google boosted productivity. The reply that seemed strange at thwt time was being able to focus on their job and not having to do a bunch of stuff is what boosted productivity at Google.

I get some perspective from the comments above. There is seemingly an army of engineers at Google that keeps the monorepo functioning. I was at a meeting about bazel and angular. I thought I'd ask how they do things at Google. To my surprise, the presenter said he is not at liberty to discuss how things work at Google. I guess it wasn't so surprising in hindsight. I mean what would I do with that information, right? It would be way too overkill for my tiny crud application.

Re:Why Google Stores Billions of Lines of Code in a Single R... by Too on Wednesday July 25, 2018 @03:39AM (#17607515)
How is this

   company
     /ProjectA
       /.git
     /ProjectB
       /.git
easier to browse than this?

   company
     /.git
     /ProjectA
     /ProjectB
You still need to find the project A repo if you don't use monorepos. And even if you do use monorepos everything doesn't have to be one monoloithic build hogging down your IDE, you can still have microservices with the code for each hosted in the same repo. You seem to conflate monorepo with lots of other things.
Re:Why Google Stores Billions of Lines of Code in a Single R... by flukus on Wednesday July 25, 2018 @04:47AM (#17607804)
In the former each project is a self contained unit and if I'm working on project B I can forget project A even exists, which is lovely caused I've got enough to deal with on B as is. Each project can be branched individually, the log of project B is not polluted with commits to project A, I can rebase and not get a bunch of commits I don't care about.

The later forces me to be aware of the entire universe in that repo.

Re:Why Google Stores Billions of Lines of Code in a Single R... by Too on Wednesday July 25, 2018 @07:03AM (#17608325)
In the later you can also forget project A exist. git log works in subdirectories out of the box and if you didn't touch any files in project A a rebase will be trivial without any merge conflicts. Branching is also free (unless you are still in the SVN stoneage that requires a copy of each file) so it doesn't matter if you branch the whole monorepo or just a single project.
Re:Why Google Stores Billions of Lines of Code in a Single R... by wcoenen on Wednesday July 25, 2018 @08:36AM (#17608749)
> unless you are still in the SVN stoneage that requires a copy of each file

Maybe you are thinking of CVS? In SVN, creating branches has always been cheap in both space and time.

Re:Why Google Stores Billions of Lines of Code in a Single R... by artursapek on Tuesday July 24, 2018 @11:39PM (#17606760)
We had this same experience with a large golang project, consisting of about 8 individual services. Switching to a monorepo made it incredibly easy to make changes to common code and inter-service communication. Huge breath of fresh air.
Re:Why Google Stores Billions of Lines of Code in a Single R... by hobls on Tuesday July 24, 2018 @10:37PM (#17606551)
A single team is really helpful. Where I’ve seen it get particularly unhelpful is with multiple teams. I’m also not opposed to the concept, I just think it requires work to do correctly.
Re:Why Google Stores Billions of Lines of Code in a Single R... by bedros on Tuesday July 24, 2018 @10:43PM (#17606568)
how do you create branches in mono repo?

for example I want to use branch rev5 from project A and rev3 from project B

how I do that in a mono repo, I could not do it in HG, but sure about GIT

Re:Why Google Stores Billions of Lines of Code in a Single R... by aidos on Wednesday July 25, 2018 @02:44AM (#17607305)
Depends on the system. When I used to manage SVN we would branch independent projects and then releases would be a snapshot of each into the server section of the repo. Those were then pulled down to their respective machines.

In SVN a branch is simply a convention. You copy (almost zero cost) things around into your branches directory

Re:Why Google Stores Billions of Lines of Code in a Single R... by tom_ on Wednesday July 25, 2018 @06:31AM (#17608205)
Branch rev5 of project A's folder into a folder in your project's folder, branch rev3 of project B's folder into a folder in your project's folder. Get your project to refer to its own copy, rather than the shared copies you branch from. (This isn't quite like git submodules, but that's probably the closest thing git has.)

You do the usual 3-way merge thing to push your changes upstream, or pull upstream changes into your copy. As with git, the VCS tracks which revision of upstream your copy is up to date with, which is how it determines the base for the 3-way merge.

Re:Why Google Stores Billions of Lines of Code in a Single R... by Tloewald on Tuesday July 24, 2018 @11:02PM (#17606641)
Can’t you create a branch and merge the two branches you are interested in into that?
Re:Why Google Stores Billions of Lines of Code in a Single R... by bedros on Wednesday July 25, 2018 @12:14AM (#17606869)
my understanding, if you branch, you branch the entire repo, (not sure about some special case extensions ) if you have two projects stored in a single repo, you are forced to use whatever rev at for each project at a point of branch rev 5543 for example
Re:Why Google Stores Billions of Lines of Code in a Single R... by ScottBurson on Wednesday July 25, 2018 @12:44AM (#17606953)
In Perforce, which is more or less what Google is using, you can branch any directory within the repo. (You would never branch the whole repo; that makes no sense.) So if you wanted to construct a directory with one version of one subdirectory, and a different version of another subdirectory, that's quite straightforward.
Re:Why Google Stores Billions of Lines of Code in a Single R... by ec109685 on Wednesday July 25, 2018 @01:32AM (#17607085)
Google branches google for releases. Otherwise, you would end up with version skew across dependencies, which would be a mess.
Re:Why Google Stores Billions of Lines of Code in a Single R... by Too on Wednesday July 25, 2018 @03:46AM (#17607547)
Yep, and if you want to keep folders you didn't branch up to date with master you have to continuously rebase.

Not having it this way would be equivalent to having subrepo that refers to HEAD instead of a specific commit which is normally considered an big anti-pattern.

The best remedy is to not do branching like this in the first place, just try to stay on trunk all the time.

Re:Why Google Stores Billions of Lines of Code in a Single R... by dgsb on Friday July 27, 2018 @08:42AM (#17625499)
Just curious how small is small ? How many kloc ? How many people ?