AlignmentSystems / MatchingEngine

A toy implementation of a matching engine. Don't use this in the real world, it's a toy!
MIT License
3 stars 0 forks source link

GraalVM #35

Closed JohnGreenan closed 9 months ago

JohnGreenan commented 9 months ago

See https://hackernoon.com

GraalVM home

Gradle plug-in

JohnGreenan commented 9 months ago

Download from here Instructions here

JohnGreenan commented 9 months ago

Update JAVA_HOME and PATH add to ~/.bashrc these lines:

JAVA_HOME="/home/john/graalvm-jdk-21+35.1"

export PATH=/home/john/graalvm-jdk-21+35.1/bin:$PATH 
JohnGreenan commented 9 months ago
john@john-VBox:~/git/MatchingEngine/exchange/build/libs$ native-image AlignmentMatching.jar 

================================================================================

GraalVM Native Image: Generating 'alignmentmatching.jar' (executable)...

================================================================================

[1/8] Initializing...                                            (0.0s @ 0.08GB)

Error: Main entry point class 'AlignmentMatching.jar' neither found on 

classpath: '/home/john/git/MatchingEngine/exchange/build/libs' nor

modulepath: '/home/john/graalvm-jdk-21+35.1/lib/svm/graal-microservices.jar:/home/john/graalvm-jdk-21+35.1/lib/svm/library-support.jar'.
JohnGreenan commented 9 months ago

Native Image Basics

JohnGreenan commented 9 months ago
john@john-VBox:~/git/MatchingEngine/exchange/build/libs$ native-image -jar AlignmentMatching.jar 

================================================================================

GraalVM Native Image: Generating 'AlignmentMatching' (executable)...

================================================================================

Warning: The host machine does not support all features of 'x86-64-v3'. Falling back to '-march=compatibility' for best compatibility.

[1/8] Initializing...                                            (8.4s @ 0.14GB)

 Java version: 21+35, vendor version: Oracle GraalVM 21+35.1

 Graal compiler: optimization level: 2, target machine: compatibility, PGO: ML-inferred

 C compiler: gcc (linux, x86_64, 11.4.0)

 Garbage collector: Serial GC (max heap size: 80% of RAM)

 1 user-specific feature(s):

 - com.oracle.svm.thirdparty.gson.GsonFeature

--------------------------------------------------------------------------------

Build resources:

 - 5.85GB of memory (75.6% of 7.75GB system memory, determined at start)

 - 4 thread(s) (100.0% of 4 available processor(s), determined at start)

[2/8] Performing analysis...  [******]                          (75.1s @ 1.14GB)

    9,834 reachable types   (80.6% of   12,196 total)

   16,243 reachable fields  (58.1% of   27,946 total)

   54,221 reachable methods (46.4% of  116,921 total)

    2,923 types,   122 fields, and 1,840 methods registered for reflection

       61 types,    59 fields, and    55 methods registered for JNI access

        4 native libraries: dl, pthread, rt, z

[3/8] Building universe...                                      (10.2s @ 1.06GB)

Warning: Reflection method java.lang.Class.newInstance invoked at quickfix.Message.clone(Message.java:133)

Warning: Reflection method java.lang.Class.getMethod invoked at org.apache.kafka.common.security.kerberos.KerberosError.<clinit>(KerberosError.java:61)

Warning: Reflection method java.lang.Class.getMethod invoked at org.slf4j.helpers.SubstituteLogger.isDelegateEventAware(SubstituteLogger.java:467)

Warning: Reflection method java.lang.Class.getMethods invoked at quickfix.MessageCracker.initialize(MessageCracker.java:73)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.slf4j.LoggerFactory.loadExplicitlySpecified(LoggerFactory.java:223)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.apache.kafka.common.utils.SecurityUtils.addConfiguredSecurityProviders(SecurityUtils.java:86)

Warning: Reflection method java.lang.Class.getConstructor invoked at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:61)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:197)

Warning: Reflection method java.lang.Class.getConstructor invoked at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:63)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.apache.mina.filter.codec.demux.DemuxingProtocolDecoder.addMessageDecoder(DemuxingProtocolDecoder.java:107)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:200)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.apache.mina.filter.codec.demux.DemuxingProtocolEncoder.addMessageEncoder(DemuxingProtocolEncoder.java:70)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:191)

Warning: Reflection method java.lang.Class.getConstructor invoked at org.apache.mina.core.service.SimpleIoProcessorPool.<init>(SimpleIoProcessorPool.java:206)

Warning: Reflection method java.lang.Class.getConstructor invoked at ch.qos.logback.classic.util.ContextInitializer.instantiateConfiguratorByClassName(ContextInitializer.java:105)

Warning: Reflection method java.lang.Class.getDeclaredConstructor invoked at net.jpountz.lz4.LZ4Factory.<init>(LZ4Factory.java:197)

Warning: Reflection method java.lang.Class.getDeclaredConstructor invoked at org.apache.kafka.common.utils.Utils.newInstance(Utils.java:396)

Warning: Reflection method java.lang.Class.getField invoked at net.jpountz.lz4.LZ4Factory.classInstance(LZ4Factory.java:180)

Warning: Reflection method java.lang.Class.getField invoked at net.jpountz.xxhash.XXHashFactory.classInstance(XXHashFactory.java:167)

Warning: Reflection method java.lang.Class.getDeclaredFields invoked at quickfix.BusinessRejectReasonText.<clinit>(BusinessRejectReasonText.java:41)

Warning: Reflection method java.lang.ClassLoader.loadClass invoked at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(OptionHelper.java:56)

Warning: Reflection method java.lang.ClassLoader.loadClass invoked at ch.qos.logback.classic.util.ContextInitializer.instantiateConfiguratorByClassName(ContextInitializer.java:104)

Warning: Reflection method java.lang.ClassLoader.loadClass invoked at org.slf4j.LoggerFactory.loadExplicitlySpecified(LoggerFactory.java:222)

Warning: Reflection method java.lang.ClassLoader.loadClass invoked at org.apache.kafka.common.config.ConfigDef.parseType(ConfigDef.java:732)

Warning: Reflection method java.lang.ClassLoader.loadClass invoked at ch.qos.logback.classic.spi.PackagingDataCalculator.loadClass(PackagingDataCalculator.java:207)

Warning: Aborting stand-alone image build due to reflection use without configuration.

--------------------------------------------------------------------------------

   13.6s (14.3% of total time) in 142 GCs | Peak RSS: 2.22GB | CPU load: 3.49

================================================================================

Finished generating 'AlignmentMatching' in 1m 34s.

Generating fallback image...

Warning: The host machine does not support all features of 'x86-64-v3'. Falling back to '-march=compatibility' for best compatibility.
JohnGreenan commented 9 months ago

Warning: Aborting stand-alone image build due to reflection use without configuration.

See Native Image and Third-Party Libraries

JohnGreenan commented 9 months ago

Abandon this for now, too time consuming