当前位置:网站首页>On Oracle full stack virtual machine -- graalvm
On Oracle full stack virtual machine -- graalvm
2022-06-25 18:59:00 【Magic City】
Official statement :
GraalVM Is an ecosystem and shared runtime , Not only is it based on JVM Language ( Such as Java,Scala,Groovy and Kotlin) Performance advantages , Other programming languages are also available ( Such as JavaScript,Ruby,Python and R) Performance advantages . Besides , It also supports the adoption of LLVM Front-end JVM Execute native code on .GraalVM 1.0 be based on JDK 8.

The picture above shows GraalVM As an open ecosystem Architecture .
Virtualization layer representative GraalVM Programming languages provided . Client programming language ( namely JavaScript,Ruby,R,Python and LLVM bitcode) In conjunction with host based JVM The execution in the same runtime of the application is now down-to-earth . Host and client languages can interoperate directly , And transfer data back and forth in the same storage space .
The applicable scope is shown at the bottom .GraalVM It can run independently , It can also be used as OpenJDK or node.js Part of the platform , You can even embed MySQL or Oracle RDBMS Wait for the database .
GraalVM 1.0 Version contains language interpreters :
- be based on JVM Language , Such as Java,Scala,Groovy or Kotlin
- JavaScript( Include node.js)
- Compiled into LLVM bitcode Language , Such as C,C ++ or Rust
- Ruby,R and Python The experimental version of
GraalVM Includes the following components :
- Graal: A dynamic instant (JIT) compiler , Improve application efficiency and speed through unique code analysis and optimization methods .
- Graal Polyglot API: For combining programming languages in a shared runtime API. these API Allows you to match programming languages as needed , And use fewer resources to provide you with better performance .
- Graal SDK: A set for embedding Graal Languages and configuring native images API.
- Oracle HotSpot Java virtual machine (JVM): be based on JVM And the runtime environment of the supported client programming languages .
ShowTime:
Configuration article :
After reading the exciting introduction , I decided to try . As a serious java In patients with , about Oracle I'm still interested in something . Here is his official website , It looks like this , On the whole ,UI The designer is good . At least I like this style .

We continue to look down the front page . The official website has a paragraph Node Code , Show us ,GraalVM The advantages of , We can clearly find that , In this code we are compatible with 3 Different languages . It provides us with great convenience .

Next , Let's introduce ,java Optimization of aspects ,GraalVM Allows you to compile a program into a native executable in advance . The generated program is not in Java HotSpot VM Up operation , Instead, use the necessary components , Such as memory management , Thread scheduling from different implementations of virtual machines , be called Substrate VM.Substrate VM Yes, it is Java Compiling , And compile the cost machine executable . And Java VM comparison , The generated program has faster startup time and lower runtime memory overhead .

In this picture we , It's obvious that ,java The compilation time of has been shortened ,14 times . Of course, this is its official data . Everything is subject to my later test data .
Said so much , The more you say it, the more excited you get , I can't wait to download , This thing . I went to the official website . This guy offers the community version and the enterprise version , I first tried the community version , And then failed to live up to expectations . Then I decided to Baidu , Du Niang is not omnipotent , majority “ The player ” Using all of these Mac It gives me a headache . However, I found the solution in the official documents .

After successfully registering an account on the official website , Will automatically download
, Then I dragged it to , In my virtual machine .
Then do the following :
1. Choose a folder at will , Execute the unzip command , You will see a pile of decompressed data . If the folder shown in Figure 3 appears on the desktop, it indicates success .


Figure 3
2. Next, configure the running environment for the virtual machine , Because I am. linux The system of , So I chose the configuration item in the first line . The format is as follows :
export PATH=/path/to/graalvm/bin:$PATH
The effect configured on my machine is :
among :/home/gjt/Desktop/graalvm-ee-1.0.0-rc4/bin This is my installation path .
export PATH=/home/gjt/Desktop/graalvm-ee-1.0.0-rc4/bin:$PATH
The following interface appears , The configuration is successful .

Operation :
Done , Virtual machine configuration , The next step is to test the basic code .
java Code :
Execute the new command , Open a file .

This is the basic code I write

And then use javac compile , then java Compile implementation :

Then we tried the official website native-image Way to run , Found a mistake ,


but , Since there are few references on the Internet , I chose to go to the official git On issue To find the answer .
Sure enough, there are fellow believers , This is a Oracle The answer given by the official .

I decided to have a try , Started to try .

Compile again .

Finally, I successfully compiled this HelloWord file ,
The next most exciting moment has come .
Figure 1 shows the process native-image After the start-up time .

Figure 1
Figure 2 shows the tradition java Starting time .

Figure 2

The speed has been significantly improved .
We can see that the code speed has been significantly improved after image acceleration .
The official explanation is :GraalVM Can be Java Bytecode compiled to native image , For faster startup and smaller application footprint . therefore , Native images are better than direct images JVM It's much faster to run the same code on :
The final operation :
After the test java After the code, we test a wave js Code , Obviously basic js The syntax has been supported .

Another wave Node Code ,
Test code :

