What are good ways to induce threading problems
I am finishing off testing a multi-threaded application that seems to work fine until I put it under heavy load and then stress the machine it is running on as well. Then I start seeing some of the stranger edge-cases that I did not foresee produce some unexpected/unforeseen conditions. The way I am stressing the machine is by running a vacu开发者_如何学Pythonum on a very large sqlite database. Does anyone have any other good ways of inducing this type of heavy-load scenario?
You could use CHESS.
What kind of stress are you referring to? Memory, CPU, full thread pool, or file I/O?
I'd write a simple app that has a thread that consumes memory, a thread that consumes CPU cycles, a thread that ties up the thread pool, and a thread that thrashes the disk. Hang a UI on it to control each thread's appetite and adjust the "knobs" to honk with your app.
Might be of interest to you - Unit testing a mutlithreaded application
Threading problems due to improper locking tend to reveal themselves under heavy load because the timing changes. It isn't actually the heavy load that produces the problem, it is the changed timing due to random scheduling delays. You can repro the problems without heavy loads by introducing random delays in the thread's execution. This is the approach Chess uses.
精彩评论