Dynamic Derivation Working Group - Meeting Notes #1

Dyn Drvs Working Group - Kickoff meeting

Result of Dynamic Derivations + Dynamic build graphs: next steps - #11 by tomberek. If interested; contact @tomberek for meetup invites, Ping @Ericson2314 for org invites, join Matrix: #nix-dyn-drv:ggpeti.com for discussion.

Status

  • @ericson2314:

    • @artemis has been working on rust use case w/crates per derivation
    • if using one of the libraries then end user doesn’t need to know
    • basic primitives are feature complete
    • build integrations
    • have had dyn-drvs for a while, but depended on recursive-nix
    • @artemis implemented builder-rpc-v0 (unix domain socket) to interact with store and register outputs, allows for references between outputs
    • Haskell has Sandstone (need to investigate Darwin failure)
  • @mschwaig:

    • Q: do we have to register the outputs?
    • A: @artemis: only have to register final derivation, the tree is resolved by nix-daemon
    • Q: can it be used as a caching mechanims, via CA?
    • A: Yes if the fine-grained derivation collides. They become valid paths.
  • @tomberek: anything else needed in Nix itself?

    • A: @ericson: allow for building to get started before entire plan is done. Can implement your integration without depending on it, but can get speed up for free. Looking to remove placeholders. More work needed on signature format.
  • @ericson2314:

    • lang2nix tool development can work in parallel
  • @reiss:

    • sandboxing costs 30-40% (few versions ago)
    • @ericson: current design doesn’t inherently have the costs, this can be optimized over time. Current approach does O(n) mounting of dependencies. Can consider file-descriptor based approachs.
    • @artemis: a firecracker-based VM can do snapshot/restore, or get reused
  • @artemis:

    • Hydra work need.

Brainstorm

Things to work on

Next

  • infra
    • Hydra: @artemis: should work, needs further testing. A few PRs are in flight.
    • @tomberek: should we setup shared infrastructure?
      • @ericson: having join infra and larger scale demo would help β€œlive it”. Performance issues would be felt and prioritized.
      • @tomberek: I can try to get an Oxide rack. (no ARM, no KVM)
      • @artemis: considering Obsidian after some TBD work
      • @mschwaig: how much? (@tomberek: maybe Hydra + 2 builders)
      • @waern: nixbulid recently added CA-derivation, not yet added support for DynDrvs.
      • @ericson: draft of RFC to stablize the rpc format, derivation format, etc.
      • Currently rpc implements the protocol as a limitted form of the regular protocol, inheriting the daemon protocol’s warts. There is some thought on other formats (Cap’N’Proto,Varlink, etc) might reduce toil for integrations. It is possible that the format can change.
  • When do we start aggressive outreach?
    • nixpkgs fork/overlay
    • build farm
    • cache: S3 might be best for now
  • admin
    • video: Jitsi Meet
    • shared GitHub org with fork/overlay
    • Matrix: #nix-dyn-drv:ggpeti.com
  • documentation/tutorials/testimonials
  • benchmarks/perf

With Jaen post meeting

Tasks

  • @tomberek: ask Oxide for a rack
  • @tomberek: establish meetup cadence
  • @bryanhonof: can get feedback from internal use
  • @ericson: Github org
  • @artemis: Hydra stand-up + infra
    • @adeci happy to help here with infra
  • @bryanhonof: engage on cache
  • @mschwaig: build-trace implementation
  • @lyndeno: explore kernel build + writeup
  • all: send Github handles to @ericson
13 Likes

It’s mentioned a little here, but any nixpkgs implementation will need feature detection that also works without the latest versions of Nix. Lix has all dynamic-derivations features removed, and compatibility needs to be maintained on that end.

1 Like

I was just talking to @xokdvium about this. I have other features I would like to adopt that also need feature detection…..

1 Like

FWIW, I don’t see dyn drvs being remotely ready for prime time in nixpkgs of course. Too many bugs to fix and a very long road to having it be competitive in terms of performance.

Language-side feature detection is one thing, and store layer is another. There isnt really an easy way for libstore-dependent pure feature detection that can be exposed in libexpr. So if anything, this stuff would have to stay opt-in and target out-of-tree use. That’s where the greatest (potential) benefits lie anyway.

