Live data from Hacker News

Deterministic Linux for controlled testing and software bug-finding

developers.facebook.com

61–70 of 71 posts

Re: Deterministic Linux for controlled testing and software bug-finding

#61

TL;DR: This is a Rust project that forces deterministic execution of arbitrary programs and acts like a reproducible container. That is, it hermetically isolates the program from sources of non-determinism such as time, thread interleavings, random number generation, etc. Guaranteed determinism is a powerful tool and it serves as a basis for a number of applications, including concurrency stress testing, record/repla…

Sorry, just an additional question as this project is so interesting:

Does Hermit support running different processes in parallel in certain situations?

It seems like this should be possible to do as long as they are appropriately isolated from each other.

Specifically, if two processes don't share any writable memory mappings then I'm thinking it might be possible for Hermit to exploit the underlying existing isolation between them so that they could run code in-between system calls in parallel (while still making sure that the actual system calls happen in a deterministic order).

Perhaps it would even be possible for the two processes to execute system calls in parallel if they are unrelated and they do not affect deterministic execution (such as if they are doing I/O to different files or directories, or one process doing I/O while another is doing something completely unrelated like getting the time, etc).

Although I guess this latter point (of executing syscalls in parallel) would require doing rewind/replay because it wouldn't be possible to know in advance whether the system calls are going to be related or not, as the two processes might not do the syscalls at exactly the same time.

Is Hermit doing this (executing code in-between syscalls in parallel, at least)? Or do you think it would be possible to do it?

This could significantly increase the usefulness of Hermit for distros that want to do deterministic builds of packages, as most compilation could happen in parallel / i.e. use several cores at the same time!

I'm thinking about huge package builds such as Chromium, Firefox, the Linux kernel, etc. which would perhaps take days to build if they were completely serialized into a single CPU core.

Re: Deterministic Linux for controlled testing and software bug-finding

#62
post #61

TL;DR: This is a Rust project that forces deterministic execution of arbitrary programs and acts like a reproducible container. That is, it hermetically isolates the program from sources of non-determinism such as time, thread interleavings, random number generation, etc. Guaranteed determinism is a powerful tool and it serves as a basis for a number of applications, including concurrency stress testing, record/repla…

Sorry, just an additional question as this project is so interesting: Does Hermit support running different processes in parallel in certain situations? It seems like this should be possible to do as long as they are appropriately isolated from each other. Specifically, if two processes don't share any writable memory mappings then I'm thinking it might be possible for Hermit to exploit the underlying existing isolat…

[Caught by the no-procrastination feature by accident.]

Our earlier (dettrace) prototype allowed syscall-free regions in separate processes to run physically in parallel. Hermit actually hasn't added any process parallelism yet, but it's designed to actually go further than dettrace in this respect.

Specifically, Hermit is architected so that the thread-local syscall handler "checks out" resources from the central scheduler. Resources include things like paths on the file system, contents of files, shared memory, and permission to perform external side effects. Right now, all requests wait for the scheduler to background all other threads and make the current thread the only runnable. But the idea is: in the future we will keep the semantical identical log of linear "commits" (linearization), but will simply background the current thread while it uses the resources they checked out, move forward to the next scheduler iteration, and only block the next runnable thread until its requested resources are freed, not until ALL other threads have finished their timeslice and gone back to waiting on the scheduler.

Re: Deterministic Linux for controlled testing and software bug-finding

#63
post #61

Earlier quoted context omitted.

Sorry, just an additional question as this project is so interesting: Does Hermit support running different processes in parallel in certain situations? It seems like this should be possible to do as long as they are appropriately isolated from each other. Specifically, if two processes don't share any writable memory mappings then I'm thinking it might be possible for Hermit to exploit the underlying existing isolat…

[Caught by the no-procrastination feature by accident.] Our earlier (dettrace) prototype allowed syscall-free regions in separate processes to run physically in parallel. Hermit actually hasn't added any process parallelism yet, but it's designed to actually go further than dettrace in this respect. Specifically, Hermit is architected so that the thread-local syscall handler "checks out" resources from the central sc…

Wow, that's so cool!

That's actually much better than what I was thinking and if I understand you correctly, that should allow you to exploit practically all possible parallelism opportunities (given the constraints).

I'm guessing that your plan would require unmapping shared memory pages so that Hermit can catch memory accesses and request permission from the scheduler (to access the memory pages) when these memory accesses happen. But I think it should be possible to do it, yes (with some overhead if two threads/processes access shared memory pages simultaneously very often, I guess).

Awesome work, thank you!

Re: Deterministic Linux for controlled testing and software bug-finding

