Skip to content

Commit 08e4876

Browse files
authored
Minor fixes (#192)
* Fix flaky point-to-point test * Remove unused piece of code * Re-order fields to remove struct padding * Fix missing initializers for primitive members * fix possible fd leak * Pass by const reference where it's more efficient * More unused variables * copy->move * find ":" -> ':' * Use defaulted instead of empty constructors * Executor con/destructor fixup * PTP broker raciness fixes * DummyExecutor short sleep to make it much less likely to fail under TSan
1 parent 4eef572 commit 08e4876

25 files changed

+53
-57
lines changed

include/faabric/scheduler/MpiWorld.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class MpiWorld
230230

231231
// Track ranks that are local to this world, and local/remote leaders
232232
// MPITOPTP - this information exists in the broker
233-
int localLeader;
233+
int localLeader = -1;
234234
std::vector<int> localRanks;
235235
std::vector<int> remoteLeaders;
236236
void initLocalRemoteLeaders();

include/faabric/scheduler/Scheduler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class ExecutorTask
3535
bool needsSnapshotPushIn,
3636
bool skipResetIn);
3737

38-
int messageIndex = 0;
3938
std::shared_ptr<faabric::BatchExecuteRequest> req;
4039
std::shared_ptr<std::atomic<int>> batchCounter;
40+
int messageIndex = 0;
4141
bool needsSnapshotPush = false;
4242
bool skipReset = false;
4343
};
@@ -49,7 +49,7 @@ class Executor
4949

5050
explicit Executor(faabric::Message& msg);
5151

52-
virtual ~Executor();
52+
virtual ~Executor() = default;
5353

5454
void executeTasks(std::vector<int> msgIdxs,
5555
std::shared_ptr<faabric::BatchExecuteRequest> req);
@@ -222,7 +222,7 @@ class Scheduler
222222

223223
// ---- Host resources and hosts ----
224224
faabric::HostResources thisHostResources;
225-
std::atomic<int32_t> thisHostUsedSlots;
225+
std::atomic<int32_t> thisHostUsedSlots = 0;
226226

227227
void updateHostResources();
228228

include/faabric/snapshot/SnapshotRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace faabric::snapshot {
1212
class SnapshotRegistry
1313
{
1414
public:
15-
SnapshotRegistry();
15+
SnapshotRegistry() = default;
1616

1717
faabric::util::SnapshotData& getSnapshot(const std::string& key);
1818

include/faabric/snapshot/SnapshotServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ class SnapshotServer final : public faabric::transport::MessageEndpointServer
4040

4141
private:
4242
faabric::transport::PointToPointBroker& broker;
43-
std::atomic_size_t diffsAppliedCounter;
43+
std::atomic_size_t diffsAppliedCounter = 0;
4444
};
4545
}

include/faabric/state/InMemoryStateRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace faabric::state {
88
class InMemoryStateRegistry
99
{
1010
public:
11-
InMemoryStateRegistry();
11+
InMemoryStateRegistry() = default;
1212

1313
std::string getMasterIP(const std::string& user,
1414
const std::string& key,

include/faabric/transport/Message.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ namespace faabric::transport {
1212
class Message
1313
{
1414
public:
15-
Message(const zmq::message_t& msgIn);
15+
explicit Message(const zmq::message_t& msgIn);
1616

17-
Message(int sizeIn);
17+
explicit Message(int sizeIn);
1818

19-
Message();
19+
// Empty message signals shutdown
20+
Message() = default;
2021

2122
char* data();
2223

@@ -31,6 +32,6 @@ class Message
3132
private:
3233
std::vector<uint8_t> bytes;
3334

34-
bool _more;
35+
bool _more = false;
3536
};
3637
}

include/faabric/transport/PointToPointBroker.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <faabric/util/locks.h>
66
#include <faabric/util/scheduling.h>
77

8+
#include <atomic>
89
#include <condition_variable>
910
#include <queue>
1011
#include <set>
@@ -69,7 +70,7 @@ class PointToPointGroup
6970
int groupId = 0;
7071
int groupSize = 0;
7172

72-
std::mutex mx;
73+
std::shared_mutex mx;
7374

7475
// Transport
7576
faabric::transport::PointToPointBroker& ptpBroker;
@@ -80,7 +81,7 @@ class PointToPointGroup
8081

8182
// Distributed lock
8283
std::stack<int> recursiveLockOwners;
83-
int lockOwnerIdx = -1;
84+
std::atomic<int> lockOwnerIdx = -1;
8485
std::queue<int> lockWaiters;
8586

8687
void notifyLocked(int groupIdx);

include/faabric/util/func.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace faabric::util {
1010
std::string funcToString(const faabric::Message& msg, bool includeId);
1111

1212
std::string funcToString(
13-
const std::shared_ptr<faabric::BatchExecuteRequest> req);
13+
const std::shared_ptr<faabric::BatchExecuteRequest>& req);
1414

1515
unsigned int setMessageId(faabric::Message& msg);
1616

include/faabric/util/snapshot.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ enum SnapshotMergeOperation
3030
class SnapshotDiff
3131
{
3232
public:
33+
const uint8_t* data = nullptr;
34+
size_t size = 0;
3335
SnapshotDataType dataType = SnapshotDataType::Raw;
3436
SnapshotMergeOperation operation = SnapshotMergeOperation::Overwrite;
3537
uint32_t offset = 0;
36-
size_t size = 0;
37-
const uint8_t* data = nullptr;
3838

3939
bool noChange = false;
4040

src/scheduler/Executor.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ ExecutorTask::ExecutorTask(int messageIndexIn,
2424
std::shared_ptr<std::atomic<int>> batchCounterIn,
2525
bool needsSnapshotPushIn,
2626
bool skipResetIn)
27-
: messageIndex(messageIndexIn)
28-
, req(reqIn)
29-
, batchCounter(batchCounterIn)
27+
: req(std::move(reqIn))
28+
, batchCounter(std::move(batchCounterIn))
29+
, messageIndex(messageIndexIn)
3030
, needsSnapshotPush(needsSnapshotPushIn)
3131
, skipReset(skipResetIn)
3232
{}
@@ -53,8 +53,6 @@ Executor::Executor(faabric::Message& msg)
5353
}
5454
}
5555

56-
Executor::~Executor() {}
57-
5856
void Executor::finish()
5957
{
6058
SPDLOG_DEBUG("Executor {} shutting down", id);

0 commit comments

Comments
 (0)