how does one actually test concurrency (and then debug it)? like, how
can you write tests which claim to have "coverage" of the possible
interleavings?
thanks.
Many thanks for the note.
> coverage of the interleavings, as in a real MT run the interleavings
> are non-deterministic.
> With the Refs and STM, the interleavings can become arbitrarily
> complex and you shouldn't care. What matters is the degree of
I agree that at some level it is good to be able to abstract out
caring about the issue, and that things like STM are helping the
higher levels get away from having to worry about it. And that seems
like a good thing.
But, being a devil for a moment, or just being interested in how one
robustly develops STM that for sure works, what does one do when stuck
at the level where non-determinism is something you really do have to
deal with?
I'm not expecting there to be much of a perfect answer given the fact
that testing can't prove the absence of bugs. But presumably there are
best practices / various ways / some theory about how to approach such
problems, and I wonder what those are for concurrency. Seems like the
usual things people would rely on in unit testing for single threaded
systems suddenly are nigh useless because their coverage metric
suddenly goes towards zero due to not being able to know and cover all
possible interleavings. E.g. Perhaps there are some approaches like
somehow tweaking the game and underlying rules such that you can prove
more things with more confidence, or rule things out? But then of
course you might be losing power of some sort as you do that. Do you
go for probabilistic testing? Or is there some abstract theory that
builds things from the ground up such that if converted correctly to
code really don't worry about interleavings - sorta full circle to STM
and back again to "ah but how do you really test that you converted it
to actual code correctly?" :-)
sincerely.
That said, I'm not terribly familiar with their use and value in practice.
[1]: http://www.cs.umd.edu/projects/PL/multithreadedtc/overview.html
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
> In the absence of any analysis, you can't trust the code.
> Testing tells you very little, if anything at all.
Analysis is important, to be sure. But there's Knuth's down-to-earth
truism "I have only proven it correct, not tested it" to be kept in
mind. I believe both analysis and testing are required before you can
get anywhere close to trusting some code. Given that, I'm interested
in hearing about theory, tools, best practices for either. For
example, taking all the locks in the same numbered order begs the
qustion how do you prove and test that a real-world system actually
does that?
There are probably as many answers to the vague question I'm asking as
there are people and systems. The thought I had in my head was "if you
are a regular single-threaded unit testing kind of person, what do you
do when you start into concurrency?" I agree that approaching
concurrency from the angle of "oh I wrote some unit tests and they
passed on my machine so ship it" is a zillion times more preposterous
in light of concurrency. So then one must move along the gamut towards
(a) tests which better take into consideration concurrency issues and
(b) even further, analysis.
Which then begs the questions of what theory and tools to check the
theory do people use? I get the impression it is all pretty academic
still, or perhaps there are non-academic tools which may be used but
they are bloody expensive. And, over all, that it will require a fair
bit of new learning and training.
If things like STM take care of it all for regular folks, I'm of
course excited about that. But unfortunately I don't yet have the good
fortune of working at that level, I have to live with regular
concurrent Java, and with people who seem to think that isn't so bad.
:-(
sincerely.
many thanks for the thoughts!
> There's a presumption in your question you refuse to relinquish - that
> testing is useful here. I contend it isn't very useful.
> They are kidding themselves, IMO, at least when things go beyond some
yeah, i think i agree to a fair degree.
tho, i think there's a gamut of quality targets and expectations - it
seems to me that it must be the case that some folks don't really care
if things sometimes get 100% stuck as long as it doesn't happen
frequently and they can just reboot the sever and get another week
before it gets stuck. (it is scary when those people are even
developers, themselves, i'd expect them to know/desire better.)
> But your question boils down to - how can we keep doing essentially
> what we already do (writing imperative code and unit tests) and ensure
> our programs will work well under concurrency. Clojure exists in part
> because I think we can't.
Personally I don't really want to keep doing things the old way,
believe it or not. I didn't mean to imply that I think only imperative
approaches with unit testing are useful. I am just trying to find out
what other people's experience / thoughts are.
We probably differ in how much value we attach to the nebulous concept
of testing wrt concurrency; Even if somebody smart has really great
analysis, w/out tests I'll be skeptical of there not being bugs which
perhaps could have been unearthed via some sort of testing approach.
There is plenty of room for semantics around what the idea of
"testing" means, and I suspect that you believe in at least some basic
level of testing even for concurrency. Like, you do run your code
through an actual compiler not just to get bytecode out, but to find
errors - sometimes even ones which might impact concurrency - too,
presumably. :)
sincerely.