@@ -28,10 +28,12 @@ class PushManager {
28
28
public:
29
29
// / Create a push manager.
30
30
// /
31
- // / \param max_bytes_in_flight Max number of bytes allowed to be in flight
31
+ // / \param max_chunks_in_flight Max number of chunks allowed to be in flight
32
32
// / from this PushManager (this raylet).
33
- explicit PushManager (int64_t max_bytes_in_flight)
34
- : max_bytes_in_flight_(max_bytes_in_flight){};
33
+ explicit PushManager (int64_t max_chunks_in_flight)
34
+ : max_chunks_in_flight_(max_chunks_in_flight) {
35
+ RAY_CHECK_GT (max_chunks_in_flight_, 0 );
36
+ };
35
37
36
38
// / Start pushing an object subject to max chunks in flight limit.
37
39
// /
@@ -40,39 +42,40 @@ class PushManager {
40
42
// / \param dest_id The node to send to.
41
43
// / \param obj_id The object to send.
42
44
// / \param num_chunks The total number of chunks to send.
43
- // / \param max_chunk_size See comment for max_chunk_size_ in PushState.
44
45
// / \param send_chunk_fn This function will be called with args 0...{num_chunks-1}.
45
46
// / The caller promises to call PushManager::OnChunkComplete()
46
47
// / once a call to send_chunk_fn finishes.
47
48
void StartPush (const NodeID &dest_id,
48
49
const ObjectID &obj_id,
49
50
int64_t num_chunks,
50
- int64_t max_chunk_size,
51
51
std::function<void (int64_t )> send_chunk_fn);
52
52
53
53
// / Called every time a chunk completes to trigger additional sends.
54
54
// / TODO(ekl) maybe we should cancel the entire push on error.
55
- void OnChunkComplete (int64_t push_max_chunk_size );
55
+ void OnChunkComplete ();
56
56
57
57
// / Cancel all pushes that have not yet been sent to the removed node.
58
58
void HandleNodeRemoved (const NodeID &node_id);
59
59
60
- void RecordMetrics () const ;
61
-
62
- int64_t BytesInFlight () const { return bytes_in_flight_; }
63
-
64
- int64_t ChunksRemaining () const { return chunks_remaining_; }
60
+ // / Return the number of chunks currently in flight. For metrics and testing.
61
+ int64_t NumChunksInFlight () const { return chunks_in_flight_; };
65
62
66
- int64_t PushesInFlight () const { return push_state_map_.size (); }
63
+ // / Return the number of chunks remaining. For metrics and testing.
64
+ int64_t NumChunksRemaining () const { return chunks_remaining_; }
67
65
68
- int64_t PushRequestsRemaining () const {
66
+ // / Return the number of push requests with remaining chunks. For metrics and testing.
67
+ int64_t NumPushRequestsWithChunksToSend () const {
69
68
return push_requests_with_chunks_to_send_.size ();
70
- }
69
+ };
70
+
71
+ // / Record the internal metrics.
72
+ void RecordMetrics () const ;
71
73
72
74
std::string DebugString () const ;
73
75
74
76
private:
75
77
FRIEND_TEST (TestPushManager, TestPushState);
78
+ FRIEND_TEST (TestPushManager, TestNodeRemoved);
76
79
77
80
// / Tracks the state of an active object push to another node.
78
81
struct PushState {
@@ -81,13 +84,8 @@ class PushManager {
81
84
82
85
// / total number of chunks of this object.
83
86
int64_t num_chunks_;
84
- // / the max size of a chunk for this object in bytes, used to count bytes_in_flight_
85
- // / and assure it stays under max_bytes_in_flight_. This means we can overcount for
86
- // / the last chunk but we're accepting that to keep the code simpler.
87
- int64_t max_chunk_size_;
88
87
// / The function to send chunks with.
89
88
std::function<void (int64_t )> chunk_send_fn_;
90
-
91
89
// / The index of the next chunk to send.
92
90
int64_t next_chunk_id_ = 0 ;
93
91
// / The number of chunks remaining to send.
@@ -96,12 +94,10 @@ class PushManager {
96
94
PushState (NodeID node_id,
97
95
ObjectID object_id,
98
96
int64_t num_chunks,
99
- int64_t max_chunk_size,
100
97
std::function<void (int64_t )> chunk_send_fn)
101
98
: node_id_(node_id),
102
99
object_id_ (object_id),
103
100
num_chunks_(num_chunks),
104
- max_chunk_size_(max_chunk_size),
105
101
chunk_send_fn_(std::move(chunk_send_fn)),
106
102
num_chunks_to_send_(num_chunks) {}
107
103
@@ -126,11 +122,11 @@ class PushManager {
126
122
// / Called on completion events to trigger additional pushes.
127
123
void ScheduleRemainingPushes ();
128
124
129
- // / Max number of bytes in flight allowed.
130
- const int64_t max_bytes_in_flight_ ;
125
+ // / Max number of chunks in flight allowed.
126
+ const int64_t max_chunks_in_flight_ ;
131
127
132
- // / Running count of bytes in flight
133
- int64_t bytes_in_flight_ = 0 ;
128
+ // / Running count of chunks in flight, used to limit progress of in_flight_pushes_.
129
+ int64_t chunks_in_flight_ = 0 ;
134
130
135
131
// / Remaining count of chunks to push to other nodes.
136
132
int64_t chunks_remaining_ = 0 ;
0 commit comments