mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:53:18 +08:00
Use one memory mapped file for plasma (#3871)
This commit is contained in:
committed by
Robert Nishihara
parent
d2b6db3db1
commit
3bb65677dc
+1
-1
@@ -29,7 +29,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
<version>0.10.0</version>
|
||||
<version>0.13.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.ruedigermoeller</groupId>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.ray.runtime.objectstore;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.apache.arrow.plasma.ObjectStoreLink;
|
||||
import org.apache.arrow.plasma.ObjectStoreLink.ObjectStoreData;
|
||||
import org.ray.api.id.UniqueId;
|
||||
import org.ray.runtime.RayDevRuntime;
|
||||
import org.ray.runtime.raylet.MockRayletClient;
|
||||
@@ -57,12 +59,18 @@ public class MockObjectStore implements ObjectStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> wait(byte[][] objectIds, int timeoutMs, int numReturns) {
|
||||
ArrayList<byte[]> rets = new ArrayList<>();
|
||||
public List<ObjectStoreData> get(byte[][] objectIds, int timeoutMs) {
|
||||
ArrayList<ObjectStoreData> rets = new ArrayList<>();
|
||||
// TODO(yuhguo): make ObjectStoreData's constructor public.
|
||||
for (byte[] objId : objectIds) {
|
||||
//tod test
|
||||
if (data.containsKey(new UniqueId(objId))) {
|
||||
rets.add(objId);
|
||||
UniqueId uniqueId = new UniqueId(objId);
|
||||
try {
|
||||
Constructor<ObjectStoreData> constructor = ObjectStoreData.class.getConstructor(
|
||||
byte[].class, byte[].class);
|
||||
constructor.setAccessible(true);
|
||||
rets.add(constructor.newInstance(metadata.get(uniqueId), data.get(uniqueId)));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return rets;
|
||||
@@ -73,11 +81,6 @@ public class MockObjectStore implements ObjectStoreLink {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetch(byte[][] objectIds) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long evict(long numBytes) {
|
||||
return 0;
|
||||
@@ -89,8 +92,12 @@ public class MockObjectStore implements ObjectStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(byte[] objectId) {
|
||||
public void delete(byte[] objectId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(byte[] objectId) {
|
||||
return data.containsKey(new UniqueId(objectId));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.arrow.plasma.ObjectStoreLink;
|
||||
import org.apache.arrow.plasma.PlasmaClient;
|
||||
import org.apache.arrow.plasma.exceptions.DuplicateObjectException;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.ray.api.exception.RayException;
|
||||
import org.ray.api.id.UniqueId;
|
||||
@@ -12,6 +13,8 @@ import org.ray.runtime.RayDevRuntime;
|
||||
import org.ray.runtime.config.RunMode;
|
||||
import org.ray.runtime.util.Serializer;
|
||||
import org.ray.runtime.util.UniqueIdUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Object store proxy, which handles serialization and deserialization, and utilize a {@code
|
||||
@@ -19,6 +22,8 @@ import org.ray.runtime.util.UniqueIdUtil;
|
||||
*/
|
||||
public class ObjectStoreProxy {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ObjectStoreProxy.class);
|
||||
|
||||
private static final int GET_TIMEOUT_MS = 1000;
|
||||
|
||||
private final AbstractRayRuntime runtime;
|
||||
@@ -82,11 +87,19 @@ public class ObjectStoreProxy {
|
||||
}
|
||||
|
||||
public void put(UniqueId id, Object obj, Object metadata) {
|
||||
objectStore.get().put(id.getBytes(), Serializer.encode(obj), Serializer.encode(metadata));
|
||||
try {
|
||||
objectStore.get().put(id.getBytes(), Serializer.encode(obj), Serializer.encode(metadata));
|
||||
} catch (DuplicateObjectException e) {
|
||||
LOGGER.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void putSerialized(UniqueId id, byte[] obj, byte[] metadata) {
|
||||
objectStore.get().put(id.getBytes(), obj, metadata);
|
||||
try {
|
||||
objectStore.get().put(id.getBytes(), obj, metadata);
|
||||
} catch (DuplicateObjectException e) {
|
||||
LOGGER.warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public enum GetStatus {
|
||||
|
||||
Reference in New Issue
Block a user