Похожие чаты

Hey. I'M not sure, but if I understood currectly, Graalvm makes

Java run without the jvm on native machines and it produces assembly like C/C++?
If it does this, does this mean that Java with Graalvm is as fast is C/C++?

2 ответов

10 просмотров

> Graalvm makes Java run without the jvm on native machines and it produces assembly like C/C++? Yes, correct. > If it does this, does this mean that Java with Graalvm is as fast is C/C++? There's no answer to this question because there are different aspects in "to be fast". First aspect is app startup time. In classic bytecode-for-JVM style, the app startup takes very substantial time because first before your app code gets executed, the JVM itself needs to start up. This is probably the major advantage of using graalvm - instant startup time. With this regards, graalvm app is as fast as c/cpp one - they both start up practically instantly. Second aspect is the first rounds of your code blocks execution (first ~15 executions if I'm not mistaken). This is the time when JVM does not engage JIT yet. You better google for what JIT is, but in a nutshell, it is an adaptable compiler that lives in VM, tracks code execution metrics and from time to time during code execution tries to recompile code pieces and find the best performing optimization options for that block. So, before JIT kicks in, first executions are very slow compared to c/c++. I.e. java app as bytecode-for-JVM is significantly slower than c/cpp one during first 15 executions. Graalvm and c/cpp both do not have JIT, all compiler optimizations are specified during build time. Hence: jvm << graalvm < c/cpp jvm will be significantly slower. And c/cpp code most likely will be slightly faster than graalvm in real world apps. And "slightly" here is "slightly faster compared to how significantly faster graalvm is than jvm during first executions". I.e. this "slightly" may be like 2-4 times faster. But it may be 20-40 times faster than first jvm executions. For "one off" applications, that's it. But for server apps, or UI apps that users use for a prolonged time, the same code paths may be executed many times repeatedly. That's where JIT comes in. So now we're talking about the third aspect - running for a long time when same code is executed again and again. This state is usually called "hot jvm" or "pre-heated jvm" in java world. So in this case the full power of JIT is unleashed, as compared to classic compiler (graalvm or c/cpp), jit takes into account how code is executed in reality, in runtime, and jit can make experiments or assumptions. All this allows better optimizations than the classic compiler can do. So in this phase, in "hot jvm" state, bytecode-for-jvm might perform better than graalvm. It's very unlikely that hot-jvm will peform better than c/cpp, especially in real-world apps. Yeah, you can find some example, but in average c/cpp is faster than hot-jvm. The bottom line. Graalvm is not that about speed, but rather about - faster startup time than jvm - self-contained execution binary (you don't need jre or anything to run it) - much smaller memory requirements All that is important for microservices. That's where graalvm shines. But overall, question like "jvm is faster than graalvm or than c/cpp" is practically useless. Areas where they are both applicable and you decide which one to use, those areas in 99% cases are not dependent on performance differences in question. These techs are from different worlds with very small intersection.

Αλι-(EN, EO) Автор вопроса

Похожие вопросы

Обсуждают сегодня

Какой-то там пердун в 90-х решил, что есть какая-то разная типизация. Кого вообще это волнует?
КТ315
49
Hi. Do we have a raid bot? Why nobody doing raids on X? Even RH mentioned this and nobody paying attention...whats the channel for hex memes? If mods cant run raids just insta...
H
31
Подскажите, а есть vault lite или ченить такое?) А то нужен вольт для похода в вольт, но весит он ~500 мб) как-то многовато для парочки запросов ))
Alexandr Orloff
17
блеать, почему так?? где в роутере это исправляется?
Арсен Маньяков 🇦🇲
16
void terminal_scroll() { memmove(terminal_buffer, terminal_buffer + VGA_WIDTH, buffer_size - VGA_WIDTH); memset(terminal_buffer + buffer_size - VGA_WIDTH, 0, VGA_WIDTH); ...
Егор
47
🌊 Ocean Nodes Dashboard Update 🚀 Hey, Oceaners! First off, a massive round of applause 👏to all of you for the amazing engagement since we launched Ocean Nodes. In just a few ...
KreigDK | Never DM first🌊
3
Всем привет! Подскажите, пожалуйста, в чем ошибка? Настраиваю подключение к MySQL. Либы лежат рядом с exe. Все как по "учебнику"
Евгений
16
А можете как-то проверить меня по знаниям по ассемблеру?
A A
132
Здравствуйте! У меня появилась возможность купить книгу "Изучай Haskell во имя добра!". Но я где-то слышал, что эта книга устарела. Насколько это правда??
E
22
люди, которые используют flameshot, к вам вопрос. Можно-ли поставить хоткей на создание скриншота? В программе есть отдел "горячие клавиши", но там все для редактирования, скр...
ThunDer104
11
Карта сайта