Simplify piglit threading

Graphics / Mesa 3D Graphics Library / Piglit - Dylan Baker [gmail.com] - 9 January 2014 19:37 UTC

This patch simplifies threading in piglit by removing the hand-rolled threadpool, and instead using the Pool class from multiprocessing.dummy. This provides a map interface, allowing for very clear succinct code.

The previous implementation ran all tests out of thread pools, a serial pool and a multi-threaded pool. This patch does the same thing for a couple of reasons. First, the obvious solution is to use the map() builtin for serial tests. However, map in python3 returns an iterator instead of a list so calling map(f, x) will not actually run f(x) until something tries to use those values. This would require considerable restructuring to work around. Second, that could easily be split out into another patch, and limits the number of changes in this patch.

Multiproccessing.dummy is a wrapper around the Threading module, providing the multiproccessing API, but with threads instead of processes.

V2: - Renamed run() helper to test()- use multiprocessing.dummy.Pool() default thread count value, which is equal to multiproccessing.cpu_count(), instead of cpu_count() explicitly
V3: - use Pool.imap() instead of Pool.map(), it is slightly faster.
V4: - Remove use of map() builtin

e4c9a36 Simplify piglit threading
framework/core.py | 58 +++++++++++++++++++++++-----------------
framework/threadpool.py | 67 -----------------------------------------------
2 files changed, 34 insertions(+), 91 deletions(-)

Upstream: cgit.freedesktop.org


  • Share