Skip to content

Commit

Permalink
[Distributed] Set smaller Store timeouts to make c10d tests run faster (
Browse files Browse the repository at this point in the history
#46067)

Summary:
Pull Request resolved: #46067

In our store tests, we expect there to be an exception when we call
get on a recently-deleted key. Unforunately, the store waits for the timeout
period for the key to be set before throwing, which causes the tests to idel
wait for 5+ minutes. This PR decreases the timeouts before this set call so
these tests run faster.
ghstack-source-id: 113917315

Test Plan: Ran both the Python and C++ tests.

Reviewed By: pritamdamania87

Differential Revision: D24208617

fbshipit-source-id: c536e59ee305e0c01c44198a3b1a2247b8672af2
  • Loading branch information
osalpekar authored and facebook-github-bot committed Oct 9, 2020
1 parent 2fa91fa commit e33d455
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/distributed/test_c10d.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def _test_numkeys_delkeys(self, fs):
self.assertEqual(fs.num_keys(), 5)
fs.delete_key("key")
self.assertEqual(fs.num_keys(), 4)
fs.set_timeout(timedelta(seconds=2))
with self.assertRaises(RuntimeError):
fs.get("key")
fs.delete_key("key0")
Expand Down
4 changes: 4 additions & 0 deletions torch/lib/c10d/test/TCPStoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <c10d/PrefixStore.hpp>
#include <c10d/TCPStore.hpp>

constexpr int64_t kShortStoreTimeoutMillis = 100;

// Different ports for different tests.
void testHelper(const std::string& prefix = "") {
const auto numThreads = 16;
Expand Down Expand Up @@ -51,6 +53,8 @@ void testHelper(const std::string& prefix = "") {
EXPECT_FALSE(delFailure);
numKeys = serverStore->getNumKeys();
EXPECT_EQ(numKeys, 4);
auto timeout = std::chrono::milliseconds(kShortStoreTimeoutMillis);
serverStore->setTimeout(timeout);
EXPECT_THROW(serverStore->get("key0"), std::runtime_error);
});

Expand Down

0 comments on commit e33d455

Please sign in to comment.