News for hackers. Stuff that matters.
Re:Why Google stores billions of lines of code in a single r... by nickm12 on Sunday December 10, 2017 @04:29AM (#15890660)
I've worked with both a distributed repo model and a monorepo model and vastly prefer the distributed approach (given the right tooling). The trade-offs are complementary and no doubt with proper discipline you can try to maximize the benefits, while minimizing the downside. But here's what I don't like about working in a large monorepo:

1) Difficult to track changes to the code I'm interested in. Every day there are hundreds of changes in the repo and almost all of them have nothing to do with what I'm working on.

2) all sorts of operations take longer (pulling, grepping source, etc.) to support code I couldn't care less about.

3) Frequently have to update the world at once. Unless the repo can store multiple versions of the same module, then all the consumers have to be updated at once, even if it's inconvenient. Sometimes migrations are better done gradually.

4) Encourages sloppy dependency management. There are frequently unclear boundaries between software layers.

I'm sure people will say "if you're having those problems, you're doing it wrong" but the same thing could be said to people who find the distributed model problematic.

Re:Why Google stores billions of lines of code in a single r... by vertex-four on Sunday December 10, 2017 @05:40AM (#15890831)
The trick is that Google have their own VCS, build tooling, automated refactoring tools, etc etc, specifically designed to deal with their monorepo. Nobody else has that - we're stuck with git and a complex landscape of tools for managing code in ad-hoc ways. As a result, with the tools we have, many repos is better than a monorepo - but perhaps if we had those tools, for some cases, a monorepo might be better than many repos.

Note that even where Google are forced to use git (e.g. Android, Chrome) they use a many-repo approach.

Re:Why Google stores billions of lines of code in a single r... by user5994461 on Sunday December 10, 2017 @07:01AM (#15891060)
Google has that, Facebook has that, Microsoft partially has that, some investment banks have that too.

Everywhere I've seen mono repo, mono repo was better than multi repo.

They all built special tooling and have dedicated teams to support it.

Re:Why Google stores billions of lines of code in a single r... by perfmode on Sunday December 10, 2017 @07:17AM (#15891097)
I wish someone would create an open-source vcs that supports mono-repos at scale out of the box.
Re:Why Google stores billions of lines of code in a single r... by albertzeyer on Sunday December 10, 2017 @07:40AM (#15891151)
Re:Why Google stores billions of lines of code in a single r... by supergreg on Sunday December 10, 2017 @01:32PM (#15892725)
Maybe we could look at the problem from the other side. Create tools to manage multi-repos like if they were a single mono-repo. A docke-compose for git.
Re:Why Google stores billions of lines of code in a single r... by monocasa on Sunday December 10, 2017 @09:44PM (#15894799)
It's sort of intrinsically a pain since then you lose atomic, cross project commits.
Re:Why Google stores billions of lines of code in a single r... by zeckalpha on Sunday December 10, 2017 @01:52PM (#15892836)
Re:Why Google stores billions of lines of code in a single r... by zifnab06 on Monday December 11, 2017 @11:56AM (#15898281)
Android does this with a tool named repo. It tires into gerrit and you can treat the whole Android project as one repo.
Re:Why Google stores billions of lines of code in a single r... by qznc on Sunday December 10, 2017 @12:51PM (#15892506)
Why is the problem with Subversion?
Re:Why Google stores billions of lines of code in a single r... by hennsen on Sunday December 10, 2017 @06:30PM (#15894098)
Are you proposing a subversion-based monorepo?
Re:Why Google stores billions of lines of code in a single r... by gmueckl on Monday December 11, 2017 @12:47AM (#15895368)
We get a lot of mileage out of Subversion as a monorepo. It certainly works better than people like to give it credit for.
Re:Why Google stores billions of lines of code in a single r... by vertex-four on Monday December 11, 2017 @06:47AM (#15896472)
Perforce Helix might be even better - it even has a DVCS model based on creating a "local server" that can fetch/push from a shared server asynchronously from use of that local server, and a hybrid model that allows for only parts of the repository to be hosted on your personal server, and other parts to follow the more traditional Subversion-like model. Things like exclusive locks on files that can't really be "merged" are also supported (for example, all your assets).

The only downside is that it's not open-source, and as a result has a much smaller community. It's free for up to 5 users, then "email us" for any more. But if a very flexible VCS model is something you need, it's the same as anything else you need to pay for.

Google used to use Perforce until they hit a certain scale, so it's likely it'll work for you until you hit that scale and can build your own tools too.

Re:Why Google stores billions of lines of code in a single r... by qznc on Monday December 11, 2017 @03:50AM (#15895883)
Well, it seems to fit the requirements better than git. Obviously, subversion is not used much. I would like to hear some experience reports what is the problem with it.
Re:Why Google stores billions of lines of code in a single r... by gmueckl on Monday December 11, 2017 @10:39AM (#15897668)
We have two issues with Subversion:

- it requires a certain discipline: we need branching in our workflow and this is handled mostly by convention in a subversion repository. We have "branches" that were created by less careful colleagues by copying subdirectories of trunk to the branches folder.

- all the tooling developers fled to work on making git bearable. It seems that there is good money in sugarcoating got and none in making good tools for Subversion (awareness of branches in Jenkins, decent code review...). We have a budget, but that does not compensate for the lead that git has in that regard.

Other than that, subversion fits our needs. It just works.

Re:Why Google stores billions of lines of code in a single r... by hennsen on Tuesday December 12, 2017 @09:51AM (#15905902)
Subversion is not used much anymore - just in case you entered the industry after this.

Subversion has been used in basically each and every open source project as a replacement for the previously most used CVS.

Subversion was better tjan cvs, but still bad in many aspects, slow synchronization and bad branching and merging support come to my mind.

Because of these shortcomings and because of the idea of decentralized versioning coming up, many systems like git, mercurial, and others came up then, and git seems to be the most successful of these by now

Re:Why Google stores billions of lines of code in a single r... by hennsen on Tuesday December 12, 2017 @09:52AM (#15905911)
That being said, not sure how and if subversion has improved by now, didn’t use it for years...
Re:Why Google stores billions of lines of code in a single r... by hello_there on Sunday December 10, 2017 @07:47AM (#15891170)
What special tooling is required to deal with a monorepo that is not required for multi repo?
Re:Why Google stores billions of lines of code in a single r... by user5994461 on Sunday December 10, 2017 @08:34AM (#15891299)
Must have: Tooling that can interact on a file or sub directory level. Git cannot do that.

Should have: Access control to view and change file on a subdirectory basis. Everyone can see the repo so you can't permissions users per repo anymore. It's optional but these companies have that.

Recommended: Global search tools, global refactoring tools, global linting that can identify file types automatically and apply sane rules, unit test checks and on commit checks available out of the box for everything and that run remotely quickly, etc...

It's regular tooling that every development company should have, but only big companies with mono repos have it.

It's not that the tooling is needed to deal with the mono repo, it's that the tools are great and you want them. But they can't be implemented in a multi repo setup.

Think of it. How could you have a global search tool in a multi repo setup? Most likely, you can't even identify what repo exists inside the company.

Makes me realize. If I ever go back to another tech company, the shit tooling is gonna make me cry.

Re:Why Google stores billions of lines of code in a single r... by bunderbunder on Sunday December 10, 2017 @10:35AM (#15891831)
IIRC, Bitbucket Enterprise has pretty decent global search. GitHub Enterprise doesn't seem to have much of any cross-repo tooling, which is one of my least favorite things about it.

Global refactoring seems a lot less necessary if you have clean separation among your processes. Maybe this is me coming from a more microservices perspective, but I'm inclined to say that needing to do a refactor that cuts across several different functional areas is a sign that things are becoming hopelessly snarled together.

Re:Why Google stores billions of lines of code in a single r... by malkia on Sunday December 10, 2017 @11:10AM (#15891995)
Google have dedicated (no more there) language, platform, library, etc. teams that can push really huge refactoring changelists - for example if they've noticed that code had plenty of: "if (someString == null || someString.empty())" - they would replace it with something simpler.

Or if they've found some bad pattern, would pull it too. I do remember when certain java hash map was replaced, and they replaced it across. It broke some tests (that were relying on specific orders, and that was wrong) - and people quickly jumped and fixed them.

This level of coordination is great. And it's nost just, let's do it today - things are prepared in advance, days, weeks, months and years if it had to. With careful rollout plans, getting everyone aware, helping anyone to get to their goal, etc.

It's also easy to establish code style guides, and remove the bikeshedding of tabs/spaces, camel braces or not, swtich/case statement styles, etc. Once a tool has been written to reformat (either IDE, or other means), and another to check style, some semantics - then people like it or not soon get on that style and keep going. There are more important things to discuss than it.

Re:Why Google stores billions of lines of code in a single r... by derefr on Sunday December 10, 2017 @01:54PM (#15892853)
The idea of global refactoring is mostly that you can decide to modify a private API, and in the process actually update all the consumers of that API, because they all live in the same repo as the component they're consuming. (This is also the argument of the BSD "base system" philosophy, vs. the Linux "distro" philosophy: with a base-system, you can do a kernel update that requires changes to system utilities, and update the relevant system utilities in the very same commit.)
Re:Why Google stores billions of lines of code in a single r... by xwvvvvwx on Sunday December 10, 2017 @03:26PM (#15893313)
Code search in bitbucket server is dismal. All punctuation characters are removed. This includes colons, full stops, braces and underscores. This makes it close to useless for searching source code.

Regarding global refactorings think new language features or library versions.

Re:Why Google stores billions of lines of code in a single r... by rbbitbucket on Monday December 11, 2017 @02:50PM (#15899769)
Bitbucket PM here. Thanks for the feedback!

Support for punctuation in search is something we knew wasn't ideal when we first added code search. As with all software, there were some technical constraints that made it hard to do.

We plan to have support for full stops and underscores in a future version and are exploring how to best handle more longer term. Our focus, based on feedback, is on "joining" punctuation character to better allow searching for tokens. Support for a full range of characters threatens to blow out index sizes, but if we get more feedback on specific use cases we're always happy to consider them.

Re:Why Google stores billions of lines of code in a single r... by mikepurvis on Sunday December 10, 2017 @04:28PM (#15893591)
That boggles the mind. Why wouldn't they just ship Hound or something else based on the Go regex search backend?
Re:Why Google stores billions of lines of code in a single r... by rbbitbucket on Monday December 11, 2017 @03:02PM (#15899900)
There's always a reason ;)

Being a self-hosted product we have to make tradeoffs for the thousands of people operating (scaling, upgrading, configuring, troubleshooting...) instances. In short, we try to keep the system architecture fairly simple using available technology and keeping the broad skillsets of admins in mind.

It was a somewhat difficult call to add ElasticSearch for it's broad search capability, but being used for other purposes helped justify it. Adding Hound or similar services that were considered would have added more to administrative complexity and wouldn't provide for a broader range of search needs.

We continue to iterate on search, making it better over time.

Re:Why Google stores billions of lines of code in a single r... by mikepurvis on Thursday December 14, 2017 @02:06PM (#15925678)
A fair point, but I will just say that Hound is _astonishingly_ low maintenance. I set it up at my current employer like two years ago and have logged into that VM maybe twice in the entire time. It just hums along and answers thousands of requests a week with zero fuss.
Re:Why Google stores billions of lines of code in a single r... by user5994461 on Sunday December 10, 2017 @10:56AM (#15891933)
You really need a good "search and replace", whether it's called a refactoring tool or something else.
Re:Why Google stores billions of lines of code in a single r... by lclarkmichalek on Sunday December 10, 2017 @09:10AM (#15891422)
> Must have: Tooling that can interact on a file or sub directory level. Git cannot do that.

I mean, when you get big, sure. But until you're big, git is fine. Working at fb, I don't use some crazy invocation to replace `hg log -- ./subdir`, I just do `hg log -- ./subdir`. Sparse checkouts are useful, but their necessity is based on your scale - the bigger you are, the more you need them. Most companies aren't big enough to need them.

> Should have: Access control to view and change file on a subdirectory basis. Everyone can see the repo so you can't permissions users per repo anymore. It's optional but these companies have that.

Depends on your culture (and regulatory requirements). I prefer companies where anyone can modify anyone's code.

> Recommended: Global search tools, global refactoring tools, global linting that can identify file types automatically and apply sane rules, unit test checks and on commit checks available out of the box for everything and that run remotely quickly, etc...

I'd bump this up to `should have`. The power of a monorepo is being able to modify a lib that is used by everyone in the company, and have all of the dependencies recursively tested. Global search is required, but until you're big, ripgrep will probably be fine (and after that you just dump it into elasticsearch).

Re:Why Google stores billions of lines of code in a single r... by Xorlev on Sunday December 10, 2017 @11:18AM (#15892036)
> Depends on your culture (and regulatory requirements). I prefer companies where anyone can modify anyone's code.

This is still true at Google, except for some very sensitive things. However, every directory is covered by an OWNERS file (specific or parent) that governs who needs to sign off on changes. If I’m an owner, I just need any one other engineer to review the code. If I’m not, I specifically need someone that owns the code. IMHO, this is extremely permissive and the bare minimum any engineering organization should have. No hot-rodding code in alone without giving someone the chance to veto.

>ripgrep, ElasticSearch

Having something understand syntax when indexing makes these tools feel blunt. SourceGraph is making a good run at this problem.

Re:Why Google stores billions of lines of code in a single r... by lclarkmichalek on Sunday December 10, 2017 @03:00PM (#15893202)
Eh, at least in FB, I see more unstructured querying.
Re:Why Google stores billions of lines of code in a single r... by user5994461 on Sunday December 10, 2017 @11:02AM (#15891964)
Elasticsearch is too dumb. You need to use a parser and build a syntax tree to have a good representation of the code base. That's what facebook and google do on their java code.

Agree that any small to medium company could have a mono repo without special tooling. Yet they don't.

There are companies that care about development and there is the rest of the world.

Re:Why Google stores billions of lines of code in a single r... by rpedela on Sunday December 10, 2017 @04:59PM (#15893709)
Github uses Elasticsearch [1]. I agree that ES is too dumb by default, however the analysis pipeline can be customized for searching source code.

1. https://www.elastic.co/use-cases/github

Re:Why Google stores billions of lines of code in a single r... by boyter on Sunday December 10, 2017 @02:49PM (#15893139)
Might I suggest using a tool designed for searching source code rather than dumping into elastic. Bitbucket, sourcegraph, github search or my own searchcodeserver.com

Unless designed to search source code most search tools will be lacking.

Re:Why Google stores billions of lines of code in a single r... by marssaxman on Monday December 11, 2017 @01:20PM (#15899017)
I had a bad time at Google and was glad to leave, but wow did I ever miss that culture of commitment to dev process improvement and investment in tooling. The next startup I joined was kind of a shocking letdown. It became clear pretty early on that nobody else there had ever seen anything like the systems at Google, couldn't imagine why they might be worth investing in, and therefore the level of engineering chaos we wasted so much time struggling with was going to be permanent.

The startup I'm working for now is roughly half ex-googlers, so it is a different story. Of course we can't afford Google level infrastructure, but there is at least a strong cultural value around internal tooling, and a belief that issues with repetitive or error-prone tasks are problems with systems, not the people trying to use them.

Re:Why Google stores billions of lines of code in a single r... by malkia on Sunday December 10, 2017 @11:03AM (#15891967)
Worked at google for 2-3 years, mainly java, under google3: my thoughts: Having things under single repo, and with a system like blaze (bazel), I can quickly link to other systems, or be prevented/warned that it's not good idea (system may be going deprecated, or just fresh new, and you need visibility permission (can be ignored locally)).

Build systems, release systems, integration tests, etc. - everything works easier - as you refer to things just by global path like names.

Blaze helps a lot - one language for linking protobufs, java, c++, python, etc., etc., etc.

Lately docs are going in it too, with renderers.

Best features I've seen: code search, let's you jump by clicking on all references. Let's you "debug" directly things running in servers. Let's you link specific versions, check history, changes, diffs.

GITHUB is very far away from this, for nothing else - but naturally by not even be possible to know how things are linked. Even if github.com/someone/somelibrary is used by github.com/someone-else/sometool, GITHUB would not know how things are connected - is it CMake, Makefiles, .sln, .vcxproj. It maybe able to guess, but that would be lies at the end... Not the case at google - you can browse things better than your IDE - as you can't even produce this information for your IDE (a process that goes every few others updates it, and uses huge Map Reduce to do that).

Then local client spaces - I can just create a dir, open a space there, and virtually everything is visible from it (whole monolithic depot) + my changes. There are also couple of other ways to do it (git-like include), but I haven't explored those.

What's missing? I dunno... I guess the whole overwhelming things that such a beast exist, and it's already tamed by thousands of SREs, SWEs, Managers, and just most awesome folks.

I certainly miss the feeling of it all, back to good ole p4, but the awesome company that I'm in also realized that single depot is the way to go (with perforce that is). We also do have git, but our main business is game development, so huge .tiff, model files, etc. files require it.

Also ReviewBoard and now swarm (p4 web interface and review system) is so far nice. Not as advanced as what google had internally for review (no, it's not gerrit, I still can't get around this thing), but at going there.

Another last point - monolithically incremental change list number would always be easier than random SHAxxx without order - you can build whole systems of feature toggles, experiments, build verifications, around it, like:

This feature is present if built with CL > 12345 or having cherrypicks from 12340 and CL 12300 - you may come up with ways to do this too with SHA - but imagine what your confiuration would look like. It's also easier to explain to non-eng people - just a version number.

Re:Why Google stores billions of lines of code in a single r... by mrep on Sunday December 10, 2017 @06:55PM (#15894221)
Sounds like an opportunity for Google cloud
Re:Why Google stores billions of lines of code in a single r... by marcosdumay on Sunday December 10, 2017 @09:00PM (#15894657)
Wouldn't it be better to just adjust the linter, refactoring etc to work on a multi-repo hierarchy? Most of them already mostly do.
Re:Why Google stores billions of lines of code in a single r... by brlewis on Sunday December 10, 2017 @03:02PM (#15893211)
What special tooling is required to deal with a monorepo that is not required for multi repo?

From my time at Google the first thing that came to mind was citc. But I couldn't remember if citc was publicly known, so I did an Internet search for "google citc". The first search result was this article.

"CitC supports code browsing and normal Unix tools with no need to clone or sync state locally."

Re:Why Google stores billions of lines of code in a single r... by robrenaud on Monday December 11, 2017 @01:23AM (#15895473)
Facebook is painfully non mono repo.
Re:Why Google stores billions of lines of code in a single r... by sah2ed on Monday December 11, 2017 @01:48AM (#15895551)
Dan Abramov's comment elsewhere in this thread says otherwise:

"I work at Facebook, and can confirm we keep all code in a monorepo".

https://news.ycombinator.com/item?id=15893184

Re:Why Google stores billions of lines of code in a single r... by robrenaud on Monday December 11, 2017 @04:23PM (#15900581)
Unless something drastic changed in the last year, I really doubt it. There is the fb frontend, the backend, the offline batch processing repo, and the instagram frontend repo. I think the phone apps have their own repos too? It was a giant mess, especially when you had to make changes that spanned repos, like introducing a new backend API and then depending on it, or changing logging formats.
Re:Why Google stores billions of lines of code in a single r... by fishywang on Monday December 11, 2017 @04:34PM (#15900685)
> Note that even where Google are forced to use git (e.g. Android, Chrome) they use a many-repo approach.

Google uses many-repo approach for Android and Chrome because you cannot fit everything in a single git repo (well you can, but it will be a pain in the ass to work on that repo). Git is just not designed for huge repos. Google is also working on tools to make the many-repo of Android or Chrome work like a monorepo.

Re:Why Google stores billions of lines of code in a single r... by w_t_payne on Sunday December 10, 2017 @06:35AM (#15890984)
I have written my own tooling. It is doable. Just time-consuming. -- It took me about a year (2015) of my (limited) spare time.
Re:Why Google stores billions of lines of code in a single r... by geocar on Sunday December 10, 2017 @05:32AM (#15890819)
Software A version 1 consumes format F1 and produces format G1 data, and software B version 1 consumes format G1 and produces H1.

To upgrade format G2 we must change both software A and B.

First, software B version 2 must accept both G1 and G2. To do this we may need to build software A version 2 and try them in a sandbox environment to gain confidence that ∀F1 we produce the correct G2. If F1 is complete, we may be able to do this exhaustively, but if F1 is sufficiently diverse, monte carlo simulation might be used.

Then, if there's a 1:1 relationship between A/B we can upgrade pairs.

If there's a N:M relationship, we need to upgrade all of the instances of software version B1 to B2 (at least within a shard). If you're running in a non-stop environment, this might have it's own challenges. Only then, can we begin the upgrade from A1 to A2.

Now:

Something, somewhere needs to record what and where we are in this journey. It is relatively straightforward how to do this with a monorepo, but it is very unclear how to do it with a distributed repository:

Almost everyone I know punts and uses some other golden record (like a continuous integration server, or a ticketing system, or an admin/staging system), and like it or not: that's your monorepo.

Re:Why Google stores billions of lines of code in a single r... by Joeri on Sunday December 10, 2017 @09:22AM (#15891471)
You can also design software A to produce both G1 and G2 side by side, deploy it, and then develop new software B against G2, submitting bug reports to project A when there’s a problem detected in G2.

If you’re doing the multirepo strategy it’s best imho to make the projects truly independent, as if they were developed by different companies. That way every project only needs to think about its own dependencies and consumers, and how to do migrations, without needing to have the big picture mapped out.

Re:Why Google stores billions of lines of code in a single r... by geocar on Sunday December 10, 2017 @09:58AM (#15891636)
> You can also design software A to produce both G1 and G2 side by side

This can be impractical if G is a database table that is very large.

> it’s best imho to make the projects truly independent, as if they were developed by different companies.

One of our systems might cost £300k, so completely desynchronising them so that code paths can build both G1 and G2 simultaneously (allowing B to develop separately) means "simply" doubling the costs. That might put our team at a disadvantage against someone who figures out another way.

Re:Why Google stores billions of lines of code in a single r... by Groxx on Sunday December 10, 2017 @01:17PM (#15892649)
> This can be impractical if G is a database table that is very large.

If this is true, you have no choice, and must run things side by side while you convert to G2. Or shut everything down to make the migration atomic, which is increasingly not an option.

Re:Why Google stores billions of lines of code in a single r... by geocar on Sunday December 10, 2017 @01:53PM (#15892845)
> you have no choice

It depends on your database.

If you imagine a simple postgres or mysql server and an "alter table G..." then you're right.

If (however) G1⊂G2 then a document store or a column-based database can usually partition the table somehow.

Re:Why Google stores billions of lines of code in a single r... by gwenzek on Monday December 11, 2017 @03:38AM (#15895847)
> This can be impractical if G is a database table that is very large.

Unless if the new format G2 is a super set of the old format G1. Read protobuffers best practice to know more about this.

Re:Why Google stores billions of lines of code in a single r... by pas on Sunday December 10, 2017 @07:05AM (#15891069)
Maybe using a ticketing system [or just call it a project management system] is the right abstraction level.

If A and B has nothing to do with each other - other than for some circumstantial reason they consume data from each other, then why would we care if A or B starts to support a new output format?

If we want to do a format change for some reason, maybe it'll allow better security/traceability, then sure, make a project and track the tasks (like make A able to produce/consume new format, make B able to produce/consume new format, deploy A2 and B2 to test environment, promote to prod), but I don't see why would you track that on the source code versioning level.

A and B has separate tests to ascertain that they can deal with the new format, and then you do the integration testing, that might catch problems, that then should be covered by unit tests in A or B. (Or in a fuzzer for said format.)

Re:Why Google stores billions of lines of code in a single r... by geocar on Sunday December 10, 2017 @09:14AM (#15891440)
> Maybe using a ticketing system [or just call it a project management system] is the right abstraction level.

> If A and B has nothing to do with each other - other than for some circumstantial reason they consume data from each other, then why would we care if A or B starts to support a new output format?

First, even if the coordination between A and B is recorded in the ticketing system, the coordination between F and G is probably not.

> I don't see why would you track that on the source code versioning level.

Pretend F and G are tables in a database (or other data storage system) if that makes it easier.

Where is the schema stored? Who records the migration path?

Many people like to record migrations in a version control system, but it is tricky to link those migrations to the (otherwise) independent A and B.

If these are file formats where exists the code to consume and produce them? Or network formats? The problem remains the same -- do we break this up into additional libraries?

That there's a very real ordering between release of A and B that isn't properly encoded, we're relying on process diligence (as opposed to tooling) to be correct.

Re:Why Google stores billions of lines of code in a single r... by pas on Monday December 11, 2017 @04:24AM (#15895974)
If tables, then if they are in the same DB, they should be in the same project.

If they are independent tables, then I don't care, show me the API between the projects.

If these are file/network/serialization/wire/in-memory/binary/codec formats, then there are conformance checkers (passive and active, like fuzzers). Those are separate projects, but they can be used like tools during testing and development.

Rely on tooling to make sure that the stated goal of the project is reached. (It now supports F or G or X,Y,Z formats. It supports output-format G by processing input-format F. If that's a project requirement, test it in that project.)

You can use a top level repo for the integration tests. But it's no need to make it one flat repo.

Re:Why Google stores billions of lines of code in a single r... by geocar on Tuesday December 12, 2017 @10:18AM (#15906127)
> If tables, then if they are in the same DB, they should be in the same project.

Lock-stepping two otherwise unrelated applications because they both share support for a data structure is silly at best, and often impractical, especially if development for only one of the projects is "in-house". Consider the possibility that "A" is a commercial product produced by another company.

Anyway, it's my experience most software upgrades don't involve a schema change, so it's worth optimising for the common case, and supporting the difficult case.

Re:Why Google stores billions of lines of code in a single r... by qquark on Sunday December 10, 2017 @06:15AM (#15890937)
> but it is very unclear how to do it with a distributed repository

Versioning through branching and tagging, while having some drawbacks - at least the fact that you have to DO an operation and that this is not automatic - seem to solve this problem, and are not, in my eyes, a form of monorepo. You globally get more flexibility at the cost of a bit more repo management work.

If the problem is retrieving the right version automatically, externals or submodules should be able to solve this problem. If A and B have no clear dependency direction, a top level repo might help.

Re:Why Google stores billions of lines of code in a single r... by geocar on Sunday December 10, 2017 @09:18AM (#15891452)
> a top level repo might help.

This is the way I generally do it: A repository that represents my system/environment that has submodules for A1, A2, B1, and B2, and scripts for updating the environment.

Re:Why Google stores billions of lines of code in a single r... by newfoundglory on Sunday December 10, 2017 @05:52AM (#15890864)
Not by any definition I can think of. How are you defining "monorepo"?
Re:Why Google stores billions of lines of code in a single r... by user5994461 on Sunday December 10, 2017 @06:56AM (#15891050)
I will get a furry of downvotes for saying it but the cause of your first three problems is git, not the mono repo approach.

Git only allows to check/commit/view to the entire repo at once. Then, some git operations are superlinear with the number of files or revisions, they are slow on large repo to the point of being unusable.

It's mandatory to have operation on a per file or subdirectory level in a mono repo approach. Companies that have mono repos all built tooling to support it. CVS/SVN used to do that out of the box but everyone hate them now.

Re:Why Google stores billions of lines of code in a single r... by svckr on Sunday December 10, 2017 @07:49AM (#15891177)
> CSV/SVN used to do that out of the box but everyone hate them now.

It's "CVS" and it lacks a concept for a repository-wide version (except, maybe, a timestamp). A repository-wide version is –I guess– the single best reason to have monorepo in the first place.

SVN is okay.

Also, `git log -- subdir/`.

Re:Why Google stores billions of lines of code in a single r... by k__ on Sunday December 10, 2017 @07:29AM (#15891127)
Why aren't submodules more wide spread?

Building a monorepo out of submodules should solve these problems, or not?

Also, there is subtree.

Re:Why Google stores billions of lines of code in a single r... by iveqy on Sunday December 10, 2017 @09:01AM (#15891383)
Because submodules is hard to understand. They require that you understand git and that you can add one level of abstraktion.

Once you done that, they är great!

Re:Why Google stores billions of lines of code in a single r... by Groxx on Sunday December 10, 2017 @01:21PM (#15892665)
Also hard to deal with. Lots of operations leave submodules in unclean / out-of-date states.

In general / light use, yeah, they're great. Unfortunately, they have a very large number of edge cases where they essentially require either a) everyone to be experts in the edge cases, or b) tons of new tooling (because existing tools won't take these steps for you).

Re:Why Google stores billions of lines of code in a single r... by lamlam on Sunday December 10, 2017 @09:00PM (#15894658)
That is... until you try to remove a submodule.

I like sobmodules, but the whole feature needs a lot more polish before it's widely adopted.

Re:Why Google stores billions of lines of code in a single r... by nickm12 on Monday December 11, 2017 @12:42AM (#15895356)
That's fair. I think the important thing is to be able to have multiple versions of portions of your repo and then be able to version that. A branch of branches, so to speak.
Re:Why Google stores billions of lines of code in a single r... by Sacho on Sunday December 10, 2017 @05:27AM (#15890811)
> Every day there are hundreds of changes in the repo and almost all of them have nothing to do with what I'm working on.

Wouldn't the right tooling be able to show you changes to the slice of code you're interested in? I remember SVN would allow you to checkout just a single subdirectory, for example.

> all sorts of operations take longer (pulling, grepping source, etc.) to support code I couldn't care less about.

Makes sense about the pulling, but again, wouldn't grepping be configurable to only search where you need to?

> Frequently have to update the world at once. Unless the repo can store multiple versions of the same module, then all the consumers have to be updated at once, even if it's inconvenient. Sometimes migrations are better done gradually.

I'm not sure I understood you here, can you expand on that? Do you mean all the devs have to update their module? Why not use tagged/branched version of libs instead of working off trunk?

What kind of tooling do you use for the distributed approach?

Re:Why Google stores billions of lines of code in a single r... by nickm12 on Monday December 11, 2017 @12:50AM (#15895377)
Yeah, it's all about the tooling. The distributed system I used was when I worked at Amazon. Each "package" there has its own git repo, which can have multiple branches and the dependencies of each branch are versioned along with the branch. I wonder if at the end of the day it really matters whether something is a "monorepo" or not if the tooling provides the necessary abstractions to version things the way you need.
Re:Why Google stores billions of lines of code in a single r... by gmueckl on Monday December 11, 2017 @01:12AM (#15895443)
Did you use standard software for the versioning? We are looking for a solution for this at work and have come up blank so far.
Re:Why Google stores billions of lines of code in a single r... by gmueckl on Monday December 11, 2017 @01:11AM (#15895436)
Using different branches for different modules becomes hard in a monorepo when branching is a global operation. You can only have a single branch checked out in your working copy then.

The only solution I can think of is to create a copy within the monorepo to create de facto branches without regular VCS support. This would be kind of terrible.

Re:Why Google stores billions of lines of code in a single r... by hvidgaard on Monday December 11, 2017 @08:37AM (#15896915)
I am a firm believer of using processes and tools that make it hard to do stuff you should not be doing in the first place. Dependencies should be solved ala how FAKE and Paket is doing it, not in a mono repo. It's the same story for many projects in a solution vs few. With few projects you avoid wrestling with cyclic dependencies between projects, on the other hand, that is just a tell tale sign that the overall structure is starting to deteriorate.

I still do not see the appeal in mono repos since you're heavily dependent on discipline to not introduce spaghetti dependencies, where you fix one bug, but introduce 4 new in unrelated parts of the code. Now you solve that with an if statement, and thus we introduced a great deal of technical debt.

Re:Why Google stores billions of lines of code in a single r... by nerdwaller on Sunday December 10, 2017 @10:35AM (#15891825)
> 3) Frequently have to update the world at once

I’ve never worked in a monorepo, so may be wrong, but this point presumes a dependency on “latest” at all times. I’d assume the components in the mono repo still release versions to the various package management systems (maven, pypi, npm, etc), allowing dependencies to be more stable.

Has that not been the common experience by those that have worked in them? I see a lot of merits of having to update everything at once (less code rot, hopefully) but it does seem to have drawbacks (many have commented on these as well).

Re:Why Google stores billions of lines of code in a single r... by malkia on Sunday December 10, 2017 @11:16AM (#15892026)
If the library/component is wide spread, it either can be developed in a branch, and specific version be tagged, or always developed "trunk" mode with feature toggles (may not be always possible, but one can adjust), e.g. - certain features are disabled, and need to be enabled after others come across, or after some specific time, etc.

While at google, we used that kind of development for the project I was in. Someone would push source code changes for new features, but prefferable behind a flag (normally a command-line flag, driven to a configuration, like the one ksonnet has). The confiuration file would say - enable this flag, only the binary was compiled with this CL version, and/or these cherrypicks, or some other rule.

This also allows a feature to be quickly disabled by SRE, SWE, or other personnel if it's found to be not working well.

Re:Why Google stores billions of lines of code in a single r... by w_t_payne on Sunday December 10, 2017 @06:34AM (#15890982)
Both approaches can be made to work. For me, the overriding concern is simplicity and ease of configuration management, so I prefer something that on the surface looks like a monorepo. Somewhat paradoxically, in my attempt to solve the issues that you mention, I ended up scripting my commits and checkouts so I could place the repository in a set of git repositories -- so I have a distributed set of repositories under the hood that look like a monorepo to the people using it! Neat, huh?
Re:Why Google stores billions of lines of code in a single r... by zeveb on Monday December 11, 2017 @02:43PM (#15899693)
(argh, I wasn't able to post this due to HN's over-eager 'submitting too fast' filter; at the time, I'd submitted all of two comments & one story within an hour — and then I had to restart my browser, which lost the text of this comment)

> 1) Difficult to track changes to the code I'm interested in.

What's wrong with 'git log $PATH'?

> 2) all sorts of operations take longer (pulling, grepping source, etc.) to support code I couldn't care less about.

A different format could help here, as can different tools (e.g. ripgrep or ag instead of grep). The time spent on those operations has to be balanced with the time spent updating your code to deal with someone else's incompatible library changes, again, when the other person is on vacation and you have no idea what the new philosophy of his library is. And you don't have any choice about updating, because another one of your dependencies that you really must update has already been updated to rely on his changes.

> 3) Frequently have to update the world at once.

IMHO that's a feature, not a bug. The person or team responsible for breaking the world is responsible for fixing it, rather than getting to break the world, then pop off down to Barton-on-Sea for an extended holiday while everyone else in the company gets to update his code to use an entirely different idiom.

> 4) Encourages sloppy dependency management.

My experience has been that multiple repos tend to encourage sloppy dependency management, while a monorepo tends to encourage deliberative, collaborative, professional dependency management. That's just my own experience, and of course different organisations will differ.

> I'm sure people will say "if you're having those problems, you're doing it wrong" but the same thing could be said to people who find the distributed model problematic.

My own experience has been that multirepos tend to be like dynamic typing and monorepos tend to be like static typing: multirepos can in theory be done right, but in practice they never are, while monorepos work, but at the cost of people having to colour within the lines. Which makes sense for any particular organisation may actually be a function of its maturity: if a place is trying to move fast and break things, maybe multiple repos make sense; if it's trying to deliver quality software, maybe a single repo makes sense.

Re:Why Google stores billions of lines of code in a single r... by albertzeyer on Sunday December 10, 2017 @07:42AM (#15891153)
You could argue that all your points can be solved also by the right tooling.
Re:Why Google stores billions of lines of code in a single r... by s17n on Monday December 11, 2017 @04:27PM (#15900619)
1 and 2 are trivially fixable.

3 and 4 are pretty fundamental though, especially 3 - if you don't want to force everybody to keep up with head, you probably don't want to use a monorepo.

Re:Why Google stores billions of lines of code in a single r... by woolvalley on Monday December 11, 2017 @03:29AM (#15895817)
#1 in git is `git log <subdirectory>`