Live data from Hacker News

Running three hours of Ruby tests in under three minutes

stripe.com

51–60 of 111 posts

Re: Running three hours of Ruby tests in under three minutes

#51
> Initially, we experimented with using Ruby's threads instead of multiple processes

Why, to be cool? Tests are a classic case of things that should be run in isolation - you don't want tests interfering with earth other or crashing the whole test suite. Using separate processes would have been the sensible approach to start with.

Re: Running three hours of Ruby tests in under three minutes

#52
post #39

Earlier quoted context omitted.

Not exactly a fair comparison, because you have to compile the changed files first and link which I'm sure takes longer than 14s. On the other hand, using ruby I can have it continuously run the tests for the specific feature I'm working on without the long building step.

Compiling a changed file and linking takes about 5s.

Is that the best case for changing a single cpp file, or the worst case for changing a header file shared across many translation units?

Re: Running three hours of Ruby tests in under three minutes

#55
One thing I've noticed since coding with immutable data structures & functions (rather than mutable OOP programs) is how tests run really fast, and are easy to run in parallell.

I/O only happens in a few functions, and most other code just takes data in -> transforms -> returns data out. This means I only have few functions that need to 'wait' on something outside of itself to finish, and much lesser delays in the code.

This is coding in Clojure for me, but you can do that in any language that has functions (preferable with efficient persistent data structures. Like the tree-based PersistentVector in Clojure).

Re: Running three hours of Ruby tests in under three minutes

#56
post #55

One thing I've noticed since coding with immutable data structures & functions (rather than mutable OOP programs) is how tests run really fast, and are easy to run in parallell. I/O only happens in a few functions, and most other code just takes data in -> transforms -> returns data out. This means I only have few functions that need to 'wait' on something outside of itself to finish, and much lesser delays in the co…

Immutable data structures give you easy parallelism, however there's a hidden runtime cost: you have to allocate way more objects. For example, I was able to save a ton of object allocations here: https://github.com/mime-types/ruby-mime-types/pull/93 mostly by mutating. For tasks that are not easily parallelizable it may be slower to use immutable structures.

I mostly only ever hear about how fast FP languages are, so maybe they use some tricks to avoid allocations somehow. I would be interested in hearing more about it.

Re: Running three hours of Ruby tests in under three minutes

#57
post #27

Earlier quoted context omitted.

how do you trust the hosted CI company not to look at your code? Contracts, not firewalls, make the world go round.

To be fair a contract does not guarantee the security framework of the company you are contracting, which means your code is only as safe as their weakest link.

Which is why contracts include things like right-to-audit, so you can verify for yourself.

Re: Running three hours of Ruby tests in under three minutes

#58
post #52

Earlier quoted context omitted.

Compiling a changed file and linking takes about 5s.

Is that the best case for changing a single cpp file, or the worst case for changing a header file shared across many translation units?

That's changing a cpp file. Changing a widely used header file could take 1-2 mins for a full or nearly full rebuild.

Re: Running three hours of Ruby tests in under three minutes

#59
post #55

One thing I've noticed since coding with immutable data structures & functions (rather than mutable OOP programs) is how tests run really fast, and are easy to run in parallell. I/O only happens in a few functions, and most other code just takes data in -> transforms -> returns data out. This means I only have few functions that need to 'wait' on something outside of itself to finish, and much lesser delays in the co…

Immutable data structures give you easy parallelism, however there's a hidden runtime cost: you have to allocate way more objects. For example, I was able to save a ton of object allocations here: https://github.com/mime-types/ruby-mime-types/pull/93 mostly by mutating. For tasks that are not easily parallelizable it may be slower to use immutable structures. I mostly only ever hear about how fast FP languages are, s…

You can allocate stuff on the stack.

Re: Running three hours of Ruby tests in under three minutes

#60
I am tired of this technology having to be re-invented time and time again.

The best I ever saw was an internal tool at Microsoft. It could run tests on devices (Windows Mobile phones, but it really didn't care), had a nice reservation and pool system and a nice USB-->Ethernet-->USB system that let you route any device to any of the test benches.

This was great because it was a heterogeneous pool of devices, with different sets of tests that executed appropriately.

The test recovery was the best I've ever seen. The back end was wonky as anything, every single function returned a BOOL indicating if it had ran correctly or not, every function call was wrapped in an IF statement. That was silly, but the end result was that every layer of the app could be restarted independently, and after so many failures either a device would be auto removed from the pool and the tests reran on another device, or a host machine could be pulled out, and the test package sent down to another host machine.

The nice part was the simplicity of this. All similar tools I've used since have involved really stupid setup and configuration steps with some sort of crappy UI that was hard to use en-masse.

In comparison, this test system just tool a path to a set of source files on a machine, the compilation and execution command line, and then if the program returned 0 the test was marked as pass, if it returned anything else it was marked as fail.

All of this (except for copying the source files over) was done through an AJAX Web UI back in 2006 or so.

Everything I've used since than has either been watching people poorly reimplementing this system (frequently with not as good error recovery) or just downright inferior tools.

(For reference a full test pass was ~3 million tests over about 2 days, and there were opportunities for improvement, network bandwidth alone was a huge bottle neck)

All that said, the test system in the link sounds pretty sweet.

Post reply on HN