Remove use of ObjectID transport flag (#7699)

This commit is contained in:
Edward Oakes
2020-05-17 11:29:49 -05:00
committed by GitHub
parent acffdb2349
commit 16f48078d9
40 changed files with 135 additions and 384 deletions
+1 -2
View File
@@ -30,8 +30,7 @@ void AbstractRayRuntime::Put(std::shared_ptr<msgpack::sbuffer> data,
ObjectID AbstractRayRuntime::Put(std::shared_ptr<msgpack::sbuffer> data) {
ObjectID object_id =
ObjectID::ForPut(worker_->GetCurrentTaskID(), worker_->GetNextPutIndex(),
static_cast<uint8_t>(TaskTransportType::RAYLET));
ObjectID::ForPut(worker_->GetCurrentTaskID(), worker_->GetNextPutIndex());
Put(data, object_id);
return object_id;
}
@@ -39,8 +39,8 @@ ObjectID LocalModeTaskSubmitter::Submit(const InvocationSpec &invocation, TaskTy
} else if (type == TaskType::ACTOR_TASK) {
const TaskID actor_creation_task_id =
TaskID::ForActorCreationTask(invocation.actor_id);
const ObjectID actor_creation_dummy_object_id = ObjectID::ForTaskReturn(
actor_creation_task_id, 1, static_cast<int>(ray::TaskTransportType::RAYLET));
const ObjectID actor_creation_dummy_object_id =
ObjectID::ForTaskReturn(actor_creation_task_id, 1);
builder.SetActorTaskSpec(invocation.actor_id, actor_creation_dummy_object_id,
ObjectID(), invocation.actor_counter);
} else {
@@ -52,8 +52,7 @@ ObjectID LocalModeTaskSubmitter::Submit(const InvocationSpec &invocation, TaskTy
/// TODO(Guyang Song): Use both 'AddByRefArg' and 'AddByValueArg' to distinguish
builder.AddByValueArg(::ray::RayObject(buffer, nullptr, std::vector<ObjectID>()));
auto task_specification = builder.Build();
ObjectID return_object_id =
task_specification.ReturnId(0, ray::TaskTransportType::RAYLET);
ObjectID return_object_id = task_specification.ReturnId(0);
std::shared_ptr<msgpack::sbuffer> actor;
std::shared_ptr<absl::Mutex> mutex;
+2 -2
View File
@@ -40,7 +40,7 @@ void TaskExecutor::Invoke(const TaskSpecification &task_spec,
data = (*exec_function)(dynamic_library_base_addr,
std::stoul(typed_descriptor->FunctionOffset()), args);
}
runtime->Put(std::move(data), task_spec.ReturnId(0, ray::TaskTransportType::RAYLET));
runtime->Put(std::move(data), task_spec.ReturnId(0));
}
} // namespace api
} // namespace ray
} // namespace ray
@@ -1,55 +0,0 @@
package io.ray.api.test;
import com.google.common.collect.ImmutableList;
import io.ray.api.Ray;
import io.ray.api.RayObject;
import io.ray.api.TestUtils;
import io.ray.api.exception.RayException;
import io.ray.api.id.ObjectId;
import io.ray.runtime.RayNativeRuntime;
import io.ray.runtime.object.RayObjectImpl;
import io.ray.runtime.runner.RunManager;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.Test;
public class ClientExceptionTest extends BaseTest {
private static final Logger LOGGER = LoggerFactory.getLogger(ClientExceptionTest.class);
@Test
public void testWaitAndCrash() {
TestUtils.skipTestUnderSingleProcess();
ObjectId randomId = ObjectId.fromRandom();
RayObject<String> notExisting = new RayObjectImpl(randomId, String.class);
Thread thread = new Thread(() -> {
try {
TimeUnit.SECONDS.sleep(1);
// kill raylet
RunManager runManager =
((RayNativeRuntime) TestUtils.getUnderlyingRuntime()).getRunManager();
for (Process process : runManager.getProcesses("raylet")) {
runManager.terminateProcess("raylet", process);
}
} catch (InterruptedException e) {
LOGGER.error("Got InterruptedException when sleeping, exit right now.");
throw new RuntimeException("Got InterruptedException when sleeping.", e);
}
});
thread.start();
try {
Ray.wait(ImmutableList.of(notExisting), 1, 2000);
Assert.fail("Should not reach here");
} catch (RayException e) {
LOGGER.debug("Expected runtime exception: {}", e);
}
try {
thread.join();
} catch (Exception e) {
LOGGER.error("Excpetion caught: {}", e);
}
}
}
@@ -84,9 +84,12 @@ public class RayCallTest extends BaseTest {
TestUtils.LargeObject largeObject = new TestUtils.LargeObject();
Assert.assertNotNull(Ray.call(RayCallTest::testLargeObject, largeObject).get());
ObjectId randomObjectId = ObjectId.fromRandom();
Ray.call(RayCallTest::testNoReturn, randomObjectId);
Assert.assertEquals(((int) Ray.get(randomObjectId, Integer.class)), 1);
// TODO(edoakes): this test doesn't work now that we've switched to direct call
// mode. To make it work, we need to implement the same protocol for resolving
// passed ObjectIDs that we have in Python.
// ObjectId randomObjectId = ObjectId.fromRandom();
// Ray.call(RayCallTest::testNoReturn, randomObjectId);
// Assert.assertEquals(((int) Ray.get(randomObjectId, Integer.class)), 1);
}
private static int testNoParam() {
+4 -8
View File
@@ -85,14 +85,10 @@ def get_async(object_id):
# A hack to keep reference to the future so it doesn't get GC.
user_future.retry_plasma_future = retry_plasma_future
if object_id.is_direct_call_type():
inner_future = loop.create_future()
# We must add the done_callback before sending to in_memory_store_get
inner_future.add_done_callback(done_callback)
core_worker.in_memory_store_get_async(object_id, inner_future)
else:
inner_future = as_future(object_id)
inner_future.add_done_callback(done_callback)
inner_future = loop.create_future()
# We must add the done_callback before sending to in_memory_store_get
inner_future.add_done_callback(done_callback)
core_worker.in_memory_store_get_async(object_id, inner_future)
# A hack to keep reference to inner_future so it doesn't get GC.
user_future.inner_future = inner_future
# A hack to keep a reference to the object ID for ref counting.
-1
View File
@@ -126,7 +126,6 @@ export type RayletInfoResponse = {
children: RayletInfoResponse["actors"];
// currentTaskFuncDesc: string[];
ipAddress: string;
isDirectCall: boolean;
jobId: string;
nodeId: string;
numExecutedTasks: number;
-3
View File
@@ -612,7 +612,6 @@ class NodeStats(threading.Thread):
"children": {},
"currentTaskFuncDesc": [],
"ipAddress": "",
"isDirectCall": False,
"jobId": "",
"numExecutedTasks": 0,
"numLocalObjects": 0,
@@ -782,7 +781,6 @@ class NodeStats(threading.Thread):
self._addr_to_extra_info_dict[addr] = {
"jobId": actor_data["JobID"],
"state": actor_data["State"],
"isDirectCall": actor_data["IsDirectCall"],
"timestamp": actor_data["Timestamp"]
}
@@ -826,7 +824,6 @@ class NodeStats(threading.Thread):
"jobId": ray.utils.binary_to_hex(
actor_data.job_id),
"state": actor_data.state,
"isDirectCall": True,
"timestamp": actor_data.timestamp
}
else:
-1
View File
@@ -75,7 +75,6 @@ cdef extern from "ray/core_worker/core_worker.h" nogil:
CJobID CreationJobID() const
CLanguage ActorLanguage() const
CFunctionDescriptor ActorCreationTaskFunctionDescriptor() const
c_bool IsDirectCallActor() const
c_string ExtensionData() const
cdef cppclass CCoreWorker "ray::CoreWorker":
-6
View File
@@ -150,12 +150,6 @@ cdef extern from "ray/common/id.h" namespace "ray" nogil:
c_bool is_put()
c_bool IsDirectCallType()
CObjectID WithPlasmaTransportType()
CObjectID WithDirectTransportType()
int64_t ObjectIndex() const
CTaskID TaskId() const
+1 -4
View File
@@ -168,9 +168,6 @@ cdef class ObjectID(BaseID):
def hex(self):
return decode(self.data.Hex())
def is_direct_call_type(self):
return self.data.IsDirectCallType()
def is_nil(self):
return self.data.IsNil()
@@ -186,7 +183,7 @@ cdef class ObjectID(BaseID):
@classmethod
def from_random(cls):
return cls(CObjectID.FromRandom().WithDirectTransportType().Binary())
return cls(CObjectID.FromRandom().Binary())
def __await__(self):
# Delayed import because this can only be imported in py3.
+4 -7
View File
@@ -125,13 +125,10 @@ class SerializationContext:
self.add_contained_object_id(obj)
owner_id = ""
owner_address = ""
# TODO(swang): Remove this check. Otherwise, we will not be able to
# handle serialized plasma IDs correctly.
if obj.is_direct_call_type():
worker = ray.worker.global_worker
worker.check_connected()
obj, owner_id, owner_address = (
worker.core_worker.serialize_and_promote_object_id(obj))
worker = ray.worker.global_worker
worker.check_connected()
obj, owner_id, owner_address = (
worker.core_worker.serialize_and_promote_object_id(obj))
obj = id_serializer(obj)
owner_id = id_serializer(owner_id) if owner_id else owner_id
return (obj, owner_id, owner_address)
-1
View File
@@ -333,7 +333,6 @@ class GlobalState:
"IPAddress": actor_table_data.owner_address.ip_address,
"Port": actor_table_data.owner_address.port
},
"IsDirectCall": True,
"State": actor_table_data.state,
"Timestamp": actor_table_data.timestamp,
}
+1 -1
View File
@@ -113,7 +113,7 @@ def test_get_throws_quickly_when_found_exception(ray_start_regular):
ray.get(signal1.send.remote())
signal2 = SignalActor.remote()
actor = Actor.options(is_direct_call=True, max_concurrency=2).remote()
actor = Actor.options(max_concurrency=2).remote()
expect_exception(
[actor.bad_func2.remote(),
actor.slow_func.remote(signal2)], ray.exceptions.RayActorError)
+10 -7
View File
@@ -18,7 +18,14 @@ logger = logging.getLogger(__name__)
@pytest.fixture
def one_worker_100MiB(request):
yield ray.init(num_cpus=1, object_store_memory=100 * 1024 * 1024)
config = json.dumps({
"object_store_full_max_retries": 2,
"task_retry_delay_ms": 0,
})
yield ray.init(
num_cpus=1,
object_store_memory=100 * 1024 * 1024,
_internal_config=config)
ray.shutdown()
@@ -33,12 +40,8 @@ def _fill_object_store_and_get(oid, succeed=True, object_MiB=40,
if succeed:
ray.get(oid)
else:
if oid.is_direct_call_type():
with pytest.raises(ray.exceptions.RayTimeoutError):
ray.get(oid, timeout=0.1)
else:
with pytest.raises(ray.exceptions.UnreconstructableError):
ray.get(oid)
with pytest.raises(ray.exceptions.RayTimeoutError):
ray.get(oid, timeout=0.1)
def _check_refcounts(expected):
@@ -18,7 +18,6 @@ logger = logging.getLogger(__name__)
@pytest.fixture
def one_worker_100MiB(request):
config = json.dumps({
"distributed_ref_counting_enabled": 1,
"object_store_full_max_retries": 2,
"task_retry_delay_ms": 0,
})
@@ -40,12 +39,8 @@ def _fill_object_store_and_get(oid, succeed=True, object_MiB=40,
if succeed:
ray.get(oid)
else:
if oid.is_direct_call_type():
with pytest.raises(ray.exceptions.RayTimeoutError):
ray.get(oid, timeout=0.1)
else:
with pytest.raises(ray.exceptions.UnreconstructableError):
ray.get(oid)
with pytest.raises(ray.exceptions.RayTimeoutError):
ray.get(oid, timeout=0.1)
# Test that an object containing object IDs within it pins the inner IDs
+1
View File
@@ -233,6 +233,7 @@ def run(run_or_experiment,
space = {"lr": tune.uniform(0, 1), "momentum": tune.uniform(0, 1)}
tune.run(my_trainable, config=space, stop={"training_iteration": 10})
"""
pass # XXX: force CI
trial_executor = trial_executor or RayTrialExecutor(
queue_trials=queue_trials,
reuse_actors=reuse_actors,
+1
View File
@@ -135,6 +135,7 @@ def create_parser(parser_creator=None):
def run(args, parser):
pass # XXX: force CI
if args.config_file:
with open(args.config_file) as f:
experiments = yaml.safe_load(f)
+8 -45
View File
@@ -61,7 +61,8 @@ constexpr uint8_t kCreatedByTaskBitsOffset = 15;
constexpr uint8_t kObjectTypeBitsOffset = 14;
/// The bit offset of the flag `TransportType` in a flags bytes.
constexpr uint8_t kTransportTypeBitsOffset = 11;
// TODO(edoakes): this isn't used anymore, should update ID layout.
// constexpr uint8_t kTransportTypeBitsOffset = 11;
/// The mask that is used to mask the flag `CreatedByTask`.
constexpr ObjectIDFlagsType kCreatedByTaskFlagBitMask = 0x1 << kCreatedByTaskBitsOffset;
@@ -71,7 +72,9 @@ constexpr ObjectIDFlagsType kCreatedByTaskFlagBitMask = 0x1 << kCreatedByTaskBit
constexpr ObjectIDFlagsType kObjectTypeFlagBitMask = 0x1 << kObjectTypeBitsOffset;
/// The mask that is used to mask 3 bits to indicate the type of transport.
constexpr ObjectIDFlagsType kTransportTypeFlagBitMask = 0x7 << kTransportTypeBitsOffset;
// TODO(edoakes): this isn't used anymore, should update ID layout.
// constexpr ObjectIDFlagsType kTransportTypeFlagBitMask = 0x7 <<
// kTransportTypeBitsOffset;
/// The implementations of helper functions.
inline void SetCreatedByTaskFlag(bool created_by_task, ObjectIDFlagsType *flags) {
@@ -86,14 +89,6 @@ inline void SetObjectTypeFlag(ObjectType object_type, ObjectIDFlagsType *flags)
*flags = (*flags bitor object_type_bits);
}
inline void SetTransportTypeFlag(uint8_t transport_type, ObjectIDFlagsType *flags) {
// TODO(ekl) we should be masking for all the SET operations in this file.
auto mask = static_cast<ObjectIDFlagsType>(1) << kTransportTypeBitsOffset;
const ObjectIDFlagsType transport_type_bits =
static_cast<ObjectIDFlagsType>(transport_type) << kTransportTypeBitsOffset;
*flags = ((*flags bitand ~mask) bitor transport_type_bits);
}
inline bool CreatedByTask(ObjectIDFlagsType flags) {
return ((flags bitand kCreatedByTaskFlagBitMask) >> kCreatedByTaskBitsOffset) != 0x0;
}
@@ -104,12 +99,6 @@ inline ObjectType GetObjectType(ObjectIDFlagsType flags) {
return static_cast<ObjectType>(object_type);
}
inline uint8_t GetTransportType(ObjectIDFlagsType flags) {
const ObjectIDFlagsType transport_type =
(flags bitand kTransportTypeFlagBitMask) >> kTransportTypeBitsOffset;
return static_cast<uint8_t>(transport_type);
}
} // namespace
template <typename T>
@@ -164,26 +153,6 @@ bool ObjectID::IsReturnObject() const {
return ::ray::GetObjectType(this->GetFlags()) == ObjectType::RETURN_OBJECT;
}
ObjectID ObjectID::WithTransportType(TaskTransportType transport_type) const {
ObjectID copy = ObjectID::FromBinary(Binary());
ObjectIDFlagsType flags = GetFlags();
SetTransportTypeFlag(static_cast<uint8_t>(transport_type), &flags);
std::memcpy(copy.id_ + TaskID::kLength, &flags, sizeof(flags));
return copy;
}
ObjectID ObjectID::WithPlasmaTransportType() const {
return WithTransportType(TaskTransportType::RAYLET);
}
ObjectID ObjectID::WithDirectTransportType() const {
return WithTransportType(TaskTransportType::DIRECT);
}
uint8_t ObjectID::GetTransportType() const {
return ::ray::GetTransportType(this->GetFlags());
}
// This code is from https://sites.google.com/site/murmurhash/
// and is public domain.
uint64_t MurmurHash64A(const void *key, int len, unsigned int seed) {
@@ -316,16 +285,13 @@ TaskID ObjectID::TaskId() const {
std::string(reinterpret_cast<const char *>(id_), TaskID::Size()));
}
ObjectID ObjectID::ForPut(const TaskID &task_id, ObjectIDIndexType put_index,
uint8_t transport_type) {
ObjectID ObjectID::ForPut(const TaskID &task_id, ObjectIDIndexType put_index) {
RAY_CHECK(put_index >= 1 && put_index <= kMaxObjectIndex) << "index=" << put_index;
ObjectIDFlagsType flags = 0x0000;
SetCreatedByTaskFlag(true, &flags);
SetObjectTypeFlag(ObjectType::PUT_OBJECT, &flags);
SetTransportTypeFlag(transport_type, &flags);
return GenerateObjectId(task_id.Binary(), flags, put_index);
}
@@ -335,15 +301,13 @@ ObjectIDIndexType ObjectID::ObjectIndex() const {
return index;
}
ObjectID ObjectID::ForTaskReturn(const TaskID &task_id, ObjectIDIndexType return_index,
uint8_t transport_type) {
ObjectID ObjectID::ForTaskReturn(const TaskID &task_id, ObjectIDIndexType return_index) {
RAY_CHECK(return_index >= 1 && return_index <= kMaxObjectIndex)
<< "index=" << return_index;
ObjectIDFlagsType flags = 0x0000;
SetCreatedByTaskFlag(true, &flags);
SetObjectTypeFlag(ObjectType::RETURN_OBJECT, &flags);
SetTransportTypeFlag(transport_type, &flags);
return GenerateObjectId(task_id.Binary(), flags, return_index);
}
@@ -364,8 +328,7 @@ ObjectID ObjectID::FromRandom() {
ObjectID ObjectID::ForActorHandle(const ActorID &actor_id) {
return ObjectID::ForTaskReturn(TaskID::ForActorCreationTask(actor_id),
/*return_index=*/1,
static_cast<int>(TaskTransportType::DIRECT));
/*return_index=*/1);
}
ObjectID ObjectID::GenerateObjectId(const std::string &task_id_binary,
+2 -40
View File
@@ -33,8 +33,6 @@
namespace ray {
enum class TaskTransportType { RAYLET, DIRECT };
class TaskID;
class WorkerID;
class UniqueID;
@@ -312,63 +310,27 @@ class ObjectID : public BaseID<ObjectID> {
/// \return True if this object is a return value of a task.
bool IsReturnObject() const;
/// Return if this is a direct actor call object.
///
/// \return True if this is a direct actor object return.
bool IsDirectCallType() const {
return GetTransportType() == static_cast<uint8_t>(TaskTransportType::DIRECT);
}
/// Return this object id with a changed transport type.
///
/// \return Copy of this object id with the specified transport type.
ObjectID WithTransportType(TaskTransportType transport_type) const;
/// Return this object id with the plasma transport type.
///
/// \return Copy of this object id with the plasma transport type.
ObjectID WithPlasmaTransportType() const;
/// Return this object id with the direct call transport type.
///
/// \return Copy of this object id with the direct call transport type.
ObjectID WithDirectTransportType() const;
/// Get the transport type of this object.
///
/// \return The type of the transport which is used to transfer this object.
uint8_t GetTransportType() const;
/// Compute the object ID of an object put by the task.
///
/// \param task_id The task ID of the task that created the object.
/// \param index What index of the object put in the task.
/// \param transport_type Which type of the transport that is used to
/// transfer this object.
///
/// \return The computed object ID.
static ObjectID ForPut(const TaskID &task_id, ObjectIDIndexType put_index,
uint8_t transport_type);
static ObjectID ForPut(const TaskID &task_id, ObjectIDIndexType put_index);
/// Compute the object ID of an object returned by the task.
///
/// \param task_id The task ID of the task that created the object.
/// \param return_index What index of the object returned by in the task.
/// \param transport_type Which type of the transport that is used to
/// transfer this object.
///
/// \return The computed object ID.
static ObjectID ForTaskReturn(const TaskID &task_id, ObjectIDIndexType return_index,
uint8_t transport_type);
static ObjectID ForTaskReturn(const TaskID &task_id, ObjectIDIndexType return_index);
/// Create an object id randomly.
///
/// Warning: this can duplicate IDs after a fork() call. We assume this
/// never happens.
///
/// \param transport_type Which type of the transport that is used to
/// transfer this object.
///
/// \return A random object id.
static ObjectID FromRandom();
+6 -9
View File
@@ -19,28 +19,25 @@
namespace ray {
void TestReturnObjectId(const TaskID &task_id, int64_t return_index,
uint8_t transport_type) {
void TestReturnObjectId(const TaskID &task_id, int64_t return_index) {
// Round trip test for computing the object ID for a task's return value,
// then computing the task ID that created the object.
ObjectID return_id = ObjectID::ForTaskReturn(task_id, return_index, transport_type);
ObjectID return_id = ObjectID::ForTaskReturn(task_id, return_index);
ASSERT_TRUE(return_id.CreatedByTask());
ASSERT_TRUE(return_id.IsReturnObject());
ASSERT_FALSE(return_id.IsPutObject());
ASSERT_EQ(return_id.TaskId(), task_id);
ASSERT_TRUE(transport_type == return_id.GetTransportType());
ASSERT_EQ(return_id.ObjectIndex(), return_index);
}
void TestPutObjectId(const TaskID &task_id, int64_t put_index) {
// Round trip test for computing the object ID for a task's put value, then
// computing the task ID that created the object.
ObjectID put_id = ObjectID::ForPut(task_id, put_index, 1);
ObjectID put_id = ObjectID::ForPut(task_id, put_index);
ASSERT_TRUE(put_id.CreatedByTask());
ASSERT_FALSE(put_id.IsReturnObject());
ASSERT_TRUE(put_id.IsPutObject());
ASSERT_EQ(put_id.TaskId(), task_id);
ASSERT_TRUE(1 == put_id.GetTransportType());
ASSERT_EQ(put_id.ObjectIndex(), put_index);
}
@@ -95,9 +92,9 @@ TEST(ObjectIDTest, TestObjectID) {
{
// test for return
TestReturnObjectId(default_task_id, 1, 2);
TestReturnObjectId(default_task_id, 2, 3);
TestReturnObjectId(default_task_id, ObjectID::kMaxObjectIndex, 4);
TestReturnObjectId(default_task_id, 1);
TestReturnObjectId(default_task_id, 2);
TestReturnObjectId(default_task_id, ObjectID::kMaxObjectIndex);
}
{
+3 -5
View File
@@ -105,10 +105,8 @@ size_t TaskSpecification::NumArgs() const { return message_->args_size(); }
size_t TaskSpecification::NumReturns() const { return message_->num_returns(); }
ObjectID TaskSpecification::ReturnId(size_t return_index,
TaskTransportType transport_type) const {
return ObjectID::ForTaskReturn(TaskId(), return_index + 1,
static_cast<uint8_t>(transport_type));
ObjectID TaskSpecification::ReturnId(size_t return_index) const {
return ObjectID::ForTaskReturn(TaskId(), return_index + 1);
}
bool TaskSpecification::ArgByRef(size_t arg_index) const {
@@ -239,7 +237,7 @@ ObjectID TaskSpecification::PreviousActorTaskDummyObjectId() const {
ObjectID TaskSpecification::ActorDummyObject() const {
RAY_CHECK(IsActorTask() || IsActorCreationTask());
return ReturnId(NumReturns() - 1, TaskTransportType::RAYLET);
return ReturnId(NumReturns() - 1);
}
int TaskSpecification::MaxActorConcurrency() const {
+1 -5
View File
@@ -74,11 +74,7 @@ class TaskSpecification : public MessageWrapper<rpc::TaskSpec> {
ObjectID ArgId(size_t arg_index, size_t id_index) const;
ObjectID ReturnId(size_t return_index, TaskTransportType transport_type) const;
ObjectID ReturnIdForPlasma(size_t return_index) const {
return ReturnId(return_index, TaskTransportType::RAYLET);
}
ObjectID ReturnId(size_t return_index) const;
const uint8_t *ArgData(size_t arg_index) const;
+3 -4
View File
@@ -55,7 +55,7 @@ ray::rpc::ActorHandle CreateInnerActorHandleFromActorTableData(
inner.mutable_actor_creation_task_function_descriptor()->CopyFrom(
actor_table_data.task_spec().function_descriptor());
ray::TaskSpecification task_spec(actor_table_data.task_spec());
inner.set_actor_cursor(task_spec.ReturnId(0, ray::TaskTransportType::DIRECT).Binary());
inner.set_actor_cursor(task_spec.ReturnId(0).Binary());
inner.set_extension_data(
actor_table_data.task_spec().actor_creation_task_spec().extension_data());
return inner;
@@ -85,9 +85,8 @@ void ActorHandle::SetActorTaskSpec(TaskSpecBuilder &builder, const ObjectID new_
absl::MutexLock guard(&mutex_);
// Build actor task spec.
const TaskID actor_creation_task_id = TaskID::ForActorCreationTask(GetActorID());
const ObjectID actor_creation_dummy_object_id = ObjectID::ForTaskReturn(
actor_creation_task_id, /*index=*/1,
/*transport_type=*/static_cast<int>(TaskTransportType::DIRECT));
const ObjectID actor_creation_dummy_object_id =
ObjectID::ForTaskReturn(actor_creation_task_id, /*index=*/1);
builder.SetActorTaskSpec(GetActorID(), actor_creation_dummy_object_id,
/*previous_actor_task_dummy_object_id=*/actor_cursor_,
task_counter_++);
+10 -41
View File
@@ -53,21 +53,7 @@ void BuildCommonTaskSpec(
// Compute return IDs.
return_ids->resize(num_returns);
for (size_t i = 0; i < num_returns; i++) {
(*return_ids)[i] = ObjectID::ForTaskReturn(
task_id, i + 1, static_cast<int>(ray::TaskTransportType::DIRECT));
}
}
// Group object ids according the the corresponding store providers.
void GroupObjectIdsByStoreProvider(const std::vector<ObjectID> &object_ids,
absl::flat_hash_set<ObjectID> *plasma_object_ids,
absl::flat_hash_set<ObjectID> *memory_object_ids) {
for (const auto &object_id : object_ids) {
if (object_id.IsDirectCallType()) {
memory_object_ids->insert(object_id);
} else {
plasma_object_ids->insert(object_id);
}
(*return_ids)[i] = ObjectID::ForTaskReturn(task_id, i + 1);
}
}
@@ -695,7 +681,6 @@ CoreWorker::GetAllReferenceCounts() const {
void CoreWorker::PromoteToPlasmaAndGetOwnershipInfo(const ObjectID &object_id,
TaskID *owner_id,
rpc::Address *owner_address) {
RAY_CHECK(object_id.IsDirectCallType());
auto value = memory_store_->GetOrPromoteToPlasma(object_id);
if (value) {
RAY_LOG(DEBUG) << "Storing object promoted to plasma " << object_id;
@@ -737,8 +722,7 @@ Status CoreWorker::Put(const RayObject &object,
const std::vector<ObjectID> &contained_object_ids,
ObjectID *object_id) {
*object_id = ObjectID::ForPut(worker_context_.GetCurrentTaskID(),
worker_context_.GetNextPutIndex(),
static_cast<uint8_t>(TaskTransportType::DIRECT));
worker_context_.GetNextPutIndex());
reference_counter_->AddOwnedObject(*object_id, contained_object_ids, GetCallerId(),
rpc_address_, CurrentCallSite(), object.GetSize(),
/*is_reconstructable=*/false,
@@ -781,16 +765,13 @@ Status CoreWorker::Create(const std::shared_ptr<Buffer> &metadata, const size_t
const std::vector<ObjectID> &contained_object_ids,
ObjectID *object_id, std::shared_ptr<Buffer> *data) {
*object_id = ObjectID::ForPut(worker_context_.GetCurrentTaskID(),
worker_context_.GetNextPutIndex(),
static_cast<uint8_t>(TaskTransportType::DIRECT));
worker_context_.GetNextPutIndex());
if (options_.is_local_mode) {
*data = std::make_shared<LocalMemoryBuffer>(data_size);
} else {
RAY_RETURN_NOT_OK(
plasma_store_provider_->Create(metadata, data_size, *object_id, data));
}
// Only add the object to the reference counter if it didn't already exist.
if (data) {
reference_counter_->AddOwnedObject(
@@ -839,8 +820,7 @@ Status CoreWorker::Get(const std::vector<ObjectID> &ids, const int64_t timeout_m
results->resize(ids.size(), nullptr);
absl::flat_hash_set<ObjectID> plasma_object_ids;
absl::flat_hash_set<ObjectID> memory_object_ids;
GroupObjectIdsByStoreProvider(ids, &plasma_object_ids, &memory_object_ids);
absl::flat_hash_set<ObjectID> memory_object_ids(ids.begin(), ids.end());
bool got_exception = false;
absl::flat_hash_map<ObjectID, std::shared_ptr<RayObject>> result_map;
@@ -952,22 +932,12 @@ Status CoreWorker::Wait(const std::vector<ObjectID> &ids, int num_objects,
}
absl::flat_hash_set<ObjectID> plasma_object_ids;
absl::flat_hash_set<ObjectID> memory_object_ids;
GroupObjectIdsByStoreProvider(ids, &plasma_object_ids, &memory_object_ids);
absl::flat_hash_set<ObjectID> memory_object_ids(ids.begin(), ids.end());
if (plasma_object_ids.size() + memory_object_ids.size() != ids.size()) {
if (memory_object_ids.size() != ids.size()) {
return Status::Invalid("Duplicate object IDs not supported in wait.");
}
// TODO(edoakes): this logic is not ideal, and will have to be addressed
// before we enable direct actor calls in the Python code. If we are waiting
// on a list of objects mixed between multiple store providers, we could
// easily end up in the situation where we're blocked waiting on one store
// provider while another actually has enough objects ready to fulfill
// 'num_objects'. This is partially addressed by trying them all once with
// a timeout of 0, but that does not address the situation where objects
// become available on the second store provider while waiting on the first.
absl::flat_hash_set<ObjectID> ready;
// Wait from both store providers with timeout set to 0. This is to avoid the case
// where we might use up the entire timeout on trying to get objects from one store
@@ -1525,7 +1495,7 @@ Status CoreWorker::ExecuteTask(const TaskSpecification &task_spec,
std::vector<ObjectID> return_ids;
for (size_t i = 0; i < task_spec.NumReturns(); i++) {
return_ids.push_back(task_spec.ReturnId(i, TaskTransportType::DIRECT));
return_ids.push_back(task_spec.ReturnId(i));
}
Status status;
@@ -1618,7 +1588,7 @@ void CoreWorker::ExecuteTaskLocalMode(const TaskSpecification &task_spec,
auto borrowed_refs = ReferenceCounter::ReferenceTableProto();
if (!task_spec.IsActorCreationTask()) {
for (size_t i = 0; i < task_spec.NumReturns(); i++) {
reference_counter_->AddOwnedObject(task_spec.ReturnId(i, TaskTransportType::DIRECT),
reference_counter_->AddOwnedObject(task_spec.ReturnId(i),
/*inner_ids=*/{}, GetCallerId(), rpc_address_,
CurrentCallSite(), -1,
/*is_reconstructable=*/false);
@@ -1645,10 +1615,10 @@ Status CoreWorker::BuildArgsForExecutor(const TaskSpecification &task,
if (task.ArgByRef(i)) {
// pass by reference.
RAY_CHECK(task.ArgIdCount(i) == 1);
// Direct call type objects that weren't inlined have been promoted to plasma.
// Objects that weren't inlined have been promoted to plasma.
// We need to put an OBJECT_IN_PLASMA error here so the subsequent call to Get()
// properly redirects to the plasma store.
if (task.ArgId(i, 0).IsDirectCallType() && !options_.is_local_mode) {
if (!options_.is_local_mode) {
RAY_UNUSED(memory_store_->Put(RayObject(rpc::ErrorType::OBJECT_IN_PLASMA),
task.ArgId(i, 0)));
}
@@ -2005,7 +1975,6 @@ void CoreWorker::YieldCurrentFiber(FiberEvent &event) {
void CoreWorker::GetAsync(const ObjectID &object_id, SetResultCallback success_callback,
SetResultCallback fallback_callback, void *python_future) {
RAY_CHECK(object_id.IsDirectCallType());
memory_store_->GetAsync(object_id, [python_future, success_callback, fallback_callback,
object_id](std::shared_ptr<RayObject> ray_object) {
if (ray_object->IsInPlasmaError()) {
+1 -1
View File
@@ -754,7 +754,7 @@ class CoreWorker : public rpc::CoreWorkerServiceHandler {
/// Perform async get from in-memory store.
///
/// \param[in] object_id The id to call get on. Assumes object_id.IsDirectCallType().
/// \param[in] object_id The id to call get on.
/// \param[in] success_callback The callback to use the result object.
/// \param[in] fallback_callback The callback to use when failed to get result.
/// \param[in] python_future the void* object to be passed to SetResultCallback
-1
View File
@@ -18,7 +18,6 @@ namespace ray {
void FutureResolver::ResolveFutureAsync(const ObjectID &object_id, const TaskID &owner_id,
const rpc::Address &owner_address) {
RAY_CHECK(object_id.IsDirectCallType());
absl::MutexLock lock(&mu_);
auto it = owner_clients_.find(owner_id);
if (it == owner_clients_.end()) {
+2 -2
View File
@@ -354,8 +354,8 @@ TEST_F(ReferenceCountTest, TestOwnerAddress) {
// Tests that the ref counts are properly integrated into the local
// object memory store.
TEST(MemoryStoreIntegrationTest, TestSimple) {
ObjectID id1 = ObjectID::FromRandom().WithDirectTransportType();
ObjectID id2 = ObjectID::FromRandom().WithDirectTransportType();
ObjectID id1 = ObjectID::FromRandom();
ObjectID id2 = ObjectID::FromRandom();
uint8_t data[] = {1, 2, 3, 4, 5, 6, 7, 8};
RayObject buffer(std::make_shared<LocalMemoryBuffer>(data, sizeof(data)), nullptr, {});
+4 -8
View File
@@ -48,8 +48,7 @@ void TaskManager::AddPendingTask(const TaskID &caller_id,
}
}
if (spec.IsActorTask()) {
const auto actor_creation_return_id =
spec.ActorCreationDummyObjectId().WithTransportType(TaskTransportType::DIRECT);
const auto actor_creation_return_id = spec.ActorCreationDummyObjectId();
task_deps.push_back(actor_creation_return_id);
}
reference_counter_->UpdateSubmittedTaskReferences(task_deps);
@@ -66,7 +65,7 @@ void TaskManager::AddPendingTask(const TaskID &caller_id,
// notify us via the WaitForRefRemoved RPC that we are now a borrower for
// the inner IDs. Note that this RPC can be received *before* the
// PushTaskReply.
reference_counter_->AddOwnedObject(spec.ReturnId(i, TaskTransportType::DIRECT),
reference_counter_->AddOwnedObject(spec.ReturnId(i),
/*inner_ids=*/{}, caller_id, caller_address,
call_site, -1, /*is_reconstructable=*/true);
}
@@ -378,8 +377,7 @@ void TaskManager::RemoveFinishedTaskReferences(
}
}
if (spec.IsActorTask()) {
const auto actor_creation_return_id =
spec.ActorCreationDummyObjectId().WithTransportType(TaskTransportType::DIRECT);
const auto actor_creation_return_id = spec.ActorCreationDummyObjectId();
plasma_dependencies.push_back(actor_creation_return_id);
}
@@ -445,9 +443,7 @@ void TaskManager::MarkPendingTaskFailed(const TaskID &task_id,
<< ", error_type: " << ErrorType_Name(error_type);
int64_t num_returns = spec.NumReturns();
for (int i = 0; i < num_returns; i++) {
const auto object_id = ObjectID::ForTaskReturn(
task_id, /*index=*/i + 1,
/*transport_type=*/static_cast<int>(TaskTransportType::DIRECT));
const auto object_id = ObjectID::ForTaskReturn(task_id, /*index=*/i + 1);
RAY_UNUSED(in_memory_store_->Put(RayObject(error_type), object_id));
}
+1 -1
View File
@@ -167,7 +167,7 @@ class TaskManager : public TaskFinisherInterface, public TaskResubmissionInterfa
size_t num_returns)
: spec(spec_arg), num_retries_left(num_retries_left_arg) {
for (size_t i = 0; i < num_returns; i++) {
reconstructable_return_ids.insert(spec.ReturnId(i, TaskTransportType::DIRECT));
reconstructable_return_ids.insert(spec.ReturnId(i));
}
}
/// The task spec. This is pinned as long as the following are true:
+4 -22
View File
@@ -425,8 +425,6 @@ void CoreWorkerTest::TestActorTask(std::unordered_map<std::string, double> &reso
RAY_CHECK_OK(driver.SubmitActorTask(actor_id, func, args, options, &return_ids));
ASSERT_EQ(return_ids.size(), 1);
ASSERT_TRUE(return_ids[0].IsReturnObject());
ASSERT_EQ(static_cast<TaskTransportType>(return_ids[0].GetTransportType()),
TaskTransportType::DIRECT);
std::vector<std::shared_ptr<ray::RayObject>> results;
RAY_CHECK_OK(driver.Get(return_ids, -1, &results));
@@ -801,14 +799,14 @@ TEST_F(SingleNodeTest, TestMemoryStoreProvider) {
std::vector<ObjectID> ids(buffers.size());
for (size_t i = 0; i < ids.size(); i++) {
ids[i] = ObjectID::FromRandom().WithDirectTransportType();
ids[i] = ObjectID::FromRandom();
RAY_CHECK(provider.Put(buffers[i], ids[i]));
}
absl::flat_hash_set<ObjectID> wait_ids(ids.begin(), ids.end());
absl::flat_hash_set<ObjectID> wait_results;
ObjectID nonexistent_id = ObjectID::FromRandom().WithDirectTransportType();
ObjectID nonexistent_id = ObjectID::FromRandom();
WorkerContext ctx(WorkerType::WORKER, WorkerID::FromRandom(), JobID::Nil());
wait_ids.insert(nonexistent_id);
RAY_CHECK_OK(provider.Wait(wait_ids, ids.size() + 1, 100, ctx, &wait_results));
@@ -858,9 +856,9 @@ TEST_F(SingleNodeTest, TestMemoryStoreProvider) {
std::vector<ObjectID> ready_ids(buffers.size());
std::vector<ObjectID> unready_ids(buffers.size());
for (size_t i = 0; i < unready_ids.size(); i++) {
ready_ids[i] = ObjectID::FromRandom().WithDirectTransportType();
ready_ids[i] = ObjectID::FromRandom();
RAY_CHECK(provider.Put(buffers[i], ready_ids[i]));
unready_ids[i] = ObjectID::FromRandom().WithDirectTransportType();
unready_ids[i] = ObjectID::FromRandom();
}
auto thread_func = [&unready_ids, &provider, &buffers]() {
@@ -937,22 +935,6 @@ TEST_F(SingleNodeTest, TestObjectInterface) {
ASSERT_EQ(*results[i]->GetMetadata(), *buffers[i].GetMetadata());
}
// Test Get() returns early when it encounters an error.
std::vector<ObjectID> ids_with_exception(ids.begin(), ids.end());
ids_with_exception.push_back(ObjectID::FromRandom());
std::vector<RayObject> buffers_with_exception(buffers.begin(), buffers.end());
std::string error_string = std::to_string(ray::rpc::TASK_EXECUTION_EXCEPTION);
char error_buffer[error_string.size()];
size_t len = error_string.copy(error_buffer, error_string.size(), 0);
buffers_with_exception.emplace_back(
nullptr,
std::make_shared<LocalMemoryBuffer>(reinterpret_cast<uint8_t *>(error_buffer), len),
std::vector<ObjectID>());
RAY_CHECK_OK(
core_worker.Put(buffers_with_exception.back(), {}, ids_with_exception.back()));
RAY_CHECK_OK(core_worker.Get(ids_with_exception, -1, &results));
// Test Wait().
ObjectID non_existent_id = ObjectID::FromRandom();
std::vector<ObjectID> all_ids(ids);
@@ -149,8 +149,8 @@ TEST_F(DirectActorSubmitterTest, TestDependencies) {
ASSERT_EQ(worker_client_->callbacks.size(), 0);
// Create two tasks for the actor with different arguments.
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
ObjectID obj2 = ObjectID::FromRandom();
auto task1 = CreateActorTaskHelper(actor_id, worker_id, 0);
task1.GetMutableMessage().add_args()->add_object_ids(obj1.Binary());
auto task2 = CreateActorTaskHelper(actor_id, worker_id, 1);
@@ -181,8 +181,8 @@ TEST_F(DirectActorSubmitterTest, TestOutOfOrderDependencies) {
ASSERT_EQ(worker_client_->callbacks.size(), 0);
// Create two tasks for the actor with different arguments.
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
ObjectID obj2 = ObjectID::FromRandom();
auto task1 = CreateActorTaskHelper(actor_id, worker_id, 0);
task1.GetMutableMessage().add_args()->add_object_ids(obj1.Binary());
auto task2 = CreateActorTaskHelper(actor_id, worker_id, 1);
@@ -216,7 +216,7 @@ TEST_F(DirectActorSubmitterTest, TestActorDead) {
// Create two tasks for the actor. One depends on an object that is not yet available.
auto task1 = CreateActorTaskHelper(actor_id, worker_id, 0);
ObjectID obj = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj = ObjectID::FromRandom();
auto task2 = CreateActorTaskHelper(actor_id, worker_id, 1);
task2.GetMutableMessage().add_args()->add_object_ids(obj.Binary());
ASSERT_TRUE(submitter_.SubmitTask(task1).ok());
@@ -172,8 +172,8 @@ TEST(TestMemoryStore, TestPromoteToPlasma) {
bool num_plasma_puts = 0;
auto mem = std::make_shared<CoreWorkerMemoryStore>(
[&](const RayObject &obj, const ObjectID &obj_id) { num_plasma_puts += 1; });
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
ObjectID obj2 = ObjectID::FromRandom();
auto data = GenerateRandomObject();
ASSERT_TRUE(mem->Put(*data, obj1));
@@ -203,26 +203,11 @@ TEST(LocalDependencyResolverTest, TestNoDependencies) {
ASSERT_EQ(task_finisher->num_inlined_dependencies, 0);
}
TEST(LocalDependencyResolverTest, TestIgnorePlasmaDependencies) {
auto store = std::make_shared<CoreWorkerMemoryStore>();
auto task_finisher = std::make_shared<MockTaskFinisher>();
LocalDependencyResolver resolver(store, task_finisher);
ObjectID obj1 = ObjectID::FromRandom();
TaskSpecification task;
task.GetMutableMessage().add_args()->add_object_ids(obj1.Binary());
bool ok = false;
resolver.ResolveDependencies(task, [&ok]() { ok = true; });
// We ignore and don't block on plasma dependencies.
ASSERT_TRUE(ok);
ASSERT_EQ(resolver.NumPendingTasks(), 0);
ASSERT_EQ(task_finisher->num_inlined_dependencies, 0);
}
TEST(LocalDependencyResolverTest, TestHandlePlasmaPromotion) {
auto store = std::make_shared<CoreWorkerMemoryStore>();
auto task_finisher = std::make_shared<MockTaskFinisher>();
LocalDependencyResolver resolver(store, task_finisher);
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
std::string meta = std::to_string(static_cast<int>(rpc::ErrorType::OBJECT_IN_PLASMA));
auto metadata = const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(meta.data()));
auto meta_buffer = std::make_shared<LocalMemoryBuffer>(metadata, meta.size());
@@ -230,13 +215,11 @@ TEST(LocalDependencyResolverTest, TestHandlePlasmaPromotion) {
ASSERT_TRUE(store->Put(data, obj1));
TaskSpecification task;
task.GetMutableMessage().add_args()->add_object_ids(obj1.Binary());
ASSERT_TRUE(task.ArgId(0, 0).IsDirectCallType());
bool ok = false;
resolver.ResolveDependencies(task, [&ok]() { ok = true; });
ASSERT_TRUE(ok);
ASSERT_TRUE(task.ArgByRef(0));
// Checks that the object id is still a direct call id.
ASSERT_TRUE(task.ArgId(0, 0).IsDirectCallType());
ASSERT_EQ(resolver.NumPendingTasks(), 0);
ASSERT_EQ(task_finisher->num_inlined_dependencies, 0);
}
@@ -245,8 +228,8 @@ TEST(LocalDependencyResolverTest, TestInlineLocalDependencies) {
auto store = std::make_shared<CoreWorkerMemoryStore>();
auto task_finisher = std::make_shared<MockTaskFinisher>();
LocalDependencyResolver resolver(store, task_finisher);
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
ObjectID obj2 = ObjectID::FromRandom();
auto data = GenerateRandomObject();
// Ensure the data is already present in the local store.
ASSERT_TRUE(store->Put(*data, obj1));
@@ -270,8 +253,8 @@ TEST(LocalDependencyResolverTest, TestInlinePendingDependencies) {
auto store = std::make_shared<CoreWorkerMemoryStore>();
auto task_finisher = std::make_shared<MockTaskFinisher>();
LocalDependencyResolver resolver(store, task_finisher);
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
ObjectID obj2 = ObjectID::FromRandom();
auto data = GenerateRandomObject();
TaskSpecification task;
task.GetMutableMessage().add_args()->add_object_ids(obj1.Binary());
@@ -298,9 +281,9 @@ TEST(LocalDependencyResolverTest, TestInlinedObjectIds) {
auto store = std::make_shared<CoreWorkerMemoryStore>();
auto task_finisher = std::make_shared<MockTaskFinisher>();
LocalDependencyResolver resolver(store, task_finisher);
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj3 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
ObjectID obj2 = ObjectID::FromRandom();
ObjectID obj3 = ObjectID::FromRandom();
auto data = GenerateRandomObject({obj3});
TaskSpecification task;
task.GetMutableMessage().add_args()->add_object_ids(obj1.Binary());
@@ -859,10 +842,10 @@ TEST(DirectTaskTransportTest, TestSchedulingKeys) {
BuildTaskSpec(resources1, descriptor1),
BuildTaskSpec(resources1, descriptor2));
ObjectID direct1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID direct2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID plasma1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID plasma2 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID direct1 = ObjectID::FromRandom();
ObjectID direct2 = ObjectID::FromRandom();
ObjectID plasma1 = ObjectID::FromRandom();
ObjectID plasma2 = ObjectID::FromRandom();
// Ensure the data is already present in the local store for direct call objects.
auto data = GenerateRandomObject();
ASSERT_TRUE(store->Put(*data, direct1));
@@ -1030,7 +1013,7 @@ TEST(DirectTaskTransportTest, TestKillResolvingTask) {
ray::FunctionDescriptor empty_descriptor =
ray::FunctionDescriptorBuilder::BuildPython("", "", "", "");
TaskSpecification task = BuildTaskSpec(empty_resources, empty_descriptor);
ObjectID obj1 = ObjectID::FromRandom().WithTransportType(TaskTransportType::DIRECT);
ObjectID obj1 = ObjectID::FromRandom();
task.GetMutableMessage().add_args()->add_object_ids(obj1.Binary());
ASSERT_TRUE(submitter.SubmitTask(task).ok());
ASSERT_EQ(task_finisher->num_inlined_dependencies, 0);
+11 -11
View File
@@ -78,7 +78,7 @@ TEST_F(TaskManagerTest, TestTaskSuccess) {
manager_.AddPendingTask(caller_id, caller_address, spec, "");
ASSERT_TRUE(manager_.IsTaskPending(spec.TaskId()));
ASSERT_EQ(reference_counter_->NumObjectIDsInScope(), 3);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
WorkerContext ctx(WorkerType::WORKER, WorkerID::FromRandom(), JobID::FromInt(0));
rpc::PushTaskReply reply;
@@ -118,7 +118,7 @@ TEST_F(TaskManagerTest, TestTaskFailure) {
manager_.AddPendingTask(caller_id, caller_address, spec, "");
ASSERT_TRUE(manager_.IsTaskPending(spec.TaskId()));
ASSERT_EQ(reference_counter_->NumObjectIDsInScope(), 3);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
WorkerContext ctx(WorkerType::WORKER, WorkerID::FromRandom(), JobID::FromInt(0));
auto error = rpc::ErrorType::WORKER_DIED;
@@ -154,7 +154,7 @@ TEST_F(TaskManagerTest, TestTaskReconstruction) {
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
ASSERT_TRUE(manager_.IsTaskPending(spec.TaskId()));
ASSERT_EQ(reference_counter_->NumObjectIDsInScope(), 3);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
WorkerContext ctx(WorkerType::WORKER, WorkerID::FromRandom(), JobID::FromInt(0));
auto error = rpc::ErrorType::WORKER_DIED;
@@ -197,7 +197,7 @@ TEST_F(TaskManagerTest, TestTaskKill) {
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
ASSERT_TRUE(manager_.IsTaskPending(spec.TaskId()));
ASSERT_EQ(reference_counter_->NumObjectIDsInScope(), 1);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
WorkerContext ctx(WorkerType::WORKER, WorkerID::FromRandom(), JobID::FromInt(0));
manager_.MarkTaskCanceled(spec.TaskId());
@@ -224,7 +224,7 @@ TEST_F(TaskManagerTest, TestLineageEvicted) {
int num_retries = 3;
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
rpc::PushTaskReply reply;
auto return_object = reply.add_return_objects();
return_object->set_object_id(return_id.Binary());
@@ -260,7 +260,7 @@ TEST_F(TaskManagerLineageTest, TestLineagePinned) {
ASSERT_FALSE(manager_.IsTaskPending(spec.TaskId()));
int num_retries = 3;
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
reference_counter_->AddLocalReference(return_id, "");
ASSERT_TRUE(manager_.IsTaskPending(spec.TaskId()));
ASSERT_EQ(reference_counter_->NumObjectIDsInScope(), 3);
@@ -300,7 +300,7 @@ TEST_F(TaskManagerLineageTest, TestDirectObjectNoLineage) {
ASSERT_FALSE(manager_.IsTaskPending(spec.TaskId()));
int num_retries = 3;
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
reference_counter_->AddLocalReference(return_id, "");
ASSERT_TRUE(manager_.IsTaskPending(spec.TaskId()));
ASSERT_EQ(reference_counter_->NumObjectIDsInScope(), 3);
@@ -335,7 +335,7 @@ TEST_F(TaskManagerLineageTest, TestLineagePinnedOutOfOrder) {
ASSERT_FALSE(manager_.IsTaskPending(spec.TaskId()));
int num_retries = 3;
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
reference_counter_->AddLocalReference(return_id, "");
ASSERT_TRUE(manager_.IsTaskPending(spec.TaskId()));
ASSERT_EQ(reference_counter_->NumObjectIDsInScope(), 3);
@@ -376,7 +376,7 @@ TEST_F(TaskManagerLineageTest, TestRecursiveLineagePinned) {
auto spec = CreateTaskHelper(1, {dep});
int num_retries = 3;
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
reference_counter_->AddLocalReference(return_id, "");
// The task completes.
@@ -418,7 +418,7 @@ TEST_F(TaskManagerLineageTest, TestRecursiveDirectObjectNoLineage) {
auto spec = CreateTaskHelper(1, {dep});
int num_retries = 3;
manager_.AddPendingTask(caller_id, caller_address, spec, "", num_retries);
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
reference_counter_->AddLocalReference(return_id, "");
// The task completes.
@@ -470,7 +470,7 @@ TEST_F(TaskManagerLineageTest, TestResubmitTask) {
ASSERT_EQ(num_retries_, 0);
// The task completes.
auto return_id = spec.ReturnId(0, TaskTransportType::DIRECT);
auto return_id = spec.ReturnId(0);
reference_counter_->AddLocalReference(return_id, "");
rpc::PushTaskReply reply;
auto return_object = reply.add_return_objects();
@@ -65,8 +65,6 @@ void InlineDependencies(
inlined_dependency_ids->push_back(id);
}
found++;
} else {
RAY_CHECK(!id.IsDirectCallType());
}
}
}
@@ -81,10 +79,7 @@ void LocalDependencyResolver::ResolveDependencies(TaskSpecification &task,
auto count = task.ArgIdCount(i);
if (count > 0) {
RAY_CHECK(count <= 1) << "multi args not implemented";
const auto &id = task.ArgId(i, 0);
if (id.IsDirectCallType()) {
local_dependencies.emplace(id, nullptr);
}
local_dependencies.emplace(task.ArgId(i, 0), nullptr);
}
}
if (local_dependencies.empty()) {
@@ -315,9 +315,7 @@ void CoreWorkerDirectTaskReceiver::HandlePushTask(
if (objects_valid) {
for (size_t i = 0; i < return_objects.size(); i++) {
auto return_object = reply->add_return_objects();
ObjectID id = ObjectID::ForTaskReturn(
task_spec.TaskId(), /*index=*/i + 1,
/*transport_type=*/static_cast<int>(TaskTransportType::DIRECT));
ObjectID id = ObjectID::ForTaskReturn(task_spec.TaskId(), /*index=*/i + 1);
return_object->set_object_id(id.Binary());
// The object is nullptr if it already existed in the object store.
+4 -4
View File
@@ -225,7 +225,7 @@ std::vector<ObjectID> InsertTaskChain(LineageCache &lineage_cache,
inserted_tasks.push_back(task);
arguments.clear();
for (size_t j = 0; j < task.GetTaskSpecification().NumReturns(); j++) {
arguments.push_back(task.GetTaskSpecification().ReturnIdForPlasma(j));
arguments.push_back(task.GetTaskSpecification().ReturnId(j));
}
}
return arguments;
@@ -379,7 +379,7 @@ TEST_F(LineageCacheTest, TestEvictChain) {
for (int i = 0; i < 3; i++) {
auto task = ExampleTask(arguments, 1);
tasks.push_back(task);
arguments = {task.GetTaskSpecification().ReturnIdForPlasma(0)};
arguments = {task.GetTaskSpecification().ReturnId(0)};
}
Lineage uncommitted_lineage;
@@ -435,7 +435,7 @@ TEST_F(LineageCacheTest, TestEvictManyParents) {
for (int i = 0; i < 10; i++) {
auto task = ExampleTask({}, 1);
parent_tasks.push_back(task);
arguments.push_back(task.GetTaskSpecification().ReturnIdForPlasma(0));
arguments.push_back(task.GetTaskSpecification().ReturnId(0));
auto lineage = CreateSingletonLineage(task);
lineage_cache_->AddUncommittedLineage(task.GetTaskSpecification().TaskId(), lineage);
}
@@ -595,7 +595,7 @@ TEST_F(LineageCacheTest, TestEvictionUncommittedChildren) {
// Add more tasks to the lineage cache that will remain local. Each of these
// tasks is dependent one of the tasks that was forwarded above.
for (const auto &task : tasks) {
auto return_id = task.GetTaskSpecification().ReturnIdForPlasma(0);
auto return_id = task.GetTaskSpecification().ReturnId(0);
auto dependent_task = ExampleTask({return_id}, 1);
auto lineage = CreateSingletonLineage(dependent_task);
lineage_cache_->AddUncommittedLineage(dependent_task.GetTaskSpecification().TaskId(),
+2 -2
View File
@@ -2058,7 +2058,7 @@ void NodeManager::TreatTaskAsFailed(const Task &task, const ErrorType &error_typ
// Determine which IDs should be marked as failed.
std::vector<plasma::ObjectID> objects_to_fail;
for (int64_t i = 0; i < num_returns; i++) {
objects_to_fail.push_back(spec.ReturnId(i, TaskTransportType::RAYLET).ToPlasmaId());
objects_to_fail.push_back(spec.ReturnId(i).ToPlasmaId());
}
const JobID job_id = task.GetTaskSpecification().JobId();
MarkObjectsAsFailed(error_type, objects_to_fail, job_id);
@@ -2110,7 +2110,7 @@ void NodeManager::TreatTaskAsFailedIfLost(const Task &task) {
// lookup callbacks are fired.
auto task_marked_as_failed = std::make_shared<bool>(false);
for (int64_t i = 0; i < num_returns; i++) {
const ObjectID object_id = spec.ReturnId(i, TaskTransportType::RAYLET);
const ObjectID object_id = spec.ReturnId(i);
// Lookup the return value's locations.
RAY_CHECK_OK(object_directory_->LookupLocations(
object_id, [this, task_marked_as_failed, task](
+9 -18
View File
@@ -281,8 +281,7 @@ class ReconstructionPolicyTest : public ::testing::Test {
TEST_F(ReconstructionPolicyTest, TestReconstructionSimple) {
TaskID task_id = ForNormalTask();
ObjectID object_id =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id = ObjectID::ForTaskReturn(task_id, /*index=*/1);
// Listen for an object.
reconstruction_policy_->ListenAndMaybeReconstruct(object_id);
@@ -300,8 +299,7 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionSimple) {
TEST_F(ReconstructionPolicyTest, TestReconstructionEvicted) {
TaskID task_id = ForNormalTask();
ObjectID object_id =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id = ObjectID::ForTaskReturn(task_id, /*index=*/1);
mock_object_directory_->SetObjectLocations(object_id, {ClientID::FromRandom()});
// Listen for both objects.
@@ -324,8 +322,7 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionEvicted) {
TEST_F(ReconstructionPolicyTest, TestReconstructionObjectLost) {
TaskID task_id = ForNormalTask();
ObjectID object_id =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id = ObjectID::ForTaskReturn(task_id, /*index=*/1);
ClientID client_id = ClientID::FromRandom();
mock_object_directory_->SetObjectLocations(object_id, {client_id});
@@ -349,10 +346,8 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionObjectLost) {
TEST_F(ReconstructionPolicyTest, TestDuplicateReconstruction) {
// Create two object IDs produced by the same task.
TaskID task_id = ForNormalTask();
ObjectID object_id1 =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id2 =
ObjectID::ForTaskReturn(task_id, /*index=*/2, /*transport_type=*/0);
ObjectID object_id1 = ObjectID::ForTaskReturn(task_id, /*index=*/1);
ObjectID object_id2 = ObjectID::ForTaskReturn(task_id, /*index=*/2);
// Listen for both objects.
reconstruction_policy_->ListenAndMaybeReconstruct(object_id1);
@@ -371,8 +366,7 @@ TEST_F(ReconstructionPolicyTest, TestDuplicateReconstruction) {
TEST_F(ReconstructionPolicyTest, TestReconstructionSuppressed) {
TaskID task_id = ForNormalTask();
ObjectID object_id =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id = ObjectID::ForTaskReturn(task_id, /*index=*/1);
// Run the test for much longer than the reconstruction timeout.
int64_t test_period = 2 * reconstruction_timeout_ms_;
@@ -399,8 +393,7 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionSuppressed) {
TEST_F(ReconstructionPolicyTest, TestReconstructionContinuallySuppressed) {
TaskID task_id = ForNormalTask();
ObjectID object_id =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id = ObjectID::ForTaskReturn(task_id, /*index=*/1);
// Listen for an object.
reconstruction_policy_->ListenAndMaybeReconstruct(object_id);
@@ -428,8 +421,7 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionContinuallySuppressed) {
TEST_F(ReconstructionPolicyTest, TestReconstructionCanceled) {
TaskID task_id = ForNormalTask();
ObjectID object_id =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id = ObjectID::ForTaskReturn(task_id, /*index=*/1);
// Listen for an object.
reconstruction_policy_->ListenAndMaybeReconstruct(object_id);
@@ -455,8 +447,7 @@ TEST_F(ReconstructionPolicyTest, TestReconstructionCanceled) {
TEST_F(ReconstructionPolicyTest, TestSimultaneousReconstructionSuppressed) {
TaskID task_id = ForNormalTask();
ObjectID object_id =
ObjectID::ForTaskReturn(task_id, /*index=*/1, /*transport_type=*/0);
ObjectID object_id = ObjectID::ForTaskReturn(task_id, /*index=*/1);
// Log a reconstruction attempt to simulate a different node attempting the
// reconstruction first. This should suppress this node's first attempt at
@@ -130,7 +130,7 @@ std::vector<Task> MakeTaskChain(int chain_size,
task_chain.push_back(task);
arguments.clear();
for (size_t j = 0; j < task.GetTaskSpecification().NumReturns(); j++) {
arguments.push_back(task.GetTaskSpecification().ReturnIdForPlasma(j));
arguments.push_back(task.GetTaskSpecification().ReturnId(j));
}
}
return task_chain;
@@ -280,7 +280,7 @@ TEST_F(TaskDependencyManagerTest, TestTaskChain) {
auto task = tasks.front();
tasks.erase(tasks.begin());
TaskID task_id = task.GetTaskSpecification().TaskId();
auto return_id = task.GetTaskSpecification().ReturnIdForPlasma(0);
auto return_id = task.GetTaskSpecification().ReturnId(0);
task_dependency_manager_.UnsubscribeGetDependencies(task_id);
// Simulate the object notifications for the task's return values.
@@ -303,8 +303,7 @@ TEST_F(TaskDependencyManagerTest, TestTaskChain) {
TEST_F(TaskDependencyManagerTest, TestDependentPut) {
// Create a task with 3 arguments.
auto task1 = ExampleTask({}, 0);
ObjectID put_id = ObjectID::ForPut(task1.GetTaskSpecification().TaskId(), /*index=*/1,
/*transport_type=*/0);
ObjectID put_id = ObjectID::ForPut(task1.GetTaskSpecification().TaskId(), /*index=*/1);
auto task2 = ExampleTask({put_id}, 0);
// No objects have been registered in the task dependency manager, so the put
@@ -340,7 +339,7 @@ TEST_F(TaskDependencyManagerTest, TestTaskForwarding) {
// Get the first task.
const auto task = tasks.front();
TaskID task_id = task.GetTaskSpecification().TaskId();
ObjectID return_id = task.GetTaskSpecification().ReturnIdForPlasma(0);
ObjectID return_id = task.GetTaskSpecification().ReturnId(0);
// Simulate forwarding the first task to a remote node.
task_dependency_manager_.UnsubscribeGetDependencies(task_id);
// The object returned by the first task should be considered remote once we
@@ -484,7 +483,7 @@ TEST_F(TaskDependencyManagerTest, TestRemoveTasksAndRelatedObjects) {
// runnable.
auto task = tasks.front();
TaskID task_id = task.GetTaskSpecification().TaskId();
auto return_id = task.GetTaskSpecification().ReturnIdForPlasma(0);
auto return_id = task.GetTaskSpecification().ReturnId(0);
task_dependency_manager_.UnsubscribeGetDependencies(task_id);
// Simulate the object notifications for the task's return values.
auto ready_tasks = task_dependency_manager_.HandleObjectLocal(return_id);
@@ -509,7 +508,7 @@ TEST_F(TaskDependencyManagerTest, TestRemoveTasksAndRelatedObjects) {
// Simulate the object notifications for the second task's return values.
// Make sure that this does not return the third task, which should have been
// removed.
return_id = tasks[1].GetTaskSpecification().ReturnIdForPlasma(0);
return_id = tasks[1].GetTaskSpecification().ReturnId(0);
ready_tasks = task_dependency_manager_.HandleObjectLocal(return_id);
ASSERT_TRUE(ready_tasks.empty());
}