#64
post #43

Earlier quoted context omitted.

Does running /bin/date under hermit always return the same time? Or does it just follow the same codepath to retrieve the actual time?

Well, the starting datetime at the beginning of execution in the container is whatever you set it to: $ hermit run --epoch=2022-01-01T00:00:00Z /bin/date Fri Dec 31 16:00:00 PST 2021 We, somewhat eccentrically, put it in last millennium by default. It used to default to the original Unix epoch back in 12/31/1969, but that was causing some software to be very unhappy ;-). The reproducibility guarantee is that the beha…

> We, somewhat eccentrically, put it in last millennium by default.

Hah, that is still going to make some TLS software and their certificate tests very unhappy! Does it show that I've ran into a similar issue before? ;)

But of course, it's trivial to fix with the --epoch parameter :)

Re: Deterministic Linux for controlled testing and software bug-finding

#65
post #59

Earlier quoted context omitted.

Thanks for all the questions! Whew, here goes. > How are you sanitizing the result of stat(), for example? Ah, that part's the same as it was described in the ASPLOS'20 paper ( https://dl.acm.org/doi/10.1145/3373376.3378519 ). Briefly, we present a somewhat sanitized version of the file system. Like if you do `hermit run -- ls -l`, you'll see that you are root, and everything owned by you is owned by root (and everyt…

> we need to implement a caching scheme to at least amortize the overhead of this sort for pathological cases. Still, we will need to trigger the sort even on a single read as you say. So there's a pathological case there -- listing one item from a ginormous directory -- that would run much slower than the native/nondeterministic version. Actually, I just thought that if you decide to go down this path because of thi…

Yeah, it's interesting to think about persisting the state we would need to make the file system more sympatico with Hermit. If we were willing to have a daemon.... Meta develops this "watchman" tool that our build infrastructure uses. I think for existing file systems we could imagine a daemon that watches the directory and caches what we need.

But if we could dream of new file systems, then I want one that is basically btrfs but with O(1) file-level parallel-hashes (rather than block level). Heck maybe it could even enforce a sorted order on directories for us too. The hashes would be very useful in record-and-replay scenarios, where you could know immediately whether the input files are in your content-addressible blob storage without having to hash them every time.

(We have some hash support in Meta's EdenFS FUSE file system https://github.com/facebook/sapling)

P.S. about Reproducible Builds -- we pitched this to the community in 2019 (at the Reproducible Builds Summit) and with that ASPLOS'20 paper, but we would be eager to see anyone wanting to pick it up and take it further.

Re: Deterministic Linux for controlled testing and software bug-finding

#66
Some many years ago there was a commercial product called Jinx debugger [1]. I think I only ever got to kick the tires and find out I couldn't get the hypervisor to run on my machine.

Good to see Meta making more practical Open Source tools like this (and BOLT).

[1] https://en.wikipedia.org/wiki/Jinx_Debugger

Re: Deterministic Linux for controlled testing and software bug-finding

#67

Some many years ago there was a commercial product called Jinx debugger [1]. I think I only ever got to kick the tires and find out I couldn't get the hypervisor to run on my machine. Good to see Meta making more practical Open Source tools like this (and BOLT). [1] https://en.wikipedia.org/wiki/Jinx_Debugger

There’s a bit of shared lineage there. Joseph Devietti and I started working in this area together around 2015. And Joe had worked on the deterministic dOS at UW during his PhD (which led to Jinx).

Another related effort is antithesis.com which also seems to use a hypervisor approach rather than Hermits Linux-syscall-API level approach.

Re: Deterministic Linux for controlled testing and software bug-finding

#68
post #46

missing from blog post: overhead of the system. The full paper provides answer: > IO-intensive software builds have an average overhead of 3.49x, while a compute-bound bioinformatics workflow is under 2%.

For what it is, that's really quite good:) I wouldn't run a prod database in it, but for development/testing/debugging 3.5x is completely fine.

Re: Deterministic Linux for controlled testing and software bug-finding

#70
post #69

Performance is much better than UndoDB I suppose? Are there any sources of nondeterminism UndoDB handles but hermit does not?

The distinction that we often have trouble getting across is between eliminating/controlling nondeterminism, vs recording what happens to occur.

Undo, like rr, and Microsoft TTD, records basically all syscalls, but doesn’t determinize anything in the original execution, only in the replay. A “hermit run” call is like a 0-byte recording —- no nondeterminism so you can “replay” by just running again.

On the overhead, the largest factor is the means of program instrumentation. I don’t know where rr sits, but I’ve heard Microsoft’s solution is quite performant on Windows.

Post reply on HN