News for hackers. Stuff that matters.
Re:Josh: Get the advantages of a monorepo with multirepo setups by derefr on Thursday July 15, 2021 @12:04PM (#27846281)
IANAMU (I Am Not A Monorepo User), but as far as I understand monorepos and their advantages, I'm not sure what the use-case for this tooling is.

Most of the time, when an org chooses to move to having a monorepo (rather than just being left with one by accident of history), the key advantage they're striving to attain, is the ability to make changes to cross-cutting concerns across many distinct applications/libraries, with single commits/PRs. To change an API, and all of its internal callers, atomically, without having to worry about symbolically binding the two together with dependency version constraint resolution.

Which is to say, the key advantage of a monorepo comes from having the whole monorepo checked out locally.

Re:Josh: Get the advantages of a monorepo with multirepo setups by majormajor on Thursday July 15, 2021 @12:25PM (#27846523)
When I've used a monorepo, that was one of the explicit goals.

Avoiding "here's my new library version, go see if it breaks your shit" was the goal - you make a change, you run the tests, you see if the whole company's code can still build or not. Having fully-separate projects in directories in the monorepo using published dependencies was considered an antipattern (though it was very hard to keep some teams from doing that).

The disadvantages of the resulting monorepo weren't "this directories are so big to keep checked out when I'm just working on one specific project" it was "our old build times and build tools are dying under the strain and even trying to move to a 'monorepo friendly' build tool might be an intractable problem because our dependency graph has become such a mess of spaghetti."

A monorepo that was done well from the start so you don't have the slow-spaghetti-build problem from months or years of "oh it's easy to depend directly on this full other module, let's just do that" sounds very appealing. We just didn't pull it off in practice, and this project would ... maybe... help in the early stages by letting people have more restricted checkouts? But only if you already know what you're doing anyway.

Re:Josh: Get the advantages of a monorepo with multirepo setups by qznc on Thursday July 15, 2021 @06:22PM (#27850812)
You seem to mix two different goals here. Atomic commits across everything surely is a feature of a monorepo which a manyrepo setup cannot replicate. However, the "test whole company's code" could also be achieve with a central package manager and many repos. That is what Amazon does: http://beza1e1.tuxen.de/amazon_manyrepo_builds.html
Re:Josh: Get the advantages of a monorepo with multirepo setups by majormajor on Thursday July 15, 2021 @07:22PM (#27851247)
Yeah, there's two different aspects in there (though without the full-blown testing making broad atomic commits isn't super attractive to me anyway. ;) )

Amazon's Brazil system doesn't sound like it does the "test the whole company's code" aspect in the same way.

> If you create a package at Amazon, you specify an interface version like "1.1". As long as changes are backwards-compatible, the interface version is not changed. When Brazil builds a package, it appends an additional number to turn it into a build version like "1.1.3847523". You can only specify dependencies on interface versions.

So if I'm working on a non-backwards-compatible version, my users aren't going to pull it down immediately in the build (if I properly call it version 1.2.x), so the build won't show which of them it broke.

Even if you depend on the latest version instead of pinning to a major version, how would I force a company-wide build of everything that depended on me using my not-yet-landed branch? I can run those tests in a monorepo on my branch directly, I don't see how I'd do it in a manyrepo setup without a very specific set of "every project in the company specifies its dependencies as depending on specific, easily-overrideable, commit SHA versions."

Re:Josh: Get the advantages of a monorepo with multirepo setups by grogenaut on Thursday July 15, 2021 @11:20PM (#27852743)
Actually to do that, one was is to just make 1.1 as 1.0 in a test branch to do the test build and build it against everything. There are other ways to do this as well, depends on what you're doing.

But it's important to note amazon doesn't monorepo like you are used to thinking, so it is actually on everyone to take the updates on the schedule they've set via automation or if it's an emergency via ticketing / policy. You are merely seeing if it's going to work, the automation does the rest, possibly over weeks.

And I am simplifying things here to make it easier to understand. Understanding brazil from not using it, is about as difficult as understanding git rebase coming from CVS, eg there are concepts you didn't even knew existed that you have to understand how to use to operate at large scale.

Re:Josh: Get the advantages of a monorepo with multirepo setups by roughly on Thursday July 15, 2021 @12:39PM (#27846698)
The basic problem with trying to solve the problems with versioned releases with monorepos is that the code in the repo and the code in production are not the same. If you change your service’s API, just updating all of the other clients of your service in the repo is not sufficient to skirt the problem of different clients expecting different APIs.

Re the tooling issue, I’ve frankly never seen it solved. I presume Google’s done it, because they’re a bit messianic about the whole thing, but outside of them, I suspect all monorepo implementations fit into the “Communism” model of working great in theory.

Re:Josh: Get the advantages of a monorepo with multirepo setups by throwaways885 on Thursday July 15, 2021 @01:08PM (#27847029)
> If you change your service’s API, just updating all of the other clients of your service in the repo is not sufficient to skirt the problem of different clients expecting different APIs.

Most Google APIs are written in protobuf, which is backwards compatible over the wire. This makes most changes painless, although caveat emptor as things can still get messy as they do in the real world. With something like a Java interface, it doesn't really matter if those APIs change because all the code is built and released together at HEAD.

Re:Josh: Get the advantages of a monorepo with multirepo setups by majormajor on Thursday July 15, 2021 @01:13PM (#27847087)
Backwards compatible from a parsing-this-message-won't-blow-up standpoint but not necessarily from a semantic meaning-of-each-field standpoint if your devs are ... clever ... enough. ;)

That discipline to commit to an API and meaning for each field and not keep tinkering with it in messy ways is an under-valued and under-evangelized aspect.

Re:Josh: Get the advantages of a monorepo with multirepo setups by roughly on Thursday July 15, 2021 @01:17PM (#27847140)
> With something like a Java interface, it doesn't really matter if those APIs change because all the code is built and released together at HEAD.

Right, this is the thing that winds up following from the monorepo - the monorepo problem goes away if we just release everything, the whole fuckin’ system, into production every time we make any update to master. If that’s your system, hats off to you, I’m not nearly that good of an engineer.

Re:Josh: Get the advantages of a monorepo with multirepo setups by barrkel on Thursday July 15, 2021 @02:50PM (#27848555)
It's actually easier, in many ways -- if you can manage to release continuously. It forces you to stage your code incrementally and you should be able to roll back things easily if you see breakage.
Re:Josh: Get the advantages of a monorepo with multirepo setups by throwaways885 on Friday July 16, 2021 @03:46PM (#27860435)
If your services are backwards compatible to talk to each other, then you don't need to release instantly. Making breaking changes is tricky, but you don't need to release everything.
Re:Josh: Get the advantages of a monorepo with multirepo setups by spicybright on Thursday July 15, 2021 @01:41PM (#27847518)
I don't understand the problem. Code structure that listens to dev/prod mode can handle the different APIs. Branches to mark prod vs. dev.

Can you give a more concrete example of the problem? I don't think I'm understanding.

Re:Josh: Get the advantages of a monorepo with multirepo setups by roughly on Thursday July 15, 2021 @01:49PM (#27847662)
The pitch I often hear with monorepos is “When you change your service/library/whatever, you can simultaneously change all of the clients of that library/service/whatever in one PR”. The problem is a PR is not a release - just because the code in the repo is up to date doesn’t mean the code in production is. So, for example, if your service changes to require an extra parameter in the API, sure, you can update all of the clients of that API to provide that extra parameter, but that still requires them to be built & released as well - just updating the code doesn’t actually fix the deploy/release coordination problem.

Short version, you’re right, coordinating releases with feature flags, branches, etc. solves this problem, but it solves the problem in a multi-repo world too, and a monorepo doesn’t obviate the need for those solutions as many of its proponents seem to suggest.

There are probably legitimate uses for monorepos, but an awful lot of people seem to position them as a silver bullet that lets developers stop having to worry about coordination in a multi-service world, and that’s just not how it works out.

Re:Josh: Get the advantages of a monorepo with multirepo setups by floober on Thursday July 15, 2021 @02:18PM (#27848132)
I agree that it doesn't improve things at the service interface level. What I have found is that I often have several internal libraries, and a monorepo ensures that I know if a change to my library breaks another service because they're all in one build. Keeping things consistent across services is very useful in my experience.
Re:Josh: Get the advantages of a monorepo with multirepo setups by thebean11 on Thursday July 15, 2021 @02:11PM (#27848025)
The issue comes if you are communicating between different binaries (for example, RPC requests or message handlers). Just because you can change the code atomically doesn't mean you can deploy the client and server atomically.

As someone pointed out though, proto mitigates a lot of this.

Re:Josh: Get the advantages of a monorepo with multirepo setups by chrschilling on Thursday July 15, 2021 @12:52PM (#27846829)
IATAOJ (I Am The Author Of Josh) ;)

You are absolutely right about the main motivation of using a monorepo: Allowing upsrteam library maintainers to see downstream usage of their code and make the required downstream changes themselves at the same time they change their libraries.

Also like you say the easiest way to get those advantages is to just check out the monorepo locally, so if there are no other reasons preventing you from doing just that, go for it.

However there are a few reasons why this is not always sufficient:

Size: The repo might be so large that cloning it all will makes local tools (git cli, guis,...) slow to use, or in the most extreme case require to much disk space for your machine. To address this there are some git native tools like partial clone and sparse checkout, so size alone is not really the the main issue for us.

History "pollution": Having a lot of somewhat loosely related projects in one tree means a history that shows all the changes. Yes git can filter them, but once again that might be a performance concern, but once again not really the biggest motivation to create a new approach/tool.

Permissions: In some organisations (like the one I work for) it is not possible to give all developers access to all the code and thus the advantages of monorepo get lost just by trying to comply with data protection standards. The only solution with native git is to split the repo at legal (not necessary technical) boundaries and try to coordinate the changes across those. Loosing most of the benefits described. Josh does not have a full blown permissions system yet, but the concept certainly allows for it and implementation is work in progress.

Sharing with others (aka, distributed VCS): This is the biggest motivation for using something like Josh. The partial repos are repos in their own right and all the distributed features of git can be used with them. In a monorepo setup as you describe distributed workflow is sacrificed for monorepo advantages. Only developers in the same monorepo see the same sha1s and can easily exchange changes. In Josh the same library can be part of different monorepos at different organisations and while the monorepos have different history and therefore sha1s, the “projected” or “partial” library subrepos will have compatible history with identical sha1s. In this way Josh can serve as a bridge between organisations using different repo structures.

Re:Josh: Get the advantages of a monorepo with multirepo setups by thrtythreeforty on Thursday July 15, 2021 @03:36PM (#27849106)
This is a really interesting approach. How would you layer CI logic on top of this? Given your example workspace josh file,

    dependencies = :/modules:[
        ::tools/
        ::library1/
    ]
how are the canonical build artifacts for, say, ::library1/ determined, and how are they presented to the workspace?

I understand that the partial repo layering is the key innovation that exists a layer below what I'm talking about, but I'm trying to understand how you can ergonomically layer never-build-twice logic on top of it.

Re:Josh: Get the advantages of a monorepo with multirepo setups by chrschilling on Friday July 16, 2021 @08:06AM (#27855426)
For the CI Josh is only used to determine if a given commit affects a given workspace. This can be done server side using the Josh GraphQL API. Having this understanding about the dependencies of workspaces understood by the vcs server(in this case Josh) means that such a query can be executed server side before any git clone/fetch needs to happen and in our case also before the CI allocates a machine to do the clone/checkout.

What artifacts are to be build inside a given workspace is totally up tho the build system(s) and tools that work after the files have been checked out to a working copy at which point Josh is not involved at all.

Re:Josh: Get the advantages of a monorepo with multirepo setups by wildmanxx on Thursday July 15, 2021 @12:31PM (#27846599)
The ability to do some changes like that is not the same as doing it always. Most commits are quite localized, and those should not be penalized by the ability to have a few cross-cutting ones.
Re:Josh: Get the advantages of a monorepo with multirepo setups by oftenwrong on Thursday July 15, 2021 @12:25PM (#27846519)
I think there are some potential applications.

For example, you want to have a project in the monorepo, but also share it outside of your organisation, and even have external contributions brought back in.

Or, you are working in a project in the monorepo, but you don't want to (or can't) check out the entire repo. You can still checkout just that project and its deps.

Or, you are working in a polyrepo-using organisation, and you want to experiment with using a monorepo while continuing to allows devs to work in the polyrepos that it is composed from. No big-bang cutover necessary.

Re:Josh: Get the advantages of a monorepo with multirepo setups by chrschilling on Thursday July 15, 2021 @12:56PM (#27846874)
Yes that it exactly the idea. Translating between both mono and poly repo, partial sharing with others (distributed development) and gradual adoption without a big bang.
Re:Josh: Get the advantages of a monorepo with multirepo setups by bognition on Thursday July 15, 2021 @12:12PM (#27846379)
They are very useful when you've got hundreds of engineers working on distinct projects that are loosely connected. Imagine you have a team working on core libraries, a few product platform teams, and finally a team working on a customer facing feature. The feature team commits to master and a build kicks off (build 1), that build fails for an unrelated issue (say the build node dies) and the build kicks off again (build 2). With multiple layers of libraries supporting the feature team, its entirely possible that a dependency could have changed and the end result of build 2 would be different than build 1.

When each commit shares a common timeline it is really easy to rebuild build 1 with the exact same dependencies.

Re:Josh: Get the advantages of a monorepo with multirepo setups by derefr on Thursday July 15, 2021 @12:17PM (#27846440)
Git submodules already solve that problem, though. As does publishing all the core libraries etc. as language-ecosystem packages on a private package namespace or internal corporate package repository, and then resolving/locking the language-package dependencies to specific tags/refs with a lockfile that gets committed to the downstream repo.

These are the "obvious" solutions to this problem, the first ones the average software architect would reach for. What would lead them to ignore these options and choose a monorepo instead, if not for what I mentioned above — the ability to make atomic changes to cross-cutting concerns?

Re:Josh: Get the advantages of a monorepo with multirepo setups by justaguy88 on Thursday July 15, 2021 @12:48PM (#27846791)
Git submodules have an annoying attribute: double commit

First you commit/push to one repository

Then you update the submodule pointer in the parent repository

Re:Josh: Get the advantages of a monorepo with multirepo setups by chiefalchemist on Thursday July 15, 2021 @12:44PM (#27846760)
I've resisted - for too long? - submodules as I've always heard they can be problematic; that the actual implementation isn't quite what I should be.
Re:Josh: Get the advantages of a monorepo with multirepo setups by zerkten on Thursday July 15, 2021 @01:34PM (#27847397)
>> These are the "obvious" solutions to this problem, the first ones the average software architect would reach for.

They would have been, except the experience working with them was somewhat problematic for those who have been down this path, and the message that many devs have received is to avoid them. I kind of agree with going to submodules, but confidence doesn't seem to have been rebuilt.