-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add :parallel-threads option to set thread pool size #274
base: parallelize
Are you sure you want to change the base?
Conversation
Thank you for the PR! I've been holding off on reviewing this because I'm waiting to merge the original PR. I think being able to control the thread pool somehow is a good idea. However, I'm not sure whether bringing in another dependency is worth it. Out of curiosity, have you run the parallel threads PR against any of your test systems? |
Thanks for responding! I considered the issue of adding a dependency, but claypoole is very light-weight and has no dependencies of its own. If that is still a problem, I could look into the possibility of vendoring just the pmap implementation. The additional control is absolutely necessary for heavy-weight test systems, both for speed and to stay within RAM constraints. It is also a useful performance-tuning knob for others. I have been running this branch for testing locally and in CI for the last month. It has held up fine for hundreds of runs, although the increased parallelism did surface a race condition in etaoin. |
@@ -186,4 +186,5 @@ | |||
(try+ | |||
(System/exit (apply -main* args)) | |||
(catch :kaocha/early-exit {exit-code :kaocha/early-exit} | |||
(shutdown-agents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also shutdown agents if -main*
exits normally?
(defn add-desc [testable description] | ||
(assoc testable ::desc | ||
(str (name (::id testable)) " (" description ")"))) | ||
|
||
(defn- try-require [n] | ||
(try | ||
(require n) | ||
(locking REQUIRE_LOCK | ||
(require n)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -174,7 +189,8 @@ | |||
:kaocha/testable test}) | |||
m (cond-> m | |||
file (assoc :file file) | |||
line (assoc :line line))] | |||
line (assoc :line line) | |||
thread (assoc :thread thread))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to namespace this? things like type/actual/expected/line/file are standard clojure.test things, if we shove extra data into reporter events we generally namespace them. Not sure how consistent we are in this but generally a good idea.
Hi @john-shaffer , thanks a lot for this PR. There's some good stuff in here, and I appreciate you're helping to make Kaocha better. Sorry it's taken me so long before I managed to make time to have a better look. I had a look at Claypoole, it has no dependencies of its own, it weighs itself about ~100kB. Also looking at what it does I think it's reasonable to bring that in here. So, let's see if we can get this into a mergeable state? I see REPL code in source namespaces, a stray Thanks a lot! |
Hi @john-shaffer , do you still have interest in getting this in a mergable state, or was this a drive-by PR? |
run-testables ends up being called within its own body, which kaocha is parallelizing. We generally want to parallelize at the namespace level, so we use run-test-serial for other testable types. This way we only create one threadpool at a time.
The previous code references fixtures/f-tests, but there is no such directory. The test case looks unfinished, so I'm not sure that there ever was a working f-tests dir. To fix the test case, I have adapted the code from run-test, just before run-test-parallel.
7bcfb5e
to
2502632
Compare
Codecov Report
@@ Coverage Diff @@
## parallelize #274 +/- ##
==============================================
Coverage ? 75.06%
==============================================
Files ? 51
Lines ? 2755
Branches ? 256
==============================================
Hits ? 2068
Misses ? 525
Partials ? 162
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Rebased on current parallelize branch, and updated a failing test case. |
dc258bb
to
615ea82
Compare
The current parallel runner uses clojure.core/map with futures, which doesn't allow much control over execution. It is probably okay for unit tests, but it uses way too many threads for integration and e2e tests. We have test systems that spawn database and browser processes, and we need a much lower level of parallelism (4 seems ideal on an 8-core machine).
This uses claypoole's pmap to run the tests, which allows for simplifying the code a bit.