Open onegoldfish opened 2 years ago
@wumuzi520 could you take a look of this issue?
@wumuzi520 could you take a look of this issue?
Okey, let me have a look. @jovany-wang Please take a look too.
Does it happen in JDK11 without JEP? I'm not sure if it's related to JDK11 or JEP. If it's related to JDK11, I think we should fix it, otherwise, we don't have the bandwidth to port Ray cross-languages invocation on JEP runtime.
I read the part of Java calling python in ray. It seems that there are some limitations
BTW, could you tell what the limits you met?
Does it happen in JDK11 without JEP?
No, it doesn't happen without JEP. The author of JEP said that JEP didn't use the sun.reflect.Reflection.getCallerClass
, I don't know where this warning came from. If you think this problem is not ray related, please tell me.
As for the Cross-language in ray, I just see that there are not many serializable types in the document, which may not be convenient for use. There is no problem at present
@onegoldfish So could you give a reproduction script without JEP ?
Rich types in Ray serialization will be supported in this REP https://github.com/ray-project/enhancements/pull/6
If your issue is not urgent, maybe it's better to use Ray native cross language invocation.
I just use demo in https://docs.ray.io/en/master/ray-overview/index.html#ray-core-quick-start, the warning doesn't happen. Thank you for your reply. If Ray native cross language can meet the demand, I will give priority to it. Thank you and your team for the optimization
@onegoldfish It's ok. So I'm closing this issue, and feel free to file a new issue if you have any other problem.
@jovany-wang When I use pure Java without JEP, the warning happened again.
package org.example;
import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import static java.lang.Thread.sleep;
public class JavaRayTask {
public static final Logger log= LoggerFactory.getLogger("JavaTaskO");
public static Integer square(Integer x) throws InterruptedException {
log.info("JavaTask quare start ,input is $x, will return ${x*x}");
sleep(500);
return x*x;}
public static Integer sprint()
{
log.info("JavaTask sprint start ,no input");
Integer result =new Random().nextInt();
log.info("JavaTask sprint end ,return: $result");
return result;
}
public static void main (String[] args){
Ray.init();
Integer count= Integer.valueOf(args[0]);
List<ObjectRef<Integer>> results = new LinkedList<>();
// val results =mutableListOf<Int>()
long start =System.currentTimeMillis();
for (int i=0; i<count;i++ ){
log.info("--- {} times loop begin start------",i);
ObjectRef<Integer> step = Ray.task(JavaRayTask::sprint).remote();
log.info("step 1 return:{}",step);
ObjectRef<Integer> result= Ray.task(JavaRayTask::square,i).remote();
log.info ("---{} times loop end , the result is {}------",i, result);
results.add(step);
results.add(result);
}
log.info("---print result List: {}------", Ray.get(results));
long end= System.currentTimeMillis();
log.info("cost time: end-start={}", end-start);
}
}
the outputs are as follow:
java -cp testRayJavaNoJEP.jar -Dray.address=10.50.219.20:6379 -Dray.job.code-search-path=/home/ccc org.example.JavaRayTask 5
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
[2022-11-25 18:44:10,069 I 261465 261466] logging.cc:230: Set ray log level from environment variable RAY_BACKEND_LOG_LEVEL to -1
2022-11-25 18:44:10,081 INFO JavaTaskO [main]: --- 0 times loop begin start------
2022-11-25 18:44:10,123 INFO JavaTaskO [main]: step 1 return:ObjectRef(52803897c098a351ffffffffffffffffffffffff2200000001000000)
2022-11-25 18:44:10,134 INFO JavaTaskO [main]: ---0 times loop end , the result is ObjectRef(34254bb0ae9f7689ffffffffffffffffffffffff2200000001000000)------
2022-11-25 18:44:10,135 INFO JavaTaskO [main]: --- 1 times loop begin start------
2022-11-25 18:44:10,135 INFO JavaTaskO [main]: step 1 return:ObjectRef(8198ec92f705973effffffffffffffffffffffff2200000001000000)
2022-11-25 18:44:10,141 INFO JavaTaskO [main]: ---1 times loop end , the result is ObjectRef(ace36dceef5a1a37ffffffffffffffffffffffff2200000001000000)------
2022-11-25 18:44:10,142 INFO JavaTaskO [main]: --- 2 times loop begin start------
2022-11-25 18:44:10,142 INFO JavaTaskO [main]: step 1 return:ObjectRef(8c1e38b14aa4e2f0ffffffffffffffffffffffff2200000001000000)
2022-11-25 18:44:10,142 INFO JavaTaskO [main]: ---2 times loop end , the result is ObjectRef(cd131a74fdaaa915ffffffffffffffffffffffff2200000001000000)------
2022-11-25 18:44:10,142 INFO JavaTaskO [main]: --- 3 times loop begin start------
2022-11-25 18:44:10,142 INFO JavaTaskO [main]: step 1 return:ObjectRef(5a1e859d9151a1d8ffffffffffffffffffffffff2200000001000000)
2022-11-25 18:44:10,143 INFO JavaTaskO [main]: ---3 times loop end , the result is ObjectRef(67e35ffb2642a211ffffffffffffffffffffffff2200000001000000)------
2022-11-25 18:44:10,143 INFO JavaTaskO [main]: --- 4 times loop begin start------
2022-11-25 18:44:10,143 INFO JavaTaskO [main]: step 1 return:ObjectRef(e7332f86bd7b3f5fffffffffffffffffffffffff2200000001000000)
2022-11-25 18:44:10,143 INFO JavaTaskO [main]: ---4 times loop end , the result is ObjectRef(7ad5a28136a3eab7ffffffffffffffffffffffff2200000001000000)------
2022-11-25 18:44:16,048 INFO JavaTaskO [main]: ---print result List: [819406792, 0, 1421224626, 1, 514415638, 4, -1154365701, 9, 243385814, 16]------
2022-11-25 18:44:16,048 INFO JavaTaskO [main]: cost time: end-start=5970
root@monitor-virtual-machine:/home/ciccinfra#
Does this mean that the problem is related to jdk11?
I'll take a look.
@jovany-wang We find that the warning may be caused by log4j2 in jdk11, could you please take a look?
Yes. It's introduced in log4j2. See https://issues.apache.org/jira/browse/LOG4J2-2537
We should use multiple jars. I'll investigate how we use multiple jars in bazel...
I'm still trying to understand, but this error appeared to me when I introduced log4j in the classpath. If I remove it, the error doesn't appear. I'm using JDK 20 (zulu).
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.20.0</version>
</dependency>
Add Multi-Release: true
to maven-assembly-plugin
:
<configuration>
<archive>
<manifestEntries>
<!-- Remove 'WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.' -->
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
</configuration>
What happened + What you expected to happen
I use ray in java. And I used JEP to call python in the remote method, but I got:
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
There is no problem with the current calculation results. Could you please tell me What are the hidden dangers?
I read the part of Java calling python in ray. It seems that there are some limitations, so we want to use JEP to implement Java calling python in ray. Will the above warnings affect the use?
Versions / Dependencies
jdk11 ubuntu20.0.4 maven ray2.0.0 python3.9.12
Reproduction script
pydemo .py
Issue Severity
No response