var http = require('http');
http.createServer(function (request, response) {
// send out HTTP Head
// HTTP The status value : 200 : OK
// Content type : text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send response data "Hello World"
response.end('Hello World\n');
}).listen(8080);
// The terminal prints the following information
console.log('Server running at http://127.0.0.1:8080/');

Last , Let's try some of its other features :
In the following code , I used... At the same time js The grammar of .

I have to mention Polyglot.
Polyglot working principle
GraalVM Allows you to write multilingual applications in a seamless way , To pass values from one language to another . Use GraalVM when , There is no need to copy or group like other multilingual systems . This enables you to achieve high performance across language boundaries . Most of the time , The extra cost of having no language boundaries at all .
Developers often have to make uncomfortable compromises , Ask them to rewrite their software in other languages . for example :
- “ That library doesn't have my language version . I need to rewrite it .“
- “ This language is very suitable for my problem , But we can't run it in our environment .”
- “ This problem has been solved in my language , But the language is too slow .”
Use GraalVM, Our goal is to allow developers to freely choose the language that is appropriate for the task at hand without compromising .
To provide foreign language multilingual values , We developed the so-called Multilingual interoperability protocol . The interoperability protocol consists of a set of standardized messages , Every Graal Language implementation and use for external multilingual values . The agreement allows GraalVM Support interoperability between any language combination , Without knowing each other . We plan to gradually improve the agreement , In order to support more and more functions over time .
For more information , We suggest you read :
- Matthias is stern , Chris · Sidon , Roland · Sand ,Würthinger,HanspeterMössenböck High performance multi language runtime for cross language interoperability stay The... In the program 11 Dynamic language workshop (DLS) Of .
Details refer to :https://www.graalvm.org/docs/reference-manual/polyglot/
Weaken the main language
GraalVM An experimental starter has been developed 「polyglot」. stay polyglot There is no concept of the main language , Every language is equal , have access to polyglot Run programs written in any language , There is no need for a separate launcher for each of the preceding languages .polyglot The language will be automatically classified by the file extension .
Conclusion :
Learn from , To environment setup and testing , I did encounter many pits , however , Because of these pits , Let me gain something , I really learned a lot . This thing , On the whole , It's not bad . Later, I will try to package the project for testing .

边栏推荐
- Regular expression summary
- [deeply understand tcapulusdb technology] create a game zone
- SQL is used for field data types in various databases
- IDEA常用插件
- QQ robot official plug-in loading configuration method [beta2 version]
- TCP/IP 测试题(一)
- Training of long and difficult sentences in postgraduate entrance examination day84
- 158_模型_Power BI 使用 DAX + SVG 打通制作商業圖錶幾乎所有可能
- QQ机器人:群成员自我禁言管理【最新beta2版本】
- Overview and trend analysis of China's CT examination equipment industry in 2021 [figure]
猜你喜欢
![Development status of China's hydrotalcite industry in 2020 and analysis of major enterprises: the market scale is rapidly increasing, and there is a large space for domestic substitution [figure]](/img/2c/05f2aa467edb76095e30a117adc251.jpg)
Development status of China's hydrotalcite industry in 2020 and analysis of major enterprises: the market scale is rapidly increasing, and there is a large space for domestic substitution [figure]

【ELT.ZIP】OpenHarmony啃论文俱乐部—见证文件压缩系统EROFS
![[deeply understand tcapulusdb technology] one click installation of tmonitor background](/img/0a/742503e96a9b51735f5fd3f598b9af.png)
[deeply understand tcapulusdb technology] one click installation of tmonitor background

Uncover ges super large scale graph computing engine hyg: Graph Segmentation
![[in depth understanding of tcapulusdb technology] tcapulusdb regular documents](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[in depth understanding of tcapulusdb technology] tcapulusdb regular documents
![Analysis on development status and development suggestions of e-commerce industry in Xinjiang in 2020 [figure]](/img/d1/8ed2958ef365e17494bade6e29ee04.jpg)
Analysis on development status and development suggestions of e-commerce industry in Xinjiang in 2020 [figure]
![[deeply understand tcapulusdb technology] create a game area for document acceptance](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[deeply understand tcapulusdb technology] create a game area for document acceptance

Idea annotation color modification method (clear)
![[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance doc

On location and scale in CNN
随机推荐
Tiger Dao VC products are officially launched, a powerful supplement to seektiger ecology
LeetCode 198. Looting & dynamic planning
Kotlin Compose 终结toDo项目 点击可以编辑修改todo
Tcp/ip test questions (4)
中金财富安全吗? 开户需要多久
[in depth understanding of tcapulusdb technology] tcapulusdb operation and maintenance
2021 development status of China's cloud game industry and analysis of major service providers: Although cloud games are still in their infancy, the market prospect is huge [figure]
Training of long and difficult sentences in postgraduate entrance examination English Day82
Comparison rules of strings in JS
网络安全检测与防范 练习题(三)
云上弹性高性能计算,支持生命科学产业高速发展、降本增效
【C语言练习——打印上三角及其变形(带空格版)】
Network security detection and prevention test questions (4)
Solidity get quarterly time
Basic operation details of binary search tree (BST) (complete code, including test cases)
English name of each stage of software version
两轮市场红海,利尔达芯智行如何乘风破浪?
What is an operator?
JS get data
《痞子衡嵌入式半月刊》 第 57 期