mirror of
https://github.com/wassname/ray.git
synced 2026-09-09 11:32:43 +08:00
Increase TaskID size by 2 bytes, taken from JobID (#6425)
* Increase TaskID size by 2 bytes, taken from JobID * comments * check max job id * fix doc * fix local mode
This commit is contained in:
@@ -288,6 +288,7 @@ cdef class JobID(BaseID):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_int(cls, value):
|
def from_int(cls, value):
|
||||||
|
assert value < 65536, "Maximum JobID integer is 65535."
|
||||||
return cls(CJobID.FromInt(value).Binary())
|
return cls(CJobID.FromInt(value).Binary())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -1111,9 +1111,8 @@ def connect(node,
|
|||||||
if setproctitle:
|
if setproctitle:
|
||||||
setproctitle.setproctitle("ray::IDLE")
|
setproctitle.setproctitle("ray::IDLE")
|
||||||
elif mode is LOCAL_MODE:
|
elif mode is LOCAL_MODE:
|
||||||
# Code path of local mode
|
|
||||||
if job_id is None:
|
if job_id is None:
|
||||||
job_id = JobID.from_int(random.randint(1, 100000))
|
job_id = JobID.from_int(random.randint(1, 65535))
|
||||||
worker.worker_id = ray.utils.compute_driver_id_from_job(
|
worker.worker_id = ray.utils.compute_driver_id_from_job(
|
||||||
job_id).binary()
|
job_id).binary()
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ ObjectID ObjectID::GenerateObjectId(const std::string &task_id_binary,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
JobID JobID::FromInt(uint32_t value) {
|
JobID JobID::FromInt(uint16_t value) {
|
||||||
std::vector<uint8_t> data(JobID::Size(), 0);
|
std::vector<uint8_t> data(JobID::Size(), 0);
|
||||||
std::memcpy(data.data(), &value, JobID::Size());
|
std::memcpy(data.data(), &value, JobID::Size());
|
||||||
return JobID::FromBinary(
|
return JobID::FromBinary(
|
||||||
|
|||||||
+3
-3
@@ -99,9 +99,9 @@ class UniqueID : public BaseID<UniqueID> {
|
|||||||
|
|
||||||
class JobID : public BaseID<JobID> {
|
class JobID : public BaseID<JobID> {
|
||||||
public:
|
public:
|
||||||
static constexpr int64_t kLength = 4;
|
static constexpr int64_t kLength = 2;
|
||||||
|
|
||||||
static JobID FromInt(uint32_t value);
|
static JobID FromInt(uint16_t value);
|
||||||
|
|
||||||
static size_t Size() { return kLength; }
|
static size_t Size() { return kLength; }
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ class ActorID : public BaseID<ActorID> {
|
|||||||
|
|
||||||
class TaskID : public BaseID<TaskID> {
|
class TaskID : public BaseID<TaskID> {
|
||||||
private:
|
private:
|
||||||
static constexpr size_t kUniqueBytesLength = 6;
|
static constexpr size_t kUniqueBytesLength = 8;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr size_t kLength = kUniqueBytesLength + ActorID::kLength;
|
static constexpr size_t kLength = kUniqueBytesLength + ActorID::kLength;
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ Ray ID Specification
|
|||||||
high bits low bits
|
high bits low bits
|
||||||
<--------------------------------------------------------------------------------------------
|
<--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
4B
|
2B
|
||||||
+-----------------+
|
+-----------------+
|
||||||
| unique bytes | JobID 4B
|
| unique bytes | JobID 2B
|
||||||
+-----------------+
|
+-----------------+
|
||||||
|
|
||||||
4B 4B
|
4B 2B
|
||||||
+-----------------+-----------------+
|
+-----------------+-----------------+
|
||||||
| unique bytes | JobID | ActorID 8B
|
| unique bytes | JobID | ActorID 6B
|
||||||
+-----------------+-----------------+
|
+-----------------+-----------------+
|
||||||
|
|
||||||
6B 8B
|
8B 6B
|
||||||
+---------------------------+-----------------------------------+
|
+---------------------------+-----------------------------------+
|
||||||
| unique bytes | ActorID | TaskID 14B
|
| unique bytes | ActorID | TaskID 14B
|
||||||
+---------------------------+-----------------------------------+
|
+---------------------------+-----------------------------------+
|
||||||
@@ -26,14 +26,14 @@ Ray ID Specification
|
|||||||
+---------------------------+---------------------------------------------------------------+
|
+---------------------------+---------------------------------------------------------------+
|
||||||
|
|
||||||
```
|
```
|
||||||
#### JobID (4 bytes)
|
#### JobID (2 bytes)
|
||||||
`JobID` is generated by `GCS` to ensure uniqueness. Its length is 4 bytes.
|
`JobID` is generated by `GCS` to ensure uniqueness. Its length is 2 bytes.
|
||||||
|
|
||||||
#### ActorID (8 bytes)
|
#### ActorID (8 bytes)
|
||||||
An `ActorID` contains two parts: 1) 4 unique bytes, and 2) its `JobID`.
|
An `ActorID` contains two parts: 1) 4 unique bytes, and 2) its `JobID`.
|
||||||
|
|
||||||
#### TaskID (14 bytes)
|
#### TaskID (14 bytes)
|
||||||
A `TaskID` contains two parts: 1) 6 unique bytes, and 2) its `ActorID`.
|
A `TaskID` contains two parts: 1) 8 unique bytes, and 2) its `ActorID`.
|
||||||
If the task is a normal task or a driver task, the part 2 is its dummy actor id.
|
If the task is a normal task or a driver task, the part 2 is its dummy actor id.
|
||||||
|
|
||||||
The following table shows the layouts of all kinds of task id.
|
The following table shows the layouts of all kinds of task id.
|
||||||
|
|||||||
Reference in New Issue
Block a user