当前位置:网站首页>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 .

边栏推荐
- Analysis on policy, output and market scale of China's natural gas hydrogen production industry in 2020 [figure]
- Training of long and difficult sentences in postgraduate entrance examination day86
- 网络安全检测与防范 测试题(二)
- 初探Oracle全栈虚拟机---GraalVM
- 2017 reading (word memory)
- Ruffian Heng embedded semimonthly issue 57
- 中金财富安全吗? 开户需要多久
- R语言使用DALEX包的model_profile函数基于条件依赖CDP方法解释多个分类模型中某个连续特征和目标值y的关系(Conditional Dependence Plots)
- Apifox简单了解——WEB端测试的集大成者
- 云上弹性高性能计算,支持生命科学产业高速发展、降本增效
猜你喜欢
![Analysis on market scale and supply of China's needle coke industry in 2020 [figure]](/img/79/6b08b62be8768484f548b6e18bd810.jpg)
Analysis on market scale and supply of China's needle coke industry in 2020 [figure]

Guangzhou Sinovel interactive creates VR Exhibition Hall panoramic online virtual exhibition hall

【历史上的今天】6 月 25 日:笔记本之父诞生;Windows 98 发布;通用产品代码首次商用

03 runtime data area overview and threads

《痞子衡嵌入式半月刊》 第 57 期

On location and scale in CNN

Regular expression summary

Differences and relations between sequential table and array (easy to confuse), linear table and linked list

Leetcode-78-subset
![Current situation and trend analysis of China's glass packaging containers in 2021: the revenue of glass packaging containers increases year by year [figure]](/img/19/d93c8647415c593de9c3c959f72d64.jpg)
Current situation and trend analysis of China's glass packaging containers in 2021: the revenue of glass packaging containers increases year by year [figure]
随机推荐
削足适履 - 谈谈赛道上的坡道改造
TCP/IP 测试题(二)
[deeply understand tcapulusdb technology] table management of document acceptance
Regular expression summary
JS some small problems about adding and accessing values to arrays
云上弹性高性能计算,支持生命科学产业高速发展、降本增效
[elt.zip] openharmony paper Club - witness file compression system erofs
想知道新股民怎样炒股票开户?在线开户安全么?
Addition, deletion, modification and query of mysql~ tables (detailed and easy to understand)
LeetCode 198. Looting & dynamic planning
Training of long and difficult sentences in postgraduate entrance examination day84
【C语言练习——打印上三角及其变形(带空格版)】
Comparison rules of strings in JS
TCP/IP 测试题(四)
Ruffian Heng embedded semimonthly issue 57
广州华锐互动打造VR展厅全景在线虚拟展厅
《痞子衡嵌入式半月刊》 第 57 期
Basic operations and basic data types of MySQL database
Training of long and difficult sentences in postgraduate entrance examination day85
Overview and trend analysis of China's CT examination equipment industry in 2021 [figure]