1 Like

Agreed (at least from the outside). Thanks for keeping expectations tempered.

The caveats about there still being many bugs to be fixed and improvements to be made is obviously self evident (trying to get Chromium to build with reasonable overhead using dyndrvs had been a challenge), but I’m not so sure about this one.

If we had granular, incremental builds of big and/or fundamental packages like Chromium or compilers or the bootstrap chain, wouldn’t it save a lot of resources in Hydra and time spent on waiting for staging to bake?

3 Likes

The incremental nature of it only works when the input is itself incremental, so its usefulness depends on how fine grained the input is, and how coupled the derivations are to the parts of the source that were modified. Or more simply the size of the reverse closure - closing over dependents.
I imagine it would help tremendously for patches, but not so much for release updates, which will have many changes that easily saturate the reverse closure.

Derivations are a final description of how stuff must be built, take it or leave it. That’s their purpose.
Evaluation is also meant to be pure, behaving like a pure function from sources to derivations, so under pure eval, we can’t have the evaluator decide anything based on properties of the builders.

So the only place where the opt-in or opt-out decision can be made is in the codomain, so in the expression sources.
That’s what we’ve been doing with nixpkgs.config flags like the timidly named config.contentAddressedByDefault.

If a sufficient number of people cares about Nix implementations without dyndrv support, Nixpkgs could use a similar flag to offer both builds, at least in leaf-ish packages, and users of dyndrv get the benefit of being able to patch their software without the wait.
Ideally channel updates can also take advantage of that, but iiuc that requires taking other hurdles anyway before it becomes significant.

2 Likes

Huh, the jitsi room was empty yesterday :eyes:. Will DM you for the invite.

I (and some others) feel skeptical that β€œdynamic derivations”, in the specific technical sense of β€œderivations producing ATerm (and one node, not a subgraph!) + speaking to the recursive-nix socket (renaming it to builder-rpc-v0 doesn’t substantially change the fact that it’s (filtered) recursive-nix)” ever go through in Nixpkgs, it just doesn’t feel realistic. The only reason we seem to be talking about dyndrvs is because our evaluator’s state is (currently) not representable, i.e. cannot be named, memoized, or distributed across multiple machines. If Nix-lang were more like Unison or Lisp (and we don’t know if it’s particularly unlike Lisp, it’s just too weird and ad hoc to easily judge, and idk if anyone has yet made a formal effort), we’d obviously just stick to the much-cleaner IFD model.

2 Likes

@roberth, here’s an example of building llc from LLVM across a few version bumps (at a derivation-per-sourcefile granularity):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Rung            β”‚ ninja  β”‚ Shinobi β”‚ ninja edges β”‚ Shinobi chunks β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 21.1.1 cold               β”‚ 207.0s β”‚ 229.0s  β”‚ 1776        β”‚ 1773           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β†’ 21.1.2 (adjacent patch) β”‚ 91.0s  β”‚ 88.1s   β”‚ 558         β”‚ 537            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β†’ 21.1.8 (6 patches)      β”‚ 84.5s  β”‚ 89.7s   β”‚ 567         β”‚ 549            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β†’ 21.1.8 (from 21.1.7)    β”‚ 9.8s   β”‚ 15.0s   β”‚ 102         β”‚ 93             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β†’ 22.1.1 (major)          β”‚ 200.4s β”‚ 211.0s  β”‚ 1809        β”‚ 1807           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

You’re right that on a major bump it didn’t really help, but it was like 2.5x faster on the two patch bumps and one was 15x faster (apparently it didn’t touch any headers, so cut-off was quick. Now, there is still some overhead I have not pinnned down or that got lost in the forest of envvar variations, but if it can make a package bump evaluate ~2x faster on average, I think it would be a big to resource utilisation efficiency in Hydra?

Maybe you were also misled by:

because that was supposed to be 5:00 PM, actually. I assumed this one was correct and " CET (Central European Time): 7:00 PM Thursdays" was an hour off (we’re +2 right now). Timezones are hard xD

2 Likes

Where is the matrix room, I can’t join?

1 Like