<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oleg Šelajev on Medium]]></title>
        <description><![CDATA[Stories by Oleg Šelajev on Medium]]></description>
        <link>https://medium.com/@shelajev?source=rss-35826df4e731------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5eOVS2rcmg1rYKzZWcLL6A.jpeg</url>
            <title>Stories by Oleg Šelajev on Medium</title>
            <link>https://medium.com/@shelajev?source=rss-35826df4e731------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 15:02:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shelajev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Embracing the Spectrum of Tests]]></title>
            <link>https://medium.com/@shelajev/embracing-the-spectrum-of-tests-54fafb98ea06?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/54fafb98ea06</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Wed, 28 Feb 2024 12:06:54 GMT</pubDate>
            <atom:updated>2024-02-28T12:06:54.967Z</atom:updated>
            <content:encoded><![CDATA[<p>I work with <a href="http://testcontainers.com/">Testcontainers</a>, the libraries which give you API to configure and work with containers. Testcontainers targets pre-production use cases, so I often find myself in the middle of the debate of unit vs. integration tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZgo6XKJIz2AsFp9NpMEwg.png" /></figure><p>This discussion usually hinges on attempts to protect and advocate participants’ personal favourite approaches. But perhaps we’re missing the forest for the trees by focusing on these labels.</p><h4>The Complexity Axis of Testing</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AssNowdi4qv_AdIG2UTErQ.png" /></figure><p>Consider a complexity axis for your tests. On one end, we have clear-cut unit tests — simple, isolated, and unmistakable. Easy to run from the IDE without losing focus, repeatable, and you can easily come up with an example that would fit right in:</p><pre>assertEquals(3, add(2, 1)); </pre><p>It’s as easy to bring an example or recognize some of the integration tests. You can probably tell an integration test by its use of multiple service components, like a database or a Kafka cluster, or having to deploy your app as a Kubernetes operator into an actual cluster, and so on. But it’s really not that easy to define what separates the two, or illustrate where exactly unit tests stop and integration tests start?</p><p>Is a test that is runnable as an individual method in your IDE, doesn’t require any externally provided setup, runs fast enough that you don’t get distracted, feel exactly like a classic unit test, but spins up a Redis (and cleans up after itself — is that a unit test? As some say if it feels like a unit test, and quacks like a unit test… that’s a totally different discussion.</p><h4>The Purpose of Tests</h4><p>Tests are, first and foremost, a tool for developers to enhance productivity. They serve a two-fold purpose: to give you confidence in the quality of your applications at any given moment of time, and to facilitate faster and safer development.</p><p>Tests should prevent code breakage, allow for local issue reproduction and fixes, and not obstruct refactoring by breaking when the internals of your code change.</p><p>This actually is a frequently overlooked part about good tests: you do want your tests to break when the code’s externally observable behaviour changes.</p><p>This prevents you from breaking other’s people parts of the system and them from messing up your code. But you don’t want them to break for “internal code changes”, so you only actually change the tests when functionality changes. This way you don’t get used to changing tests “because they are fragile”, and won’t accidentally change the code behavior and “fix” the tests at the same time wrecking havoc in production.</p><p>Tests should also ideally be fast. But rather than having milliseconds value attached, it usually means — quick enough individually to maintain focus during development and as a whole to keep the continuous integration (CI) pipeline flowing smoothly.</p><p>So with all the above, doesn’t the preoccupation with labels such as “unit” and “integration” seem inconsequential? If the boundaries between them are so blurred and the ultimate goal of testing transcends these classifications, why do we hold onto them so tightly?</p><p>The real measure of a test’s value is not in its label or arbitrary code coverage metrics but in the confidence it provides and its utility in the development process.</p><p>In the end, I strongly believe that we’ll have better software if we ask ourselves less “Is this a unit or an integration test?” and more “Does this test meet our needs?”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54fafb98ea06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 reasons I’m thrilled to join AtomicJar]]></title>
            <link>https://medium.com/@shelajev/3-reasons-im-thrilled-to-join-atomicjar-c0f4aaa502be?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0f4aaa502be</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[testcontainer]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[integration-testing]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Fri, 01 Oct 2021 14:19:43 GMT</pubDate>
            <atom:updated>2021-10-01T14:19:43.756Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I joined the <a href="https://www.atomicjar.com/">AtomicJar</a> team working on making integration tests simpler, more efficient, and a much more prominent tool for all developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GczT8-87ko607XdE_EO7fw.png" /><figcaption>A quick intro to AtomicJar</figcaption></figure><p>It’s a very exciting opportunity and I’m thrilled at the impact we can have on the enormous developer community across multiple language ecosystems and thousands of projects. Here are a few reasons AtomicJar is an amazing company to put your efforts in.</p><h3>Technology</h3><p>At the heart of the AtomicJar technology is <a href="https://github.com/testcontainers">the Testcontainers project</a> and the ideas it popularised initially in the Java ecosystem.</p><p>Testcontainers is a collection of libraries that integrate with your tests and provides lightweight, ephemeral instances of common third-party services you need: databases, message queues, text search engines, Kafkas, and Redises, and Mockservers, and if needed even the browsers for your UI tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nEeEHpkXX1ZjtMt0Skvxbg.png" /><figcaption>Some technologies you can use in your tests with Testcontainers</figcaption></figure><p>All these services can be easily programmatically managed as containers that are aware of your tests’ lifecycle and turn running your integration tests into bliss.</p><p>You can find the details and typical usage patterns on the website: <a href="https://www.testcontainers.org/"><strong>testcontainers.org</strong></a>, but if you haven’t seen it at all here’s a one-liner to awe in delight.</p><p>Setting up a Kafka instance programmatically:</p><pre>KafkaContainer kafka = <br>      new KafkaContainer(DockerImageName.parse(<br>                               &quot;confluentinc/cp-kafka:5.4.3&quot;));</pre><p>And then you can access it programmatically too with something like kafka.getBootstrapServers(). There’s of course API for every particular type of service that makes sense for them: databases, caches, search engines.</p><p>With Testcontainers it’s so easy to create proper integration tests with it and the user experience is so smooth that it’s really easy to fall in love with the technology.</p><h3>James Ward on Twitter: &quot;I&#39;ve been using @testcontainers not just for tests but also for local development... And it is AMAZING! / Twitter&quot;</h3><p>I&#39;ve been using @testcontainers not just for tests but also for local development... And it is AMAZING!</p><p>Here’s what James Ward said about Testcontainers about a year ago, and it’s as valid now as ever.</p><p>And trust me, James knows a thing or two about technology, productivity, and developer experience.</p><h3>Community</h3><p>Technology and the product are only a part of the equation. What sets AtomicJar apart is the emphasis on the success of the community.</p><p>There are currently thousands of users of the testcontainers libraries. They are also not limited to the Java ecosystem, there’re for example:</p><ul><li><a href="https://github.com/testcontainers/testcontainers-java">testcontainers-java</a></li><li><a href="https://github.com/testcontainers/testcontainers-go">testcontainers-go</a></li><li><a href="https://github.com/testcontainers/testcontainers-python">testcontainers-python</a></li><li><a href="https://github.com/testcontainers/testcontainers-rs">testcontainers-rust</a></li><li><a href="https://github.com/testcontainers/testcontainers-node">testcontainers-node</a></li><li><a href="https://github.com/testcontainers/testcontainers-dotnet">testcontainers-dotnet</a></li></ul><p>You get the point, having better integration tests is not limited to a particular language. All our projects could have better and faster integration tests.</p><p>Here’s for example a blogpost by Ricardo Ferreira about <a href="https://riferrei.com/using-testcontainers-go-with-elasticsearch/">using testcontainers to manage Elasticsearch from golang tests</a>.</p><p>I’m not an expert in go, but it looks neat, doesn’t it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OKwA--M0to0faDO3B0W0Rw.png" /><figcaption>Sample code to create a container with ElasticSearch in go from <a href="https://riferrei.com/using-testcontainers-go-with-elasticsearch/">https://riferrei.com/using-testcontainers-go-with-elasticsearch/</a></figcaption></figure><p>As a developer advocate, I’m thrilled to work with the diverse communities of various ecosystems!</p><p>If you don’t have enough of those, you can join the <a href="https://slack.testcontainers.org/">Slack workspace for the project</a> and hang out with cool people there.</p><h3>Company</h3><p>Last but not least, <a href="https://www.atomicjar.com/">AtomicJar</a> is a company I see to have a bright future. I have this tendency to trust brilliant engineers, and with <a href="https://twitter.com/bsideup">Sergei</a> and <a href="https://twitter.com/whichrich">Richard</a> at the helm, how much more brilliant can it get?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCzoZyIXojGLToHs6nY7rg.png" /><figcaption>The founding team of AtomicJar</figcaption></figure><p>Very often companies market themselves as being for developers by developers. In the case of AtomicJar, I feel it’s really the case. Open source is at the heart of the company, the team understands developers, we even participate in various initiatives like <a href="https://opencollective.com/atomicjar">opencollective to support OSS projects</a>.</p><p>It is also an excellent opportunity to see a company grow and establish itself from the early stages which is an experience I welcome very-very much.</p><p>And since you’ve read so far already, you clearly have a few minutes on your hands. Why not write a new integration test for the project you’re working on? Who knows maybe you can even <a href="https://www.testcontainers.org/">try a cool library that makes integration tests simpler</a>. 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0f4aaa502be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraalVM 21.2 with lots of native image usability improvements]]></title>
            <link>https://medium.com/graalvm/graalvm-21-2-ee2cce3b57aa?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee2cce3b57aa</guid>
            <category><![CDATA[perfomance]]></category>
            <category><![CDATA[native-image]]></category>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Tue, 20 Jul 2021 16:11:09 GMT</pubDate>
            <atom:updated>2021-07-26T10:47:10.792Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CSRcXF0keQoDxUaGC8OKRg.png" /></figure><p>GraalVM 21.2 is released today and in this article we focus on the most visible, important, and exciting updates available in this version.</p><p>First things first, GraalVM 21.2 builds are available for download from the usual locations:</p><ul><li><a href="https://www.graalvm.org/downloads">GraalVM</a></li><li><a href="https://www.oracle.com/downloads/graalvm-downloads.html">GraalVM Enterprise</a></li></ul><p>GraalVM consists of several components, and with every release we work hard on bringing improvements to them all. So if you’re interested in a particular component and would like to get a more detailed overview of the changes, please consult the <a href="https://www.graalvm.org/release-notes/21_2/">documentation</a>.</p><h3>Native Image</h3><p>Let’s start with looking at new and noteworthy in Native Image. Back in June we released the new Gradle and Maven plugins for Native Image with initial JUnit 5 testing support. It simplifies building native images of your applications and allows to run JUnit tests in native image mode to check how your code works there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*ziyoe45f-tTSkstCsb1k6g.png" /><figcaption>Sample Gradle output when running JUnit tests in native image mode.</figcaption></figure><p>Since the initial release there have been two minor ones with various bug fixes, improvements, and cleanups, so <a href="https://medium.com/graalvm/gradle-and-maven-plugins-for-native-image-with-initial-junit-testing-support-dde00a8caf0b">if you maintain an application or library that works in Native Image, consider using the two run tests and verify behavior in Native Image!</a></p><p>Another quality of life improvement is that Native Image now <strong>automatically removes unnecessary security providers from the image</strong>: the reachable security providers are detected by the static analysis. This means the options like --enable-all-security-services are deprecated and will be removed in the future. It is possible to disable the automatic detection completely using -H:-EnableSecurityServicesFeature and register the providers manually as well. You can read more about it in <a href="https://www.graalvm.org/reference-manual/native-image/JCASecurityServices/">the docs</a>.</p><p>One very welcome addition that landed in 21.2 is the implementation of the<strong> class pre-definition to support </strong><strong>ClassLoader.loadClass calls at run time</strong>. Desired classes that need to be loaded at run time must be made available to the static analysis at build time so that they are included in the closed world analysis, but otherwise the code patterns that include loading classes at arbitrary moments of run time are now working in native images just as you&#39;d expected them to.</p><p>Another interesting infrastructure enhancement made to GraalVM 21.2 is that <strong>native images built with </strong><strong>-H:+AllowVMInspection now support </strong><a href="https://docs.oracle.com/en/java/javase/11/docs/api/jdk.jfr/jdk/jfr/Event.html"><strong>JFR events that are written in Java</strong></a>. To record JFR events at run time, JFR support and JFR recording must be enabled with the command line options -XX:+FlightRecorder and -XX:StartFlightRecording. There aren&#39;t that many events actually implemented, but the architecture for implementing them or emitting them from the application code is available.</p><p>You can try the following example to see how your custom events could look in practice:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/717c298bc85885090a0a8da6158d513f/href">https://medium.com/media/717c298bc85885090a0a8da6158d513f/href</a></iframe><p>Build it into the native image, run with -XX:+FlightRecorder -XX:StartFlightRecording=”filename=recording.jfr”</p><p>And you can see how the event looks like in, for example, VisualVM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sadtNsotSm33tNWxoGlqbA.png" /></figure><h3>Compiler Updates</h3><p>Every update brings incremental improvements and new optimizations in the compiler which result in gains on some workloads. Over time these gains accumulate and result in significant performance gains. If you have not updated recently, now is a good time to leverage all those improvements. In 21.2 there are a number of interesting optimizations added to the compiler. Let’s start with the ones available in GraalVM Enterprise, available as part of an Oracle Java SE Subscription.</p><p>We improved <strong>loop limit analysis</strong> for counted loops, so the compiler also analyzes the control flow preceding the loop to reason about the induction variables. This can make more uncounted loops, like the example one below, amendable for advanced optimizations.</p><pre>long i = 0;<br>  if (end &lt; 1) return;<br>  do {<br>      // body<br>      i++;<br>  } while (i != end);</pre><p>Here the compiler can combine the info from before the loop that i is 0 and end ≥ 1 to prove that end &gt; i and use that data for optimizing the loop body.</p><p>We also added a novel <strong>Strip Mining </strong>optimization for non-counted loops, which splits loop iteration into parts, making them easier to optimize later. It is is disabled per default; enable it with the -Dgraal.StripMineNonCountedLoops=true option.</p><p>We improved compilation of the code which uses typical StringBuilder patterns, and enhanced support for these patterns in JDK11 based GraalVM builds by making it aware of the compact strings in JDK11.</p><p>Then in terms of GraalVM Community Edition, one notable improvement to the compiler is the addition of the <strong>Speculative Guard Movement</strong> optimization, which tries to move a loop invariant guard, for example, an array bounds check, from inside a loop to outside of the loop. This can improve relevant workloads dramatically.</p><p>Also, we improved <strong>safe-point elimination mechanisms</strong> in long counted loops. The compiler can now eliminate safe-points in loops that have a long induction variable where it can statically prove that the range of the induction variable is Integer.MAX_VALUE - Integer.MIN_VALUE. Consider this for-loop example:</p><pre>for (long i = Integer.MIN_VALUE; I &lt; Integer.MAX_VALUE; I++) { <br>  // body <br>}</pre><p>The compiler can now statically prove i only iterates within integer range even though it is a long. As a result, the integer overflow situation doesn&#39;t need to be accounted for and the loop optimizes better.</p><p>On top of these there are a few optimizations available in this release not yet enabled by default and considered experimental. One experimental optimization called <strong>Write Sinking</strong> tries to move writes out of loops. You can enable it in GraalVM Enterprise with -Dgraal.OptWriteMotion=true. Another optimization available in GraalVM Enterprise, but not yet enabled by default is a novel <strong>SIMD (Single Instruction Multiple Data)</strong> vectorization optimization for sequential code. You can experiment with it by using the -Dgraal.VectorizeSIMD=true option. If you&#39;re not ready to experiment yourself, stay tuned — in an upcoming standalone article we&#39;re going to explore in detail what it gives you, and how your code can benefit from it.</p><h3>Polyglot Runtime &amp; Truffle framework</h3><p>Truffle received a <strong>new compilation queuing heuristic</strong>, enabled by default. This new heuristic improves the warm-up time of the polyglot runtime on many workloads.</p><p>Here’s a brief explanation what it does: imagine the following synthetic piece of JavaScript code is your application. It runs 2 functions in a loop, both of which reach the threshold for the JIT compilation and need to be compiled:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1aa88bf2325b7522c9e4ccc9d0d4346/href">https://medium.com/media/d1aa88bf2325b7522c9e4ccc9d0d4346/href</a></iframe><p>In the previous versions of GraalVM, the algorithm to prioritize compilation worked in the first-come, first-served order. This would result in compiling the lowUsagefunction first, instead of the more beneficial order with highUsage being compiled first.</p><p>Now in GraalVM 21.2, the policy is more sophisticated than just the hotness and takes into account the multi-tier settings, compiling for the first tier faster, compilation history and deoptimizations prioritising code previously already determined to be important, and the weighted combination of code hotness and being in active use at the same time. All in all this should result in better warmup for all GraalVM languages.</p><p>There are additional configuration options to tweak the heuristic or disable its use completely. Learn more about it in the <a href="https://github.com/oracle/graal/blob/master/truffle/docs/TraversingCompilationQueue.md">docs</a>.</p><p>Another change is that certain API calls when embedding a polyglot context require a new version of JVMCI, the compiler interface used to plug the compiler to the Java HotSpot VM. The GraalVM distributions for all JDK versions contain the updated JVMCI, but if you’re using GraalVM languages with a different JDK and enable the GraalVM compiler on the module path, make sure to use one of the following JDK versions that include JDK-8264016 for full compatibility.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F9M3aVeUISfFuGsiWVB%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fwetv-we-tv-growing-up-hip-hop-guhh-9M3aVeUISfFuGsiWVB&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2F9M3aVeUISfFuGsiWVB%2Fgiphy.gif%3Fcid%3D790b76117178d6b2d120c0acf6df8221473e830abeeb9b51%26rid%3Dgiphy.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2a57eece2fea59ef99a3d5d8ce8a0db/href">https://medium.com/media/f2a57eece2fea59ef99a3d5d8ce8a0db/href</a></iframe><p>Otherwise using forced context cancellation (Context.close(true)) or interrupting (Context.interrupt(Duration)) will throw errors. For the best experience, consider using the GraalVM distributions for running your applications or avoid using these APIs. Other possible workarounds are described <a href="https://www.graalvm.org/release-notes/21_2/">in the notes</a>.</p><p>And since we’re talking about Truffle-related changes, there are some exciting updates in GraalVM 21.2 for projects implementing languages and tools on GraalVM. Truffle libraries can now be prepared for ahead-of-time compilation <strong>without prior execution</strong>. See the docs for <a href="https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/library/ExportLibrary.html#useForAOT--">ExportLibrary.useForAOT</a> and the <a href="https://github.com/oracle/graal/blob/master/docs/graalvm-as-a-platform/truffle-framework/AOT.md#truffle-aot-tutorial">AOT Tutorial</a> for more details.</p><h3>JavaScript</h3><p>JavaScript implementation continues to add and update implementations of the most recent proposals like the <a href="https://github.com/tc39/proposal-set-methods">New Set Methods</a>, <a href="https://github.com/oracle/graaljs/blob/master/docs/user/OperatorOverloading.md">experimental operator overloading support</a>, or the RegExp Match Indices proposal. You can find the details on how to enable these in the release notes.</p><p>On top of that, Graal.js enhances the development experience with an option to track unhandled promise rejections in a polyglot Context. By default, the option is set to none, and unhandled promise rejections are not tracked, but you can configure and make your development life easier with the js.unhandled-rejections option.</p><h3>Ruby</h3><p>As always Ruby experienced a continuous, ongoing stream of compatibility and performance improvements. One very impactful added feature is the precise invalidation for Ruby methods and constants, by using per-name and per-class assumptions. When loading Ruby code, methods are added one by one due to Ruby semantics, and a lot of code is executed while loading files. With per-class assumptions (which is how it behaves in other Ruby implementations and in TruffleRuby prior to this change), it would invalidate all call sites that would call a method of that class. With precise invalidation, it only invalidates call sites that would actually need to call another method for the next call. This improves warmup on the real world code.</p><p>Along with these changes, we updated to Ruby 2.7.3, with the exception of resolvstdlib which was not updated (resolv in 2.7.3 has <a href="https://bugs.ruby-lang.org/issues/17748">bugs</a>). We also added a new TruffleRuby::ConcurrentMap data structure for use in <a href="https://github.com/ruby-concurrency/concurrent-ruby">concurrent-ruby</a>.</p><p>For lots of other changes and fixes, check <a href="https://github.com/oracle/truffleruby/releases/tag/vm-21.2.0">the release notes</a>.</p><h3>Python</h3><p>In this release we implemented _pickle as a faster version than the pure Python version, making serialization faster.</p><p>Improved support for interoperability with other languages for the dict type to work as you&#39;d expect it to work, which is now using Truffle hash implementation.</p><p>As always a lot of work focused on performance improvements especially during warmup and in shared engine configurations!</p><p>And there are lots of compatibility improvements too. Check release notes or more details.</p><h3>LLVM bitcode runtime</h3><p>There are some C++ related improvements in 21.2. We fixed the issue of the LLVM toolchain not working correctly for C++ on MacOS 11.3. We also added support for C++ virtual calls via cross-language interoperability.</p><p>The <strong>managed mode</strong> in GraalVM Enterprise also got better. We updated musl libcto to version 1.2.2, and improved compatibility with the existing native code bases by adding support for pthreads and pthread synchronization primitives in <a href="https://www.graalvm.org/reference-manual/llvm/NativeExecution/#limitations-and-differences-to-managed-execution-on-top-of-graalvm-enterprise">managed mode</a>.</p><h3>FastR</h3><p>FastR continues to work on compatibility, improving its support for packages in 2021–02–01 CRAN snapshot:</p><ul><li>testthat 3.0.1 is partially supported.</li><li>tibble 3.0.6 , vctrs 0.3.6, and data.table 1.13.6 are mostly supported.</li><li>support for dplyr 1.0.3, ggplot 3.3.3, and knitr 1.31 is a work in progress.</li></ul><p>If you’re interested in support for a particular package, please reach out!</p><h3>WebAssembly</h3><p>The WebAssembly runtime saw lots of compatibility improvements and some bug fixes to pass tests for as many NPM modules that use WebAssembly as currently possible.</p><h3>Java on Truffle</h3><p>One of the important things in GraalVM 21.2 for Java on Truffle is a new <strong>Hotswap Plugin API</strong>, which allows to reload the code without the need for restarting a running application. The API is intended to allow framework developers to have better control over reflecting changes in the application in response to source code edits in your IDE. It’s achieved by setting up appropriate hooks where the main design principle is that you can register various HotSwap listeners that will be fired on specified HotSwap events. For example, it is able to re-run a static initializer, run a generic post HotSwap callback or hooks when implementations for a certain service provider changes.</p><p>The most amazing thing about it is that the API consists of normal Java calls — much easier to integrate and maintain than any bytecode manipulation-based solutions.</p><p>For more details, check <a href="https://www.graalvm.org/reference-manual/java-on-truffle/hotswap-plugin/">the documentation on the plugin API</a>.</p><p>Another very welcome improvement made to 21.2 is the better bytecode dispatch which speeds up the interpreter used in Java on Truffle about <strong>15–30%</strong>. Interpreter speed is a very important factor in how fast your application warms up.</p><p>21.2 also saw improvements to interoperability for Java on Truffle objects implementing Map, Map.Entry, List, Iterator, or Iterable with the other languages including the Java host code.</p><h3>Tools</h3><p>VisualVM got a number of excellent improvements, including <strong>support for JDK 17</strong> and allowing functionality to be controlled from command line or other external tools. The latter enables a <strong>smooth integration between VisualVM and VSCode</strong> with the GraalVM extension installed. You can command VisualVM to profile your application right from the IDE.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8F-uaCOZ0a0UKyjSpGmDkA.png" /><figcaption>Note the VisualVM tab in the lower left corner with actions available directly from VS Code.</figcaption></figure><p>VisualVM now can also save a JFR recording from a live Java process, and has a new Lock Contention view in the Profiler tab. So if you’re using VisualVM for your day-to-day profiling needs now it’s more powerful than ever.</p><h3>Documentation</h3><p>Last but not least, we restructured the documentation for GraalVM that ends up on <a href="https://www.graalvm.org/">the website</a>. It’s now available in the <a href="https://github.com/oracle/graal/tree/master/docs">main project repository on GitHub</a>.</p><p>This means that it’s easier than ever to contribute to GraalVM and improve the lives of many other developers in the ecosystem. If you notice docs that could use clarification or incompletely describe your favorite features or tuning options, please consider sharing your expertise and helping the project with a pull request! If in doubt, here’s a short guide on how to do that: <a href="https://github.com/oracle/graal/tree/master/docs#readme">contributing to the docs.</a></p><p><em>Note, that the GraalVM Enterprise documentation is available on </em><a href="https://docs.oracle.com/en/graalvm/index.html"><em>the docs.oracle.com site</em></a><em>.</em></p><p>As with every release, we want to thank the GraalVM community for all the collaboration, feedback, and discussions, and for sharing your stories about how you use GraalVM.</p><p>As we mentioned before, the downloads are available, as always, on the website.</p><p>Please don’t hesitate to let us know of any and all feedback! There are several channels available to reach the team, pick whichever works for you best: <a href="https://graalvm.org/slack-invitation">Slack</a>, <a href="https://github.com/oracle/graal">GitHub</a>, or <a href="https://twitter.com/graalvm">Twitter</a>, or <a href="https://oss.oracle.com/mailman/listinfo/graalvm-users">send us an email</a>.</p><p>— GraalVM Team</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee2cce3b57aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/graalvm-21-2-ee2cce3b57aa">GraalVM 21.2 with lots of native image usability improvements</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Faster warmup, smaller downloads, JDK 16]]></title>
            <link>https://medium.com/graalvm/graalvm-21-1-96e18f6806bf?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/96e18f6806bf</guid>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jvm]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Tue, 20 Apr 2021 15:34:35 GMT</pubDate>
            <atom:updated>2021-04-20T17:56:55.642Z</atom:updated>
            <content:encoded><![CDATA[<h3>Faster warmup, smaller downloads, JDK 16 — GraalVM 21.1 is here!</h3><p>As with every release, we’re incredibly grateful to the GraalVM community for all the feedback, collaboration, GitHub issues, pull requests, and for spreading the word about GraalVM! <em>You</em> make GraalVM the increasingly successful and ever-improving project it is!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwb9zKyjb9PnQFhZo75hyQ.png" /><figcaption>GraalVM 21.1 is available for download</figcaption></figure><p>GraalVM 21.1 is available for download from these websites:</p><ul><li><a href="https://www.oracle.com/downloads/graalvm-downloads.html">GraalVM Enterprise Edition</a></li><li><a href="https://www.graalvm.org/downloads">GraalVM Community Edition</a></li></ul><p>In this article we want to highlight some of the most important improvements in GraalVM 21.1. If you’re interested in a particular component and would like to see a detailed list of changes, please consult the <a href="https://www.graalvm.org/release-notes/21_1/">21.1 release notes</a>.</p><p>And if your preferred way to learn is videos rather than text, here’s a live stream discussing the updates in GraalVM 21.1:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fk_NNjh7QopQ&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dk_NNjh7QopQ&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2Fk_NNjh7QopQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9316a6b81fbe56bca6838c49faabf8d2/href">https://medium.com/media/9316a6b81fbe56bca6838c49faabf8d2/href</a></iframe><h3>Platform Updates</h3><p>Oracle GraalVM Enterprise Edition 21.1 is based on Oracle JDK version 1.8.0_291 and Oracle JDK version 11.0.11. GraalVM Community Edition in 21.1 is based on OpenJDK version 1.8.0_292 and OpenJDK version 11.0.11.</p><p>GraalVM 21.1 introduces new experimental binaries based on JDK 16 for both Enterprise and Community editions based on JDK 16.0.1.</p><p>The experimental status means that all components in the JDK 16 based binaries are considered experimental regardless what their status is in other distribution versions.</p><p>The JIT mode for Java applications is perhaps the most tested capability for these builds, so if you are interested in running your Java applications with the GraalVM compiler or are currently using the JVMCI compiler in any other JDK 16 OpenJDK builds, consider trying out the GraalVM binaries. These include the latest OpenJDK changes and the latest GraalVM compiler changes which is the best of both worlds setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cOaEyXS3FTuQ6YCw7Ojk1Q.png" /><figcaption>GraalVM offers experimental JDK 16 based builds now</figcaption></figure><p>Java 16 is the current release of Java and we are looking forward to providing support for the upcoming Java 17 LTS release.</p><p>Note that due to the decommissioning of the aging macOS 10.7 build infrastructure, GraalVM Community Edition releases based on JDK 8 are no longer being built.</p><p>Node.js included in GraalVM 21.1 has been updated to 14.16.1, which is recommended for most users.</p><p>There’s one more significant change regarding Node in GraalVM. As of GraalVM 21.1, Node.js support is no longer included in the base GraalVM download. It’s now a separate component that you can install with the gu install nodejs command. JavaScript support continues to be a part of the base download, it&#39;s just the Node.js support that&#39;s installable separately. This change is for speed and clarity — it aims to reduce the size of the base GraalVM download, and to reduce confusion among some users who want to use GraalVM primarily as their main JDK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*ZpPWQy_n6jQ6D5dJagep3g.png" /><figcaption>GraalVM CE 21.1 download is smaller than in the previous release.</figcaption></figure><h3>Compiler Updates</h3><p>Updates to the compiler are especially exciting because they improve GraalVM across the board since the compiler underpins the performance of all the various languages supported on GraalVM!</p><p>In 21.1 there are two particularly interesting compiler improvements:</p><p>One new optimization eliminates unneeded memory barriers on sequential volatile writes on x86. Numerous volatile writes sometimes occur in a sequence after the code has been inlined. The GraalVM compiler now omits the memory barrier for all but the last write in the sequence, nicely speeding up methods like ConcurrentHashMap.transfer().</p><p>The other main improvement, which can help increase performance on similar workloads, is more of a fix rather than a whole new optimization. In the following example method, also from ConcurrentHashMap, Unsafe is used to get an Object from an array. With this fix, the GraalVM compiler eliminates the cast:</p><pre>static final &lt;K,V&gt; Node&lt;K,V&gt; tabAt(Node&lt;K,V&gt;[] tab, int i) {      <br>  return (Node&lt;K,V&gt;)U.getObjectVolatile(<br>                      tab,                                        <br>                      ((long)i &lt;&lt; ASHIFT) + ABASE); <br>}</pre><h3>Loops Updates</h3><p>This release includes support in the GraalVM Enterprise compiler for vectorizing loops that have the hashCode-like pattern. Hashcode is often computed with an idiom like: hash = c * hash + array[i] , which the compiler can now recognize and vectorize.</p><p>We also want to highlight two new GraalVM Enterprise features related to inverted loops. First, the compiler detects inverted loops as counted loops:</p><p>Here’s an example of a tail-counted, inverted:</p><pre>int i = 0; <br>do {    <br>  // loop body    <br>  i++; <br>} while (i &lt; limit);</pre><p>Note that the loop limit check is at the end of the loop body. GraalVM Enterprise now detects such loops as counted, enabling them to be analyzed and optimized like all other counted loops making them subject to full unrolling, partial unrolling, guard optimization, and vectorization. This new capability can be disabled with the following option:</p><p>-Dgraal.DetectInvertedLoopsAsCounted=false.</p><p>We have seen performance improvements of <strong>up to 40%</strong> for applications with inverted loops in hot code paths! A prominent example of frequent inverted loop usage is the LLVM bitcode runtime in GraalVM. It compiles LLVM IR, and the internal loop representation in Clang often resembles inverted loops.</p><p>The second improvement in this regard is a novel loop inversion optimization. This adds compiler support to GraalVM Enterprise to generate inverted loops from regular ones. Inverted loops have superior characteristics for instruction-level parallelism and optimization capabilities compared to regular, head counted loops.</p><p>Consider this example loop:</p><pre>int limit = ...; // e.g. a parameter int i = 0; <br>while (i &lt; limit) {   <br>  array[i] += 10;   <br>  i++; <br>}</pre><p>Every iteration of this loop has to perform an index bounds check and throw an ArrayIndexOutOfBoundsException if it is above the array length. The guard motion optimization in GraalVM Enterprise will generate an optimized version of the guard that can be hoisted before the loop:</p><pre>int limit = ...; <br>int i = 0; </pre><pre>// transfer to interpreter to raise ArrayIndexOutOfBoundsException<br>if (limit &gt;= array.length || limit &lt; 0) deoptimize();  <br>while (i &lt; limit) { <br>  array[i] += 10;   <br>i++; <br>}</pre><p>The disadvantage of this code is that the guard is checked even if the loop is never entered. It isn’t the best use of time and resources. This <em>could be </em>solved by replicating the check that determines if the loop will be entered, but this is an extra work and increases code size. By inverting the loop, however, we get:</p><pre>int limit = ...;<br>int i = 0;<br>if (i &lt; limit) {<br>  // landing pad<br>  if (limit &gt;= array.length || limit &lt; 0) deoptimize();<br>  do {<br>    array[i] += 10;<br>    i++;<br>  } while (i &lt; limit);<br>}</pre><p>This creates a natural landing pad for guard motion and loop invariant expressions before the loop that is only executed if the original loop is executed. We have seen performance improvements of <strong>up to 30%</strong> for micro benchmarks exercising the inverted loop shape. Not too shabby!</p><h3>Native Image</h3><p>As in every release, there are numerous fixed issues and compatibility improvements in Native Image, along with new features.</p><p>GraalVM 21.1 adds support for multiple locales in Native Image. Now you can specify at build time which locales should be included in the generated executable. For example, to switch the default locale to German and also include French and English, use -H:DefaultLocale=de -H:IncludeLocales=fr,en. All locales can be included via -H:+IncludeAllLocales. ResourceBundles are included by default for all selected locales, but this can be changed by providing a locale-specific substring when requesting the bundle.</p><p>Further improvements — such as updating the Native Image assisted configuration agent to help with locale configurations, and loading bundles from an external storage — are planned for the next release.</p><p>We also deprecated the use of the --enable-all-security-services option. It is no longer necessary as security services are now registered automatically when usage is detected by static analysis during build time.</p><p>This release improves support for Native Image on Windows. Applications built with Native Image now do file globbing on parameters. Globbing is interpreting standard special characters like * and ? to match the filenames.</p><p>There are also other nice additions, like added reporting on the Native Image build in order to produce multiple artifacts, with results written to the &lt;image-name&gt;.build_artifacts.txt file. Also, multiple different Native Image compiled artifacts are can be used in the same process. For example, an application built with Native Image can use a Native Image generated shared library.</p><h3>Polyglot Runtime</h3><p>If you’re using any of the Truffle languages — JavaScript, Python, Ruby, R, Webassembly, Java on Truffle, TruffleSqueak, LLVM bitcode, etc. — changes to the polyglot runtime are important to your applications!</p><p>The polyglot runtime in GraalVM 21.1 has multi-tier compilation enabled by default. This feature was first introduced in 20.3 as an experimental option. With it enabled, Truffle uses two tiers of compilation for polyglot languages. The first tier is optimized for compilation speed and reuses the GraalVM compiler economy configuration to perform speedy compilations with method inlining of trivial methods only. The second tier compiles with all GraalVM’s compiler optimizations enabled and is performed after the first tier compilation has completed. Our benchmark results show that this improves warmup for most languages significantly.</p><p>In the adjacent article we look into <a href="https://medium.com/p/5fbc65f92402">more details about multi-tier compilation in GraalVM 21.1</a> and explore its impact on various benchmarks and Truffle languages.</p><p>To support flexibility of the multi-tier compilation, 21.1 also introduces new experimental flags to set the compilation thresholds: --engine.FirstTierCompilationThreshold sets the threshold for the first, and --engine.LastTierCompilationThreshold for the second tier. If multi-tier compilation is disabled, --engine.SingleTierCompilationThreshold may be used. The original existing option, --engine.CompilationThreshold, is now deprecated and will be taken out behind the barn and set free (removed) in a future release.</p><p>On top of improving warmup with the multi-tier compilation, this release also includes a new experimental compilation queue implementation inspired by HotSpot. This implementation is not yet enabled by default, but you can try it on your workloads using the --engine.TraversingCompilationQueue option. Give it a whirl. It is expected to reduce warmup time even more.</p><p>Your mileage may vary and it all heavily depends on the workload and details of your codebase, but startup and warmup performances of Truffle languages should show significant improvements over previous releases!</p><h3>For Polyglot Embedding/Guest Language Users</h3><p>If you’re using Truffle languages from a Java application, the changes listed here may be important for you.</p><p>One interesting new capability added in GraalVM 21.1 is an implementation of the guest languages safepoints. Use Context.safepoint() to cooperatively poll thread local actions of a polyglot context while a host method is executed. This allows to check for interruption or cancellation from within the Context.</p><p>This release also adds a new experimental sandbox option to GraalVM Enterprise to constrain memory usage of the guest language. Use the --sandbox.MaxHeapMemory=&lt;size&gt; option that controls the maximum heap memory that a guest application can retain during its run. This feature is currently only supported on HotSpot. More information on how to use heap memory limits can be found in the <a href="https://www.graalvm.org/reference-manual/embed-languages/#configure-sandbox-resource-limits">sandbox documentation</a>.</p><p>There are three welcome additions to the Truffle polyglot support for data-structures: byte buffer-like, iterator and iterable-like, and map-like data structures! Support for these features in the individual languages may vary as they need to implement the changes as well, but in a nutshell it means the following:</p><ul><li>java.nio.ByteBuffer implementations work like native guest language buffers.</li><li>java.util.Iterator and java.util.Iterable implementations work like guest language iterators.</li><li>java.util.Map implementations are handled to make them look like guest language hash maps.</li><li>guest language iterators and hash maps can be mapped to Java ones with Value.as(Iterator.class), Value.as(Map.class).</li><li>Value class API includes new methods for accessing these new data structures: Value.hasBufferElements(), Value.isIterator() and Value.hasIterator(), and Value.hasHashEntries().</li></ul><p>Of course, these features can be controlled with the HostAccess.Builder methods allowMapAccess, allowBufferAccess, allowIteratorAccess, and allowIterableAccess. This means that if a language implementation supports it, you can pass a Java Map to the context and access its entries as if it was a native guest language map.</p><h3>JavaScript</h3><p>As we mentioned above in the platform updates, the version of Node.js GraalVM supports has been updated to 14.16.1. In this release, the node and npm binaries are not included in the base download, but are instead available to be installed separately.</p><p>Installing the Node.js component is done using the gu utility like for all other optional components: gu install nodejs</p><pre>[opc@ol8-demo 21.1]$ gu install nodejs<br>Downloading: Component catalog from <a href="http://www.graalvm.org/">www.graalvm.org</a><br>Processing Component: Graal.nodejs<br>Downloading: Component nodejs: Graal.nodejs  from github.com<br>Installing new component: Graal.nodejs (org.graalvm.nodejs, version 21.1.0)<br>... </pre><p>Note that if you want to use node for running polyglot programs not in the JVM mode, which is turned on by the --jvm command line option, then you need to rebuild the polyglot shared library to include all languages you want to have access to. This can be done by running gu rebuild images or following the instructions in the gu install output. In JVM mode, all installed languages can be dynamically loaded so rebuilding is not necessary.</p><p>JavaScript in GraalVM 21.1 includes Truffle’s support for iterators, iterables, and byte buffers, which allows JavaScript iterators to be used via the Value API hasIterator(), getIterator(), hasIteratorNextElement(), getIteratorNextElement(); iterable objects from other languages to be iterated in GraalVM&#39;s JavaScript runtime, e.g., via for-of loops and vice versa; for the host ByteBuffers and buffers from other languages to be used with JavaScript typed arrays, e.g., new Uint8Array(foreignBuffer), and DataView without copying; and to access ArrayBuffers via the Value API: readBuffer*, writeBuffer*.</p><p>Support for Maps is also included so you can iterate them with for in/ofloops and new Map(hash), Array.from(hash), etc. Even better if the --js.foreign-hash-properties option is enabled (which it is by default), then foreign hash maps can also be accessed using hash[key], hash.key, {...hash}. With this support, the following example now works:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88b7a7b8e622fc0fe4c876c863a815e4/href">https://medium.com/media/88b7a7b8e622fc0fe4c876c863a815e4/href</a></iframe><p>It prints the wonderfully exciting:</p><pre>[opc@ol8-demo 21.1]$ javac Main.java &amp;&amp; java Main <br>GraalVM <br>21.1 <br>Map(2) {&quot;hello&quot; =&gt; &quot;world&quot;, 1 =&gt; 42}; world</pre><p>On top of all of these excellent improvements, this release also adds the first experimental version of the WebAssembly JavaScript Interface, which allows invoking WebAssembly programs from within JavaScript. This feature is enabled by the --js.webassembly option.</p><h3>Ruby</h3><p>As with every release, GraalVM 21.1 reflects a solid amount of Ruby compatibility and performance work, including more complete support of Ruby 2.7 (remaining work can be seen in the <a href="https://github.com/oracle/truffleruby/issues/2004">GitHub issue</a>).</p><p>Multi-tier compilation is now enabled by default, which significantly improves warmup. Other items — checks for recursion, random number generation, some cases of using class variables, irb, and pasting code into irb — all saw improvements in this release as well.</p><p>GraalVM 21.1 also includes improved support for C extensions. Installing gems which use C extensions that link to static libraries now generally work when prepending the GraalVM LLVM toolchain to your PATH. With this release, GraalVM now defaults to the vendored libxml2 and libxslt gems when installing nokogiri, similar to CRuby, which means the corresponding system packages are no longer needed.</p><p>Also, if you’re using standalone builds of TruffleRuby, note that it is now based on JDK 11, up from JDK 8 which it used previously.</p><h3>Python</h3><p>One of the more significant improvements in GraalVM 21.1 for Python is the enhanced support for Java subclassing and new interop APIs for better Jython migration path. Iteration over Python types from Java, catching and re-throwing Java exceptions in Python code, as well as implementing Java abstract classes and interfaces from Python are often-requested Jython features that GraalVM now provides, making the migration easier.</p><p>Another very exciting addition is SSL support. Now you can install packages and their dependencies with pip just as with CPython:</p><pre>$ graalpython -m venv env <br>We&#39;re not using symlinks in a Graal Python venv </pre><pre>$ source env/bin/activate </pre><pre>$ pip install pygal <br>Collecting pygal   <br>Downloading pygal-2.4.0-py2.py3-none-any.whl (127 kB)      <br>|████████████████████████████████| 127 kB 983 kB/s <br>Looking for Graal Python patches for pygal <br>Installing collected packages: pygal <br>Looking for Graal Python patches for pygal <br>Successfully installed pygal-2.4.0</pre><p>There’s also a new completely native backend for Posix API, which provides better performance and improved compatibility for filesystem access.</p><p>And we wrap up the list of exciting new features in GraalVM 21.1’s Python support with the addition of multi-threading with Global Interpreter Lock (GIL). GraalPython supports multi-threading to the same extent as CPython, that is, there is only concurrency, not parallelism for most workloads.</p><h3>LLVM bitcode runtime</h3><p>There are, as usual, oodles of performance improvements and compatibility fixes for the LLVM runtime, but in 21.1, there are also a few new features.</p><p>Pointers to foreign “buffer-like” objects, for example, JavaScript’s ArrayBuffer, can be transparently accessed like native buffers.</p><p>GraalVM now supports loading bitcode modules with regular dlopen in addition to the Polyglot API.</p><p>The option was added to support building GraalVM or native executables with “native mode” completely removed, making --llvm.managed mode the only available option. This improves security in certain scenarios.</p><h3>FastR</h3><p>In this release, GraalVM’s R implementation mostly saw compatibility work.</p><p>GraalVM 21.1 upgrades FastR to R version 4.0.3, which means FastR runtime mostly compatible with R 4.0.3. It also migrated to new versions of the base and recommended packages, and implements some of the new features of R 4.0.3. See the <a href="https://github.com/oracle/fastr/blob/master/CHANGELOG.md#2110">changelog</a> for all the details.</p><p>We also upgraded the CRAN snapshot, used by default by install.packages, to 2021-02-01. Support for new versions of some of the most popular packages on FastR is a work in progress that will improve in future releases with known issues in in dplyr 1.0.3, ggplot 3.3.3, and knitr 1.31.</p><h3>WebAssembly</h3><p>GraalVM 21.1 has two main improvement themes: compatibility and performance. Following that philosophy, JavaScript and WebAssembly are now integrated much better than before, now allowing JavaScript to invoke WebAssembly. Basic WASI functions are now implemented, which allows manipulating files and accessing the file system through the Truffle file-system layer… and performance results are incredible!</p><p>Besides improving the speed of the standalone GraalWasm launcher and peak performance of WebAssembly on GraalVM in general, the main highlight is the <strong>more that 10x</strong> performance improvement of the interpreter, which should be most evident in short-running programs or in code that’s invoked just a few times, not enough to trigger JIT compilation. This is not a drill. We repeat — 10x performance improvement!</p><h3>Java on Truffle</h3><p>The GraalVM 21.0 release was the first for Java on Truffle. Since then, we’ve concentrated on compatibility and making sure it’s useful for running typical applications in typical development scenarios.</p><p>For example, we fixed a massive slowdown when instruments are enabled, so debugging your application on Java on Truffle doesn’t feel slow anymore. It was not just a single issue, but a number of edge cases in the Java Debug Wire Protocol (JDWP) support that required fixing, and it was all worth it, speeding up applications with the debugger enabled sometimes by a ridiculous <strong>200x</strong>!</p><p>We also added support for signal handlers, which means that shutdown hooks registered in the application now run as expected when an application stops.</p><p>Work always continues on improving enhanced HotSwap capabilities. For example, as of this release, reflective access and MethodHandles now follow method changes.</p><h3>Tools</h3><p>Tooling is a very important part of the GraalVM Ecosystem. In every release we’re trying to improve the developer experience by improving the tools that are part of the GraalVM distribution, including the debugger and profilers, etc.. GraalVM 21.1 is no exception.</p><p>For example, VisualVM now also <strong>works on JDK 16</strong> and has support for running on Apple M1 chips.</p><p>We’re happy to announce the new version of the <a href="https://www.graalvm.org/tools/vscode/">VS Code GraalVM Extensions</a>, which includes a collection of features to make working with GraalVM, Java, and Micronaut applications easier:</p><ul><li>Added unit test results visualization</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZMes57g01H2XcOcruQTi-Q.png" /><figcaption>VS Code visualizing results of the unit tests in the testing view</figcaption></figure><ul><li>Improved Micronaut support: YAML support and content assistance for configuration files, and more Java code editing features</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_aA1rzkVMjKMCuRtxI0esQ.png" /><figcaption>Configure Micronaut applications in VS Code with the improved content assist</figcaption></figure><ul><li>Added new supported refactorings for Java code</li><li>Added support for Docker build commands for Micronaut projects</li></ul><h3>Whew!</h3><p>While this is a much longer post than we typically write for a release, these are still only <em>some</em> of the exciting improvements in GraalVM 21.1!</p><p>Again, as always, the downloads are available on the website.</p><p>Please don’t hesitate to send us any and all feedback! There are several channels available to reach the team; pick whichever works best for you: <a href="https://www.graalvm.org/slack-invitation">Slack</a>, <a href="https://github.com/oracle/graal">GitHub</a>, or <a href="https://twitter.com/graalvm">Twitter</a>! We’re always happy to hear from you!</p><p>Until next time!</p><p>— GraalVM Team</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96e18f6806bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/graalvm-21-1-96e18f6806bf">Faster warmup, smaller downloads, JDK 16</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraalVM 21.0: Introducing a New Way to Run Java]]></title>
            <link>https://medium.com/graalvm/graalvm-21-0-introducing-a-new-way-to-run-java-df894256de28?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/df894256de28</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[graalvm]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Tue, 19 Jan 2021 18:53:04 GMT</pubDate>
            <atom:updated>2021-01-19T18:53:04.918Z</atom:updated>
            <content:encoded><![CDATA[<p>Today we’re happy to announce the GraalVM 21.0 release.</p><p>With the recent winter holidays break this release was in development for a brief time, however it still offers a number of improvements and new exciting features for the whole GraalVM ecosystem.</p><p>As with every release, we’re greatly thankful to the wonderful GraalVM community for all the feedback, collaboration and the discussions around the issues, sending pull requests, and last but not least spreading the word about the GraalVM project and how it helps your project. Together, we make GraalVM extraordinary!</p><p>GraalVM 21.0 is available for downloading right now:</p><ul><li><a href="https://www.graalvm.org/downloads">GraalVM</a></li><li><a href="https://www.oracle.com/downloads/graalvm-downloads.html">GraalVM Enterprise</a></li></ul><p>In this article we want to talk about some of the most notable changes in GraalVM 21.0. There are many components to GraalVM and every release brings improvements and fixes to all of them. So for a more detailed list of changes, please consider the <a href="https://www.graalvm.org/docs/release-notes/">release notes</a> on the website or the change logs of the individual components.</p><h3>Platform Updates</h3><p>As usual, the release bumps up the version of the JDK used for the GraalVM builds. GraalVM Community Edition in 21.0 is based on OpenJDK version 1.8.0_282 and OpenJDK version 11.0.10, and the GraalVM Enterprise on Oracle JDK version 1.8.0_281 and Oracle JDK version 11.0.10.</p><h3>Java on Truffle</h3><p>The most exciting addition in GraalVM 21.0 is the new component which implements Java on Truffle. Java on Truffle is a JVM, realized with the <a href="https://www.graalvm.org/graalvm-as-a-platform/language-implementation-framework/">Truffle framework</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dIdeW11ahafB_ofVEIk-LQ.jpeg" /><figcaption>Image source: <a href="https://unsplash.com/photos/Al8ypubs25k">Jess Eddy, Unsplash</a></figcaption></figure><p>Java on Truffle is currently marked as experimental. However, even in this initial release state it offers very interesting capabilities and makes Java (and other JVM languages) possible to run through the infrastructure that powers all other GraalVM languages.</p><p>Install it with gu install espresso, and give it a spin by running your favourite Java app with java -truffle.</p><p>Read more about Java on Truffle in <a href="https://medium.com/p/215531e3f840">this adjacent article</a> providing more details, motivation, and use cases for how you can experiment with using Java on Truffle now.</p><h3>Native Image</h3><p>One of the things possible now is the use of <strong>Java serialization in the native image binaries</strong>. Serialization usage needs to be configured, just like the other dynamic features, and classes which can be serialised/deserialized needs to be known during the build time. The configuration can be generated using the <a href="https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/#assisted-configuration-of-native-image-builds">assisted configuration with</a><a href="https://www.graalvm.org/reference-manual/native-image/BuildConfiguration/#assisted-configuration-of-native-image-builds">javaagent</a>, so you don’t have to create it from scratch.</p><p>Consider, for example, if you have a class like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c01dd11047afdf7d1833957e8ee47e2/href">https://medium.com/media/7c01dd11047afdf7d1833957e8ee47e2/href</a></iframe><p>It serializes, deserializes and prints the Fibonacci numbers. You can compile and run it withjavaagent:</p><pre>javac Main.java<br>java -agentlib:native-image-agent=config-output-dir=config/META-INF/native-image Main</pre><p>Now in the config directory, we can see the JSON file showing which classes will be included for serialisation:</p><pre>cat config/META-INF/native-image/serialization-config.json <br>[{   &quot;name&quot;:&quot;java.lang.Long&quot;        },   <br> {   &quot;name&quot;:&quot;java.lang.Number&quot;      },   <br> {   &quot;name&quot;:&quot;java.util.ArrayList&quot;   } <br>]</pre><p>All that is left to build the native image is just running the command: native-image -cp .:config Main. And voila, the list of the Fibonacci numbers will be serialized/deserialized when you run the result.</p><p>In addition to this very important change that brings native image capabilities to more Java programs much easier than before, 21.0 has an improved <strong>method handle invocation support</strong>. Most of the use cases of method handles should be working now. They do require the configuration, but the tracing agent can also provide it for you.</p><p>Speaking of the configuration agent with the configuration provided by it, you can build <strong>native images of the AWT and Swing applications</strong> on Linux (experimental). Other platforms aren’t supported yet, but it’s an excellent first step.</p><h3>Truffle</h3><p>Truffle added the HostCompilerDirectives annotation for directives that guide the optimizations in host compilations of the Truffle interpreters:</p><ul><li>HostCompilerDirectives.BytecodeInterpreterSwitchto denote methods that contain the instruction-dispatch switch in bytecode interpreters</li><li>HostCompilerDirectives.BytecodeInterpreterSwitchBoundary to denote methods that do not need to be inlined into the bytecode interpreter switch.</li></ul><h3>JavaScript</h3><p>Node.js in the distributions of GraalVM got updated to 12.20.1.</p><p>Compatibility is always priority number one, and this release enables the following ECMAScript 2021 mode/features by default:</p><ul><li>Class fields</li><li>Promise.any</li><li>String.prototype.replaceAll</li><li>Logical Assignment Operators</li></ul><p>Even more, if you would run the JavaScript engine in the ECMAScript 2022 mode enabled by the --js.ecmascript-version=2022 option, you even get the implementation of the <a href="https://tc39.es/proposal-relative-indexing-method/">relative indexing method</a> proposal.</p><h3>Ruby</h3><p>In GraalVM 21.0, the Ruby implementation now targets compatibility with Ruby 2.7.2. Most Ruby 2.7 features and changes are implemented (see <a href="https://github.com/oracle/truffleruby/issues/2004">this GitHub issue</a> for the details).</p><p>In addition to that, in the short time this release was in development, there were some performance improvements, notably methods like MatchData#length, Array#sample, String#inspect, are now more efficient.</p><p>A few issues around the $~ special variable were also fixed.</p><p>Some interop method under Truffle::Interop have been renamed to match better the naming of InteropLibrary (#2139).</p><p>Note that the new IRB version is quite slow when copy/pasting code into it. This is due to an inefficient io/console implementation which will be addressed in the next release. A workaround is to use irb --readline, which disables some IRB features but is much faster for copy/pasting code.</p><h3>Python</h3><p>The team continues to work on the compatibility both with Python native libraries and the Jython implementation.</p><p>For example, 21.0 saw the addition of the <a href="https://www.javadoc.io/static/org.python/jython/2.7.2/org/python/modules/jarray.html">jarray module</a> for compatibility with Jython. It also sports fixes to avoid possible memory leaks and crashes when running NumPy in certain setups and improved support for Pandas.</p><p>For more details about the performance updates, and other fixes, check out the <a href="https://github.com/oracle/graalpython/blob/master/CHANGELOG.md#version-2100">changelog</a> in the repo.</p><h3>LLVM bitcode runtime</h3><p>One of the major areas for improvement for the LLVM bitcode runtime implementation is warmup. In 21.0 we improved not only the AST sharing — sharing the internal representation of the program among several contexts in a single engine, but also introduced support for the auxiliary engine caching. On top of what the AST sharing provides, the auxiliary engine caching allows persisting of shared code across process boundaries.</p><h3>GraalWASM</h3><p>The Webassembly interpreter sometimes flies under the radar, but there’s always active work happening to make it better, faster, and more secure. In 21.0 we optimized the Graalwasm interpreter making the warmup better and overall peak performance of <strong>interpreting WebAssembly up to 20x faster</strong>. We also pass most of the official WebAssembly specification suite now, and we are working on fixing several minor remaining edge-cases.</p><h3>Tools</h3><p>Since GraalVM 21.0 the gu utility becomes more powerful and can be used to update your local <strong>GraalVM installation to a newer version</strong>, or upgrade from the Community to Enterprise Edition. Please refer to the documentation for <a href="https://www.graalvm.org/reference-manual/graalvm-updater#upgrade-graalvm">more details</a>.</p><p>Also, as a part of the GraalVM 21.0 release, we’re happy to announce the <strong>GraalVM Extension Pack for Visual Studio Code</strong>. While being a Technology Preview release, it already provides many features to boost your Java 8+, JavaScript, Python, Ruby, R, and Micronaut productivity in the VS Code environment. The Extension Pack is immediately available on the Visual Studio Code Marketplace and ready to be installed right from your VS Code — just type GraalVM in the Extensions: Marketplace view, select the GraalVM Extension Pack and click the Install button. While installing, you can read <a href="https://medium.com/p/ab196354faeb">more details on the VS Code extensions</a> in a separate article.</p><p>Note that these are only a part of the improvements in the GraalVM 21.0! Please read a more detailed outline of the new and noteworthy features in the release notes, and for the components you’re most interested in the changelogs are an invaluable source of information!</p><p>As we mentioned before, the downloads are available as always for <a href="https://www.graalvm.org/downloads">GraalVM 20.3.1</a> and <a href="https://www.oracle.com/downloads/graalvm-downloads.html">GraalVM Enterprise 20.3.1</a>.</p><p>Even if you don’t plan to upgrade right now, which you should, grab the binaries and <a href="https://www.graalvm.org/java-on-truffle">try Java on Truffle</a>, it is a really cool addition to the ecosystem.</p><p>Please don’t hesitate to let us know on any and all feedback! There are several channels available to reach the team, pick whichever works for you best: <a href="https://www.graalvm.org/slack-invitation">Slack</a>, <a href="https://medium.com/github.com/oracle/graal">GitHub</a>, or <a href="https://medium.com/twitter.com/graalvm">Twitter</a>!</p><p>— GraalVM Team</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df894256de28" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/graalvm-21-0-introducing-a-new-way-to-run-java-df894256de28">GraalVM 21.0: Introducing a New Way to Run Java</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java on Truffle — Going Fully Metacircular]]></title>
            <link>https://medium.com/graalvm/java-on-truffle-going-fully-metacircular-215531e3f840?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/215531e3f840</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[graalvm]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Tue, 19 Jan 2021 18:52:29 GMT</pubDate>
            <atom:updated>2021-03-02T15:45:43.796Z</atom:updated>
            <content:encoded><![CDATA[<h3>Java on Truffle — Going Fully Metacircular</h3><p>Up until now, GraalVM has offered two ways to run Java programs: using the Java HotSpot VM with the GraalVM JIT (just-in-time) compiler, and compiled to a native executable using GraalVM Native Image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dIdeW11ahafB_ofVEIk-LQ.jpeg" /></figure><p>Today, we’re happy to announce a new way to run Java on GraalVM. GraalVM 21.0 introduces a new installable component, named espresso, which provides a JVM implementation written in Java.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWeivN_3IbdjJ9GkJXxHzA.png" /><figcaption>Java on Truffle place in the GraalVM architecture</figcaption></figure><p>Espresso makes it possible to run Java code via the Truffle framework elevating Java to the level of the other languages supported on GraalVM.</p><h3>Try it out</h3><p>Trying Java on Truffle out is extraordinary straightforward. It is available as a component installable into a base GraalVM distribution with a gu command.</p><pre>gu install espresso<br>gu install -L espresso-installable.jar # if downloaded manually</pre><p>After the installation to run your favorite app on Java on Truffle you just need to pass -truffle to the java command.</p><pre>java -truffle -jar myApp.jar</pre><p>Download Java on Truffle and give it a spin! There are <a href="https://www.graalvm.org/reference-manual/java-on-truffle/demos">some example apps</a> with the instructions that illustrate the particular capabilities of Java on Truffle.</p><p><em>Note</em> that current raw performance of Java on Truffle isn’t representative of what it will be capable of in the near future. The peak performance is several times lower than running the same code in the usual JIT mode. The warmup also hasn’t been optimized yet. We focused in this initial release entirely on the functionality, compatibility, and making Java on Truffle open source available for a broader community.</p><p>Expect performance, both warmup and peak performance to <strong>increase rapidly</strong> in each of our upcoming 21.x releases.</p><p>Let’s now look in more details what Java on Truffle is, explore some notable use cases where it can help you, and try to place the project into the larger GraalVM and Java ecosystems.</p><h3>Java on Truffle</h3><p>Java on Truffle is a JVM implemented using the Truffle language implementation framework. It provides all core components of a Java virtual machine:</p><ul><li>Bytecode interpreter</li><li>Bytecode verifier</li><li>Single-pass .class file parser</li><li>Simple object model</li><li>Java Native Interface (JNI) implementation in Java</li><li>Virtual Machine Implementation in Java</li><li>Java Debug Wire Protocol (JDWP)</li></ul><p>A very important detail of this implementation is that it’s implemented in Java. <strong>Java on Truffle is Java on Java</strong>! Self-hosting is the holy grail of Java virtual machine research and development.</p><p>What it can do is run Java programs. Well, programs written in other JVM languages too of course. As you can see from the list above, it also supports the debug protocol, so you can debug Java applications using it too.</p><p>Java on Truffle is available for both Java 8 and Java 11 based GraalVM distributions, so technically you can use it as a replacement for the JVM of your choice. Java on Truffle is currently experimental and not very fast yet, so it is not recommended for production workloads today, but let’s explore what you <strong>can </strong>get from running applications with Java on Truffle.</p><h3>Java on Java</h3><p>As we mentioned previously Java on Truffle is implemented in Java. It’s a virtual machine implementation, so in order to actually run Java code it needs access to the class library and the native libraries and methods JDK provides. Java on Truffle reuses the JARs and native libraries from the GraalVM distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*NBWPe88nb3-qihcykg0ebw.jpeg" /><figcaption>Java on Truffle is a metacircular Java VM.</figcaption></figure><p>Being implemented in Java and being able to run Java gives Java on Truffle a very interesting property: it can run itself. Indeed, Java on Truffle is a metacircular VM, it can run itself several levels deep (albeit slower and slower every time).</p><p>Being a Java program gives a number of advantages. One of them is ability to be compiled to the native executable with the native image, we’ll explore an interesting use case for that in the following chapter.</p><p>Another advantage is that the code is nice, familiar and understandable to Java developers. Consider going to the GitHub repository and looking at the source code for it. Your day-to-day tools work for it, your IDE supports it, you can explore the code base the same way you explore any other Java dependecies. This transparency and familiarity should allow Java on Truffle be efficient at rapidly changing to the better.</p><h3>Embedding 11 in 8</h3><p>Java on Truffle is an actual JVM, and it’s also a Java program, which means you can run it within another Java program. This opens very interesting avenues for compartmentalisation of different components in your applications. For example, if you point Java on Truffle to a JDK11 distribution it can run Java 11. With access to Java 8, it becomes Java 8. When you have both distributions available, you can run Java on Truffle in the context of a Java 8 app and use it to run Java 11 byte code, and vice versa. If there’s a library that is only available for Java 8, you can migrate to a newer base JDK and still run that particular library, with some programmatic efforts to establish the interoperability, in the compatible JDK 8 within the same Java process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*ugG7XgC1r-Q2ZX-InqU0aQ.gif" /></figure><h3>Mixing AOT and JIT</h3><p>Since Java on Truffle, Truffle, the GraalVM compiler and all other necessary components to run Java on Truffle efficiently are all written in Java, it is possible to build a native image executable with the infrastructure to run Java on Truffle.</p><p>This means that you can take a Java app, build a JVM into it, and then run that app either on a JVM or as a native image. Note that in the latter case, Java on Truffle can actually execute arbitrary Java code which doesn’t necessarily need to be known at the build time.</p><p>That’s right, Java on Truffle can bring the JIT compiler and the dynamic Java runtime to an ahead-of-time compiled binary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c2VdWWLv_xc0jH1OVnuObw.png" /><figcaption>Java on Truffle allows adding dynamic language features to apps build with native image</figcaption></figure><p>We’ve prepared a <a href="https://github.com/graalvm/graalvm-demos/tree/master/espresso-jshell">sample application</a> to illustrate this concept. There’s a JShell implementation example that takes a normal JShell app, which consists of two separate parts: frontend CLI app and the backend computation engine, and replaces the latter with the Java on Truffle implementation.</p><p>You can also follow this demo in a video tutorial:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZ0Rb6QRyQVw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ0Rb6QRyQVw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZ0Rb6QRyQVw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/75f90c8093e5e70922c076da50454868/href">https://medium.com/media/75f90c8093e5e70922c076da50454868/href</a></iframe><p>It actually very neatly reuses all the classes from the original implementation by just loading them. So the original part of the sample application is the “glue” code that connects the host Java part to the Java on Truffle part of the app.</p><p>The sample can be compiled as a native executable, resulting in a nice binary that starts faster than the usual JShell because of the native executable performance characteristics and still can execute the Java code we throw at it.</p><p>Here’s a screenshot of the Tetris game loaded and started from the JShell implemented with Java on Truffle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*0qSoXht-jALa_dykf0h75Q.png" /></figure><p>Mixing AOT and JIT is a fascinating option for applications that cannot leverage the native image performance improvements because their functionality depends on dynamic code which does not work easily with Native Image.</p><h3>Advanced class redefinition</h3><p>Another really cool feature where Java on Truffle is more powerful than HotSpot is the enhanced Hot Swap ability — changing classes at runtime during a debugging session.</p><p>As of GraalVM 21.0 the following changes are supported:</p><ol><li>Add and remove methods</li><li>Add and remove constructors</li><li>Add and remove methods from interfaces</li><li>Change access modifiers of methods</li><li>Change access modifiers of constructors</li><li>Changes to Lambdas</li><li>Add new anonymous inner classes</li><li>Remove anonymous inner classes</li></ol><p>What will make hot swap even more powerful is the ability to make changes to class fields. It’s in the works and will be added in a future release.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2DjRblMOeQ1l4Jgn-_J-A.png" /><figcaption>Reload changed classes action in the IntelliJ IDEA debugger.</figcaption></figure><p>The setup is the same as with HotSpot: you start the debugger, change the code, recompile the class, hit “Reload the classes” in your IDE debugger and resume the program with the new code running next time the changed class is used.</p><p>Follow this demo to see the enhanced HotSwap feature in action:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgfuvvV6mplo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgfuvvV6mplo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgfuvvV6mplo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3129cd40ae1e46a4a80ebe18a02751e/href">https://medium.com/media/b3129cd40ae1e46a4a80ebe18a02751e/href</a></iframe><h3>GraalVM ecosystem support</h3><p>Java on Truffle benefits out of the box from the developer tooling support that GraalVM languages get from the Truffle framework.</p><p>For example, you can run your application with some java -truffle --cpusampler and have the sampling profiler run on your code. You can enable the tracing profiler or memory tracer to tell you which parts of the code generate more memory pressure than others.</p><p>Another facet of the ecosystem is the supported languages. Java on Truffle allows you to create polyglot programs where different components are written in different languages. The details about how to load code written in other languages, export and import objects between languages, and so on are a little bit more involved than the scope of the current article, but details can be found <a href="https://www.graalvm.org/reference-manual/java-on-truffle/interoperability">from the docs</a>.</p><h3>Next steps</h3><p>GraalVM 21.0 is the initial release of Java on Truffle. It’s an experimental component right now and there are major improvements planned for it in upcoming releases.</p><p>There are many things to improve, from supporting javaagents, to having a better implementation of the interop protocol with other languages, major performance improvements, and so on.</p><p>We’ll be working on these and other improvement, and would be absolutely thrilled to hear any and all feedback, feature requests, potential use cases, discovered issues, and shortcomings of the current version. You can share your feedback via <a href="https://www.graalvm.org/slack-invitation">Slack</a>, <a href="https://github.com/oracle/graal">GitHub</a>, or <a href="https://twitter.com/graalvm">Twitter</a>. To get started, head to <a href="https://www.graalvm.org/java-on-truffle">graalvm.org/java-on-truffle</a>.</p><p>Java on Truffle is a new and very exciting way to run your Java code. Take a look and consider the possibilities!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=215531e3f840" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/java-on-truffle-going-fully-metacircular-215531e3f840">Java on Truffle — Going Fully Metacircular</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraalVM quick reference]]></title>
            <link>https://medium.com/graalvm/graalvm-quick-reference-b8d1dfe24241?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8d1dfe24241</guid>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 15:15:14 GMT</pubDate>
            <atom:updated>2022-10-27T17:33:14.401Z</atom:updated>
            <content:encoded><![CDATA[<h3>GraalVM Quick Reference</h3><p><em>Find more recent quick reference</em>s<em> </em><a href="https://www.graalvm.org/docs/quick-references/"><em>here</em></a><em>.</em></p><p>There are three main ways how GraalVM can help with Java applications: making them faster by using the state-of-the-art JIT compiler, compiling them into standalone native executables with instant startup and low memory consumption, and enhancing them with libraries or code in other supported languages.</p><p>This quick reference is a <a href="https://www.graalvm.org/uploads/quick-references/GraalVM/CheatSheet_(EU_A4).pdf">one-page short summary of what GraalVM can do</a> and the key options and commands to illustrate its capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOuDl1ETPNi7xOFsBfXRtw.png" /></figure><p>You can download and print it. It fits neatly on an A4 paper, so you can hang it in the office and use it as a reminder of what GraalVM can do and which options turn it on. Be sure to grab the <a href="https://www.graalvm.org/uploads/quick-references/GraalVM/CheatSheet_(EU_A4).pdf">pdf version</a> for printing so it looks neat and sharp. <em>Note that if your printer is more comfortable with the US letter paper formats please make sure to get </em><a href="https://www.graalvm.org/uploads/quick-references/GraalVM/CheatSheet_(US_Letter).pdf"><em>this version</em></a><em>, it’ll look better.</em></p><p>In this post, we’ll go over the information in the quick reference and describe it in more detail.</p><p>The first part is focused on running Java applications. Foremost, it’s good to remember that the GraalVM distributions contain a JDK with all the usual JDK tools, meaning you can use GraalVM as your JDK. For example, compiling the Java source code with the javac utility:</p><p>javac MyApp.java</p><p>Naturally, you can also use GraalVM to run your Java applications or any other JVM languages. In addition to being able to run Java, GraalVM benefits from its powerful just-in-time (JIT) compiler and achieves state-of-the-art peak performance to often run them faster than other JDKs.</p><p>java -jar MyApp.jar</p><p>When running Java applications just-in-time with GraalVM, the underlying JVM is the usual Java Hotspot (tm) VM, which means that most of the configuration options are equivalent, for example, specifying the classpath for your application works like this:</p><p>java -cp target/myapp.jar com.example.Main</p><p>The GraalVM compiler is normally run in<a href="https://www.graalvm.org/reference-manual/compiler/#compiler-operating-modes"> the precompiled to a native shared library mode</a>. But its code is written in Java and it can be used as a JAR file, which results in a slightly different performance profile: using heap memory for the compilation at the expense of the longer warmup (for example, Java code of the compiler needs to compile). The following option configures which mode you want to run in (enabled + by default):</p><p>-XX:+-UseJVMCINativeLibrary</p><p>In addition to running the compiler as a JAR or a native library, you can <a href="https://www.graalvm.org/reference-manual/jvm/Options/">specify the configuration for the optimizations</a> by picking the economy for faster warmup, and enterprise for the best peak performance (requires GraalVM Enterprise of course).</p><p>-Dgraal.CompilerConfiguration=enterprise|community|economy</p><p>The JIT compiler impact can be dramatic speeding up the applications quite a lot, but sometimes it’s unclear whether the compiler is working, whether the code actually reaches the top tier, and which methods get to the compiler.</p><p>-Dgraal.PrintCompilation=true</p><p>In addition to looking at the logs you can enable more debug output, for example, to print the compiler graphs to analyze them for finding additional optimization opportunities:</p><p>-Dgraal.Dump=:2</p><p>And of course, other features of the JVM work with GraalVM too. For example, you can attach a Java agent that will instrument the code, generate classes at runtime, and other Java “agenty” things. Both the Java-based agents and the native agents work. One notable example would be the assisted configuration agent for simplifying native image builds.</p><p>-javaagent:path/to/jar.jar</p><p>-agentlib:path/to/native/agent</p><p>The second major advantage of using GraalVM is its <a href="https://www.graalvm.org/reference-manual/native-image/">Native Image</a> capabilities: compiling your application ahead-of-time into a native binary.</p><p><em>Update: We’ve published a separate quick reference for the </em><em>native-image, please check it out: </em><a href="https://medium.com/graalvm/graalvm-native-image-quick-reference-4ceb84560fd8"><em>Native Image quick reference</em></a><em>.</em></p><p>In order to use that you need to install the native-image component. One way to do this is to download the component’s JAR file for your GraalVM distribution and run the following:</p><p>gu install -L native-image.jar</p><p>Then you can use the installed native-image utility to prepare the native binary of your application:</p><p>native-image [options] MyClass</p><p>Alternatively, you can use the JAR file syntax similar to the java command.</p><p>native-image -jar MyApp.jar</p><p>Run the resulting binary like any executable file:</p><p>./myApp</p><p>If instead of the executable you would like to <a href="https://www.graalvm.org/reference-manual/native-image/ImplementingNativeMethodsInJavaWithSVM/#create-a-shared-library">build a shared library</a>, you can do that by passing the --shared option. You need to mark the methods to be exposed with the @CEntryPoint annotation, but a more detailed exploration of this topic is beyond the scope of this article.</p><p>--shared</p><p>Another very useful possibility is to <a href="https://www.graalvm.org/reference-manual/native-image/StaticImages/">build statically linked binaries</a> where the OS libraries like libc are linked into the executable. It’s even possible to pick which libc implementation to use. glibc is used by default, muslc is an option, for which you need to prepare the build environment a bit.</p><p>--static --libc=muslc</p><p>It is possible to include the infrastructure for running Truffle-based languages: JavaScript, Ruby, Python, R, and so on. This will include the interpreter for the language, the <a href="https://www.graalvm.org/graalvm-as-a-platform/language-implementation-framework/">Truffle framework</a>, and the JIT compiler, so the code can be compiled at runtime for faster execution.</p><p>For example, each of these will include the support for the corresponding language:</p><pre>--language:js<br>--language:python<br>--language:llvm<br>--language:ruby</pre><p>--language:js</p><p>Another fascinating capability is the <a href="https://www.graalvm.org/reference-manual/native-image/PGO/">profile-guided optimizations</a> for the native image executables. You can generate an instrumented binary, apply relevant workloads to it, record the profile of the code executed similar to what JIT does, and use those profiles to build the production binary.</p><pre>native-image — pgo-instrument MyApp<br>./myApp<br>native-image — pgo profile.iprof MyApp</pre><p>And, if you’d like to have more visibility into what happens during the native image build process, for example, trying to understand the class chain through which a class got initialized, you can use a selection of the helpful options.</p><p>Tracing the initialization path to a certain class is enabled by the following one:</p><p>-H:+TraceClassInitialization=package.class.Name</p><p>The native image build is a Java process so you can put a breakpoint into code and attach a debugger to it to have full visibility into what’s happening.</p><p>--debug-attach=[port]</p><p>In addition to these, there are a ton of other useful options to configure the native image build and the runtime behavior, which we’ll explore in the future, but you can get a gist of what’s available using the expert help option:</p><p>--expert-options-all</p><p>The third major advantage GraalVM gives you is a <a href="https://www.graalvm.org/reference-manual/polyglot-programming/">polyglot runtime</a>, capable of running several languages, and it includes the Node.js platform powered by GraalVM’s engine for JavaScript. So, if you have a node application, you can run it by calling the node command.</p><p>node myApp.js</p><p>On top of that there are a number of language launchers that you can use for running programs in the supported languages:</p><pre>js myApp.js<br>graalpython myApp.py<br>ruby myApp.rb<br>R myApp.r<br>lli myApp</pre><p>The launchers, including node, are by default run in the native mode, where the interpreter is compiled as a native image binary. So, to enable interoperability with the JVM to use Java classes, use the --jvm option and for other languages --polyglot:</p><p>--polyglot --jvm</p><p>The language engines come with a number of features to <a href="https://docs.oracle.com/en/graalvm/enterprise/20/docs/reference-manual/embed-languages/sandbox/">limit the number of resources</a>, like, for example, the amount of time in milliseconds the language context can run:</p><p>--sandbox.MaxCPUTime=Nms</p><p>And last but not least, the GraalVM languages have support for <a href="https://www.graalvm.org/docs/tools/">common developer tooling</a> out-of-the-box. This is one of the most exciting parts of the whole GraalVM ecosystem — implement a language interpreter fixing the semantics of the language and get a powerful virtual machine, a selection of GC algorithms, a debugger, a profiler, a memory analyzer, and other tools for free.</p><p>Specify the following options to enable, respectively, the debugger based on the Chrome DevTools debugger, the sampling profiler, the tracing profiler, and the memory analyzer:</p><pre>--inspect<br>--cpusampler<br>--cputracer<br>--memsampler</pre><h4>Conclusion</h4><p>GraalVM is a versatile project offering many interesting capabilities which you can use for your applications, be they in Java, JVM languages, JavaScript, Ruby, Python, R, and others.</p><p>From using a better just-in-time compiler to building native executables of your applications to running components in different languages — you can use GraalVM today.</p><p>In this quick reference, we tried to outline the most frequently used options that describe the different capabilities of GraalVM.</p><p><a href="https://www.graalvm.org/uploads/quick-references/GraalVM/CheatSheet_(EU_A4).pdf">Download it</a>, print it out, and pin it on the wall. Hopefully, it’ll keep reminding you about how interesting the GraalVM project is even if you currently only using a fraction of what it can offer.</p><p>And while you’re at it, <a href="https://www.graalvm.org/downloads/">get the GraalVM distribution</a> and try a few things from the quick reference like running your Java apps faster, making microservices more cloud friendly with native images, or enhancing your apps with libraries in other languages!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8d1dfe24241" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/graalvm-quick-reference-b8d1dfe24241">GraalVM quick reference</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GraalVM 20.3 is available]]></title>
            <link>https://medium.com/graalvm/graalvm-20-3-is-available-d2a7f7a2bbcd?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2a7f7a2bbcd</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[graalvm]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Tue, 17 Nov 2020 18:07:25 GMT</pubDate>
            <atom:updated>2020-11-20T12:03:52.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>Announcing GraalVM 20.3</h3><p>Today we’re happy to announce the GraalVM 20.3.0 release. This is the final feature release of 2020 and if you’re running GraalVM 20.x we recommend taking a look and updating to 20.3. It is also the first long-term support (LTS) release for GraalVM Enterprise. If you’re running one of the 19.x releases or earlier 20.x releases please consider upgrading to 20.3.0 in the near future.</p><p>As with every release, we’re greatly thankful to the wonderful GraalVM community for all the feedback, for the collaboration and the discussions of the issues, for sending pull requests and updates to the docs, and last but not least, for spreading the word about the GraalVM project and how it helps your project. Together we make the GraalVM ecosystem extraordinary!</p><p>You can download GraalVM 20.3.0 right now:</p><ul><li><a href="https://www.graalvm.org/downloads">GraalVM Community Edition</a></li><li><a href="https://www.oracle.com/downloads/graalvm-downloads.html">GraalVM Enterprise Edition</a></li></ul><p>In this article we want to highlight some of the most notable changes in GraalVM 20.3.0. There are many components in GraalVM and every release brings improvements and fixes to all of them. So for a more detailed list of changes please refer to the <a href="https://www.graalvm.org/docs/release-notes/">release notes</a>.</p><h3>Platform updates</h3><p>The GraalVM compiler is at the heart of the GraalVM project: it allows GraalVM to show the best results for Java benchmarks; it’s used for the ahead-of-time compilation when building native images; it’s used to optimize the performance of languages running on the Truffle language implementation framework. So all updates to the compiler are extremely important and impact almost all projects in the GraalVM ecosystem.</p><p>GraalVM 20.3 brought a number of noteworthy improvements to the compiler. 20.3.0 enhanced the heuristics that help simulation-based loop peeling in GraalVM Enterprise specifically for the cases where objects in the array are lazily initialized in the first iteration of the loop and used later. Because of this, some Python microbenchmarks saw performance improvement up to 40%. Speaking of arrays, the code generation for initializing newly allocated arrays improved and we corrected the corner cases where certain large array allocations (8–128MB large) were being initialized twice. Another particularly interesting change is in the area of the advanced code duplication optimization in GraalVM Enterprise 20.3.0. This release addresses several misclassifications in the heuristic for duplication. The result is a peak performance improvement of up to 17% on some LLVM bitcode workloads and a 5% increase on relevant Java workloads.</p><p>Introduced in a previous release,libgraal dramatically improved the compilation speed of the GraalVM compiler. However, a small amount of class loading was still performed during its initialization. This was visible in the warmup curves of micro benchmarks that had very short iterations. For example, on the <a href="https://github.com/smarr/are-we-fast-yet/blob/master/benchmarks/Java/src/NBody.java">NBody</a> benchmark from the <a href="https://github.com/smarr/are-we-fast-yet">&quot;Are We Fast Yet?&quot; benchmark suite</a>, the first 2 benchmark iterations took ~110 milliseconds on libgraal compared to 45 milliseconds on C2. This class loading has now been eliminated from libgraal or delayed until a point after libgraal initialization. A secondary benefit of eliminating this class loading is that it fixed problems related to VM assumptions about the JIT compiler not loading classes.</p><p>Individual optimizations and better heuristics don’t always improve all workloads, often they are only marginally better for some. But the continuous addition of small incremental changes does pay off in the long run. Here’s a graph illustrating the progress of 20.3.0 over last year’s 19.3.0 release:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*i1JGLOM0Xv233qwBV49VYg.png" /></figure><p>Note that last year’s performance was the state-of-the-art for these workloads showing world-class results. The fact that 20.3 improves on these result is what makes the performance even more impressive.</p><h3>Native Image</h3><p>GraalVM Native Image is a very versatile technology supporting cloud deployments, CLI tools, and deployments on embedded and mobile devices.</p><p>In 20.3.0 Native Image improved its container awareness: on Linux, resource limits like the processor count and available memory size are read from cgroup V1and V2 configurations. The processor count can also be overridden on the command line using the option -XX:ActiveProcessorCount=.</p><p>The G1 garbage collector available in GraalVM Enterprise with the Java HotSpot VM is now also supported in native executables generated by Native Image. G1 now also supports performance counters when the image is built with -H:+AllowVMInspection. It can be enabled at build time using the new simplified and more descriptive option --gc=G1</p><p>Isolated compilation is now available in the Community Edition and separates Truffle applications and the runtime compiler from each other, which improves performance by reducing interference between them such as with garbage collection.</p><p>The options to enable and disable assertions now support the full syntax to specify package and class names. Assertions need to be configured at image build time, using the options -ea / -da / -esa / -dsa. The definition of &quot;system assertions&quot; is expanded to not only include assertions in the JDK, but also in the Substrate VM runtime system, for example the garbage collector.</p><p>This release also brings many small performance and memory footprint optimizations. In particular, a new implementation of type checks improves the performance of Class.isInstance and Class.isAssignableFrom with less type data in the image heap.</p><p>Thanks to a collaborative community effort, basic debug info generation is now also available on Windows.</p><p>As in every release, we fixed a lot of issues <a href="https://github.com/oracle/graal/issues?q=is%3Aissue+is%3Aclosed+label%3Anative-image+">reported on GitHub</a>. One notable example, is the issue where some native image executables were <a href="https://github.com/oracle/graal/issues/2830">not compressing correctly</a> with the UPX utility. The ratio of compression varies based on the particular project, but it often leads to 60–70% smaller executables for microservice application examples.</p><h3>Language Implementation Framework (Truffle)</h3><p>The Truffle Language Implementation Framework underpins all the non-JVM native languages running on GraalVM. In 20.3.0 one of the major themes for Truffle was a focus on improving warmup: how quickly programs become fast. There were three most significant changes that address the warmup. 20.3.0 enabled by default the elastic allocation of Truffle compiler threads depending on the number of available processors. The previous behavior of using 1 or 2 compiler threads, can be explicitly enabled with --engine.CompilerThreads=0.</p><p>If you’re using one of the languages GraalVM supports: JavaScript, Ruby, Python, R, or running LLVM bitcode — please try the new release, it can significantly improve the warmup.</p><p>If you are embedding these languages, for example in a Java application, there are important improvements in 20.3.0. For example, we added the Context.interrupt(Duration) API to interrupt a polyglot Context execution. The interrupt is non-destructive meaning that the polyglot Context can still be used for further execution.</p><p>And GraalVM Enterprise introduced experimental sandbox resource limits. Using the options like:</p><ul><li>sandbox.MaxStatements=&lt;long&gt; to limit the maximum number of statements.</li><li>sandbox.MaxCPUTime=1000ms to limit the total maximum CPU time that is spent running the application.</li><li>sandbox.MaxThreads=&lt;int&gt; - to limit the number of threads that can be concurrently used by a context.</li></ul><p>We’ll explore the sandboxing limits in more detail in an upcoming article specifically about it.</p><h3>JavaScript</h3><p>The supported Node.js version in GraalVM 20.3.0 was updated to 12.18.4.</p><p>JavaScript also saw a number of improvements to Nashorn compatibility mode, including:</p><ul><li>enabling low precedence lossy number, string-to-boolean, and number-to-boolean conversions.</li><li>fixing the field, getter, and setter access order to mimic Nashorn.</li><li>fixing Java.extend to respect HostAccess.Builder.allowImplementation limits.</li></ul><p>The ability to set JavaScript prototypes for foreign objects mimicking JavaScript types became supported in 20.3.0, so the option to enable that got renamed to js.foreign-object-prototype.</p><h3>Ruby</h3><p>In every release, TruffleRuby comes with a ton of compatibility fixes and performance improvements.</p><p>On top of the changes focusing on warmup improvements that Truffle brings to all languages, Ruby in 20.3.0 includes various warmup improvements, notably much less splitting and more operations are being done inline, without a call. This should result in reaching peak performance faster.</p><h3>Python</h3><p>The compatibility of GraalVM’s Python implementation continues to improve. The 20.3.0 release contains many fixes to pass the unit tests of standard library types and modules: complex, bytes, bytearray, subclassing of special descriptors, type layouts, float, generators, modules, argument passing corner cases, string literals and encodings, import and importlib, decimal, glob, the builtin module, json, math, operator, numeric tower, sys, warnings, random, f-strings, struct, itertools, super.</p><p>On top of that, the Python version was updated to 3.8.5. As it is becoming more well known in the community, the standalone version of graalpython can now be installed through pyenv.</p><h3>LLVM bitcode runtime</h3><p>Besides performance improvements and bug fixes, GraalVM 20.3.0 now supports code sharing in the GraalVM LLVM runtime. This allows the AST and compiled code of common bitcode libraries to be shared between multiple contexts within a single engine.</p><p>The LLVM toolchain was also updated to version 10.0.0.</p><h3>Tools</h3><p>A major improvement in tooling for GraalVM in 20.3.0 is the new VSCode GraalVM extension for Java. It includes a lot of functionality that simplifies working with Java projects. For example:</p><ul><li>Java syntax highlighting</li><li>Java code completion</li><li>Integrated Java debugger</li><li>Integrated Polyglot debugger for GraalVM languages</li></ul><p>There’s also a new VS Code Micronaut extension which leverages the features of the GraalVM extension for Java but also simplifies working with Micronaut apps, specifically helping to create new Micronaut projects and building native images of the Micronaut applications.</p><h3>What do you want to see in GraalVM?</h3><p>With every release we introduce new features that can make your applications run faster, open new opportunities and make the development process more efficient and fun. There are many things on our project roadmap, and we would love to hear from you which would be the most useful, and what is still missing. Respond to <a href="https://ora-gcp1.custhelp.com/ci/documents/detail/5/2913/12/57581a41ab42a5ec14bbc1c2a4fdf93e6ccc47f1">this survey</a> to let us know how we should improve and extend GraalVM. Feel free to also share it with your team or community — having more opinions will help us to make GraalVM better for everyone.</p><p>Note that these are only some of the most notable improvements in the GraalVM 20.3.0! Please read a more detailed outline of the new and noteworthy features in the release notes. For the components you’re most interested in the changelogs are an invaluable source of information!</p><p>The downloads are available as always for <a href="https://www.graalvm.org/downloads">GraalVM Community Edition 20.3.0</a> and <a href="https://www.oracle.com/downloads/graalvm-downloads.html">GraalVM Enterprise Edition 20.3.0</a>.</p><p>With all and any feedback please don’t hesitate to let us know on any of the channels: <a href="https://www.graalvm.org/slack-invitation">Slack</a>, <a href="https://github.com/oracle/graal">GitHub</a>, or <a href="https://twitter.com/graalvm">Twitter</a>!</p><p>— GraalVM Team</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2a7f7a2bbcd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/graalvm-20-3-is-available-d2a7f7a2bbcd">GraalVM 20.3 is available</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CLI applications with GraalVM Native Image]]></title>
            <link>https://medium.com/graalvm/cli-applications-with-graalvm-native-image-d629a40aa0be?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/d629a40aa0be</guid>
            <category><![CDATA[native-image]]></category>
            <category><![CDATA[micronaut]]></category>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jvm]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Fri, 13 Nov 2020 10:08:45 GMT</pubDate>
            <atom:updated>2020-11-13T11:10:56.177Z</atom:updated>
            <content:encoded><![CDATA[<p>GraalVM Native Image technology allows you to compile your applications into native executables. Some of the great benefits you get from it are:</p><ul><li>small standalone distribution not requiring a JDK</li><li>instant startup</li><li>lower memory footprint</li></ul><p>Native image is a very exciting way to deploy apps to cloud environments where these benefits determine the actual cost of running your applications.</p><p>However there is another class of applications that benefits from the above characteristics — command line apps!</p><p>Indeed, a good command line app is truly standalone, not like a docker run some-image standalone which involves downloading the infrastructure and the dependencies of the app just conveniently packaged. That was possible for ages: slap some @Grab annotations on the Groovy code, provide a wrapper to download the JDK, and call it a day. Native image gives you a binary that once you wget it is functional on its own.</p><p>A good CLI app starts fast! And if it doesn’t have a lot to do it dies fast too!</p><p>GraalVM Native Image precompiles your Java applications into native binaries, which don’t need to perform lots of boot-time initialization, like loading and verifying class files, and have startup times similar to apps written in other native compiled languages: Go, C/C++, etc.</p><p>Native executables also don’t need to initialize and allocate memory for the JIT compiler because there is no JIT compiler! Everything is compiled at build time. No JIT compiler means no code caches and no profile data caches which results in lower memory requirements than the same application running on the JVM. Your app will still consume memory for its own data of course, so if there’s a lot of data to process memory usage will grow as necessary but is still configurable with the normal -Xmx and friends command line options.</p><p>All in all, it checks a lot of the boxes for how a good CLI app should be. But in this article I want to explore one more cool feature of GraalVM native image — specifying the default memory requirements at the image build time.</p><p>Normally, for a Java application running on the JVM, you need to specify how much memory it can use at runtime. You run it with a command line like java -Xmx4G -jar myApp.jar and know that this application has its heap size limit at 4G. Without the -Xmx option the heap size will be determined by a heuristic, typically based on the total amount of memory available.</p><p>When you use GraalVM Native Image to compile your app, you can pre-set the heap size at build time. Let’s look at an example.</p><p>Let’s create a sample CLI application using <a href="http://micronaut.io/">Micronaut</a> and <a href="https://picocli.info/">Picocli</a> and see how you can configure native executable memory.</p><p>You can go to <a href="https://micronaut.io/launch">launch.micronaut.io</a> and create an app by specifying necessary components or use the command line utility mn. What’s interesting about mn is that it is itself a Micronaut command line app generated by GraalVM Native Image — a perfect example of a Java CLI application!</p><p>I’m using Micronaut 2.1.2:</p><p>mn create-cli-app primes; cd primes</p><p>We have the app ready, it’s a template for a CLI app that can respond to basic commands like --help. Let&#39;s create the business logic of a very important task of calculating prime numbers. CreatePrimesComputer.java in theprimes package using your favourite IDE:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fde74a8a8e5ec48c06d87d44ea58c01/href">https://medium.com/media/2fde74a8a8e5ec48c06d87d44ea58c01/href</a></iframe><p>It’s a very simple component, which can pick 2 random numbers up to the upperbound and return the list of prime numbers between them.</p><p>The calculation of the prime numbers is done using the Streams API, which is sort of inefficient but also not relevant for this exercise. This is actually remarkably convenient for the sample app since every calculation will generate a bit of data that is not used afterwards — i.e., garbage.</p><p>Let’s put it to use in the main PrimesCommand.java file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8884219a97c102600c1e3b06a48b342f/href">https://medium.com/media/8884219a97c102600c1e3b06a48b342f/href</a></iframe><p>It declares two integer options that our CLI utility will accept — how many iterations of the calculation to run and what’s the upper limit for the numbers to consider.</p><p>You can now try the app and see it work. For convenience — delete the test class left from the template (we could of course edit it to match our functionality, but removing is simpler):</p><p>rm src/test/java/primes/PrimesCommandTest.java.</p><p>Build the project now and run the resulting jar file:</p><pre>./gradlew build <br>...<br>java -jar build/libs/primes-0.1-all.jar<br>00:51:30.519 [main] INFO  i.m.context.env.DefaultEnvironment - Established active environments: [oraclecloud, cloud, cli]</pre><p>You can see how quickly a Micronaut application starts! In less than a second!</p><p>We can also run it with some values for the arguments, so we see some output:</p><pre>java -jar build/libs/primes-0.1-all.jar -n 1 -l 100 <br>[53, 59, 61, 67, 71, 73]</pre><p>Remember, in the beginning of the article we said a CLI tool should start fast and use reasonably small amounts of memory. Let’s test the Java version just to have a baseline for those metrics:</p><pre>/usr/bin/time -v java -jar build/libs/primes-0.1-all.jar -n 1 -l 100<br>16:34:02.776 [main] INFO  i.m.context.env.DefaultEnvironment - Established active environments: [oraclecloud, cloud, cli]<br>[53, 59, 61, 67, 71, 73]<br>    Command being timed: &quot;java -jar build/libs/primes-0.1-all.jar -n 1 -l 100&quot;<br>    User time (seconds): 2.73<br>    System time (seconds): 0.43<br>    Percent of CPU this job got: 309%<br>    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.02<br>    Average shared text size (kbytes): 0<br>    Average unshared data size (kbytes): 0<br>    Average stack size (kbytes): 0<br>    Average total size (kbytes): 0<br>    Maximum resident set size (kbytes): 354996<br>    Average resident set size (kbytes): 0<br>    Major (requiring I/O) page faults: 0<br>    Minor (reclaiming a frame) page faults: 54451<br>    Voluntary context switches: 9774<br>    Involuntary context switches: 53<br>    Swaps: 0<br>    File system inputs: 0<br>    File system outputs: 64<br>    Socket messages sent: 0<br>    Socket messages received: 0<br>    Signals delivered: 0<br>    Page size (bytes): 4096<br>    Exit status: 0</pre><p>I’m using the Linux time utility (or gtime on macOS) and in the verbose mode it shows a few interesting metrics:</p><ul><li>Max memory used by the app (max RSS): 355m</li><li>Total wall clock time: 1.02s</li><li>CPU usage: 309%</li></ul><p>Note that the machine I’m testing this on is a decent cloud VM, with a few CPU and some RAM, which I often use as my remote developer machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZNDKCsIURGTW_9U0IIUWg.png" /></figure><p>This machine has quite a bit of memory available, which is perfect for development, but a bit detrimental to the heuristic based limit configuration: a good heuristic will see it has access to a ton of resources and decide to consume as much as convenient. That’s why we should not decide whether 350M consumed by a simple invocation of out utility is too much or not.</p><p>Remember these heuristics make a lot of sense for the server environment where your application is a sole consumer of the resources, even it it also makes CLI apps look more memory hungry than necessary. I’ll leave 300% of CPU and 1s to compute 5 prime numbers without a comment, it’s as good of a baseline as any.</p><p>Now a much better way to run this application is as a native executable generated by GraalVM Native Image. Fortunately, building a native executable of the Micronaut application is very straightforward as there’s a Gradle plugin that helps with the configuration and execution of the native-image utility.</p><p>Run ./gradlew nativeImage and after compiling and building the executable you&#39;ll have a standalone binary file ready for deployment.</p><p>The executable is available in the build/native-image/ folder, which we for convenience will move to the current dir: mv build/native-image/application ./primes-defaults</p><p>We can run it now and see that it works the same way as the Java version: ./primes-defaults -n 1 -l 100</p><p>And the same time command to check if the behaviour of the native image is a bit more appropriate for the CLI app:</p><pre>/usr/bin/time -v ./primes-defaults -n 1 -l 100<br>23:57:47.286 [main] INFO  i.m.context.env.DefaultEnvironment - Established active environments: [oraclecloud, cloud, cli]<br>[53, 59, 61, 67, 71, 73]<br> Command being timed: &quot;./primes-defaults -n 1 -l 100&quot;<br> User time (seconds): 0.01<br> System time (seconds): 0.01<br> Percent of CPU this job got: 113%<br> Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.02<br> Average shared text size (kbytes): 0<br> Average unshared data size (kbytes): 0<br> Average stack size (kbytes): 0<br> Average total size (kbytes): 0<br> Maximum resident set size (kbytes): 49980<br> Average resident set size (kbytes): 0<br> Major (requiring I/O) page faults: 0<br> Minor (reclaiming a frame) page faults: 1226<br> Voluntary context switches: 232<br> Involuntary context switches: 2<br> Swaps: 0<br> File system inputs: 0<br> File system outputs: 0<br> Socket messages sent: 0<br> Socket messages received: 0<br> Signals delivered: 0<br> Page size (bytes): 4096<br> Exit status: 0</pre><p>Here are the highlights:</p><ul><li>50M rss</li><li>20 ms total time</li><li>113% CPU</li></ul><p>This is much-much better of course, but since we’re not configuring the memory limits, it’ll still use the heuristics and grow memory much more aggressively than you might expect if we increase the workload.</p><p>Luckily, we have the number of iterations to run in the parameters, so we can experiment very easily. Here’s an output of running 100K iterations of the same task:</p><pre>Command being timed: &quot;./primes-defaults -n 100000 -l 100&quot;<br>    User time (seconds): 0.88<br>    System time (seconds): 0.63<br>    Percent of CPU this job got: 72%<br>    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.07<br>    Average shared text size (kbytes): 0<br>    Average unshared data size (kbytes): 0<br>    Average stack size (kbytes): 0<br>    Average total size (kbytes): 0<br>    Maximum resident set size (kbytes): 309956<br>    Average resident set size (kbytes): 0<br>    Major (requiring I/O) page faults: 0<br>    Minor (reclaiming a frame) page faults: 65110<br>    Voluntary context switches: 199<br>    Involuntary context switches: 5<br>    Swaps: 0<br>    File system inputs: 0<br>    File system outputs: 0<br>    Socket messages sent: 0<br>    Socket messages received: 0<br>    Signals delivered: 0<br>    Page size (bytes): 4096<br>    Exit status: 0</pre><ul><li>309M RSS</li><li>2s</li><li>72% CPU</li></ul><p>(Just for completeness the Java JVM version shows me these results):</p><ul><li>517M RSS</li><li>3.3s</li><li>171% CPU</li></ul><p>Now if you still think 300M is more RAM than a good behaving CLI utility should take, you can control that with the -Xmx and -Xmn options at runtime, like this:</p><pre>./primes-defaults -Xmx64m -Xmn16m -n 100000 -l 100</pre><p>Or you can pre-build the default config values into the native image.</p><p>Add the following snippet to the build.gradle file:</p><pre>nativeImage {   <br>  args(&quot;-R:MaxHeapSize=64m&quot;)   <br>  args(&quot;-R:MaxNewSize=16m&quot;) <br>}</pre><p>Here we specify the maximum heap size of 64m and the new generation size of 16m for the native image that will be built. These options will become the defaults for the native image executable. Build the native image again with ./gradlew nativeImage, to test it.</p><p>Move the binary too, so it won’t be overwritten by the future builds: mv build/native-image/application ./primes-limits</p><p>It still works the same:</p><pre>./primes-limits -n 1 -l 100 <br>00:08:08.228 [main] INFO  i.m.context.env.DefaultEnvironment - Established active environments: [oraclecloud, cloud, cli] <br>[53, 59, 61, 67, 71, 73]</pre><p>But when we apply the load (the 100K iterations test), we can see the heap configuration in action the RSS doesn’t grow uncontrollably.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*ObyMVGSqyyynscxV2U_BMQ.png" /><figcaption>Timing native executable with heap size preconfigured during the native image build</figcaption></figure><p>On my test machine I get:</p><ul><li>60M RSS</li><li>2.02 total time</li><li>77% CPU</li></ul><p>Also the native executable built this way will still respect the -Xmx, -Xmn config at runtime, so there&#39;s no downside like that for using the pre-baked limits you can increase them if needed.</p><h3>Conclusion</h3><p>GraalVM native image technology is great for command line applications. It produces a standalone binary that doesn’t depend on the JVM, starts instantly, doesn’t use a lot of memory, and lets you preconfigure reasonable heap configuration values for the workloads you expect by default. In this article we showed a sample command line application built with Micronaut and PicoCLI which is a terrific combination that works really well and is a good fit for native images.</p><p>There are a number of project that use GraalVM native image for the CLI apps:</p><ul><li><a href="https://www.scala-sbt.org/1.x/docs/sbt-1.4-Release-Notes.html#Native+thin+client">Native thin client for sbt</a></li><li><a href="https://github.com/micronaut-projects/micronaut-starter">Micronaut’s </a><a href="https://github.com/micronaut-projects/micronaut-starter">mn utility</a></li><li><a href="https://www.npmjs.com/package/google-closure-compiler">Google Closure compiler for JavaScript</a></li><li>the <a href="https://github.com/mvndaemon/mvnd">Maven Daemon</a> project</li></ul><p>There are many many others. It’s probably a good fit for creating Kubernetes operators too, they are rather similar to the CLI apps, but perhaps that’s a topic for a followup article.</p><p>If you’re using GraalVM Native Image for command line applications, please tell us about it and how it works for you in the comments, or on <a href="http://twitter.com/graalvm">Twitter</a>, or <a href="https://www.graalvm.org/slack-invitation">Slack</a>. We’re always looking to improve GraalVM further!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d629a40aa0be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/cli-applications-with-graalvm-native-image-d629a40aa0be">CLI applications with GraalVM Native Image</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Announcing GraalVM 20.2.0]]></title>
            <link>https://medium.com/graalvm/announcing-graalvm-20-2-0-674e7f6dae27?source=rss-35826df4e731------2</link>
            <guid isPermaLink="false">https://medium.com/p/674e7f6dae27</guid>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[graalvm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Oleg Šelajev]]></dc:creator>
            <pubDate>Tue, 18 Aug 2020 20:31:21 GMT</pubDate>
            <atom:updated>2020-09-04T14:34:21.535Z</atom:updated>
            <content:encoded><![CDATA[<p>The most advanced and fastest polyglot runtime that shows absolutely superb results on Java and other JVM languages — and can run programs written in popular languages like JavaScript, Ruby, R, and Python — just got even better.</p><p>Today marks the release of GraalVM 20.2.0. This is a feature release and it packs a lot of improvements to performance, native image technology, and compatibility with the supported languages.</p><p>As always, we’re truly thankful to the amazing GraalVM community for collaboration, for providing feedback and raising issues, and for sending pull requests and talking about how you use GraalVM in your projects.</p><p>In this post we want to highlight some of the most notable changes in GraalVM 20.2.0. For a more detailed list please consider the release notes on <a href="https://www.graalvm.org/release-notes/20_2/#2020">the website</a>.</p><h3>Platform updates</h3><p>In every release there are a number of fixes and improvements to every GraalVM component. The compiler is no exception. Let’s take a look at two new features you can try out in GraalVM 20.2.0:</p><p>In GraalVM Enterprise, the memory used by <a href="https://medium.com/graalvm/libgraal-graalvm-compiler-as-a-precompiled-graalvm-native-image-26e354bee5c">libgraal</a> will now be released to the OS when an application enters a stable phase and compilation is idle. This is achieved by attaching each compiler thread to a libgraal isolate. The number of compiler threads that can be attached to an isolate is controlled by the jvmci.ThreadsPerNativeLibraryRuntime system property. The default is all threads attached to a single isolate. Isolates are initialized on demand to handle extra compiler threads. When a compiler thread becomes idle, which is configurable by the jvmci.CompilerIdleDelay system property, it detaches itself from its isolate. As the last thread detaches from an isolate, the isolate is shut down and its memory (i.e., the libgraal heap) is released to the OS. This feature has a number of advantages:</p><ul><li>It can <strong>reduce the RSS memory footprint</strong> of a GraalVM process. If the compiler is not being used, it uses no resources.</li><li>If multiple isolates are used, it <strong>mitigates interference between complier threads</strong>. For example, there is less contention on shared objects, and a garbage collection in one isolate will not pause threads in other isolates.</li></ul><p>Another notable addition to GraalVM Enterprise edition is a new, experimental, off-by-default partial loop unrolling optimization. Loop unrolling is a traditional compiler optimization that can improve performance for computational heavy, loop focused workloads.</p><p>Partial loop unrolling is an extended form of this optimization that works for counted loops with an unknown upper bound of loop iterations i. The transformation creates two versions of the loop: a main version of the loop that can be unrolled n times leading to an optimized loop body doing floor(i/n) iterations, and a fix-up loop doing the remaining number of i % n iterations.</p><p>Consider the following Java example:</p><pre>for(int i = 0; i &lt; upp; i++){<br>// body<br>}</pre><p>Partial unrolling by a factor of 2 creates the two versions of the loop:</p><pre>int i1=0;<br>int unrollFactor=2;<br>for(;i1&lt;upp-unrollFactor;i1=i1+unrollFactor){<br>  // body i1<br>  // body i1 +1<br>}</pre><pre>int i2=i1;\<br>for(;i2&lt;upp;i2++){<br>  // body<br>}</pre><p>The major benefit of partial unrolling is the reduced number of jumps and updates to the loop control values, i.e., fewer counter increments and loop header jumps.</p><p>You can experiment with the new optimization by enabling it with -Dgraal.EnterprisePartialUnroll=true. However, note that it is experimental and thus may lead to unknown errors. We appreciate all feedback, so if you discover any issues during your experiments, please don’t hesitate to report them to the GraalVM team.</p><h3>Native image</h3><p>GraalVM Native Image continues to be a very exciting feature, and in 20.2.0 it got several important updates. Two of the features we’d like to highlight here are deployment improvements:</p><p>It was already possible to generate native executables where system libraries like libc are statically linked. This feature allows you to create fully standalone executables that can be used, for example, in the minimal FROM SCRATCH Docker containers that don’t have anything else present.</p><p>In 20.2.0, static compilation with Muslc got reworked and now you don’t have to rely on third party Muslc bundles. But it does require having a working musl-gcc in the system where you generate the native executable.</p><p>If you don’t have it installed and ready, there’s an instruction on <a href="https://github.com/oracle/graal/blob/master/substratevm/STATIC-IMAGES.md">how to get it</a>.</p><p>You can verify that it is installed correctly by running:</p><pre>musl-gcc -v</pre><p>Then, generating a native executable statically linked against muslc is a matter of providing the following arguments to the Native Image utility:</p><pre> — static — libc=musl</pre><p>Then the Docker image for the application deployment could look something like this, assuming `my-native-app` is the generated executable:</p><pre>FROM scratch<br>COPY my-native-app /my-native-app<br>ENTRYPOINT [“/my-native-app”]</pre><p>It’ll create an empty Docker image and only place your application into it.</p><p>Another interesting way of deploying native executables into containers is to use small Docker images with a minimum of dependencies, preferably with no operating system. For example, <a href="https://github.com/GoogleContainerTools/distroless/tree/master/base">distroless images</a> come to mind.</p><p>A distroless/base image contains only the following:</p><ul><li>ca-certificates</li><li>A /etc/passwd entry for a root user</li><li>A /tmp directory</li><li>tzdata</li><li>glibc</li><li>libssl</li><li>openssl</li></ul><p>To build your native executable and statically link everything, except libc which is provided by the container, use the Native Image -H:+StaticExecutableWithDynamicLibC flag.</p><p>We also improved Native Image support for the G1-based garbage collector which is available in GraalVM Enterprise. If you would like to try a garbage collection implementation that lowers the GC pause times, specify your GC preference with the following option: -H:+UseLowLatencyGC at build time. The native executable will build normally, and at runtime you can configure its memory usage with the usual flags -Xmx and monitor the GC activity with the -XX:+PrintGC or -XX:+VerboseGC.</p><p>Last, but not least, there’s a potentially breaking change in 20.2.0: the class initialization strategy has been changed to include fewer classes from the JDK library to be initialized at build time.</p><p>If you are initializing your application classes at build time, they might trigger initialization of the JDK library classes at build time, which will conflict with the new strategy, and the build will not succeed. You can solve this problem by introducing the build time class initialization for necessary classes, yourself.</p><p>For example, for a sample Micronaut application, I needed to add — initialize-at-build-time=com.sun.org.apache.xerces,com.sun.xml.internal,jdk.xml.internal to the command line to initialize those classes at build time, like prior to the 20.2.0 release.</p><p>If you’re relying on a framework or library to configure your native image generation, you might need to update it to a more recent version that works with the 20.2.0.</p><h3>Truffle</h3><p>One important change to the Truffle language implementation framework was changing the default inlining heuristic for the language interpreters in which inlining budgets are based on Graal IR node counts and not Truffle Node counts.<br>This is a very interesting change that makes inlining, which is a very important optimization, work better at estimating the cost of the optimization. A Truffle node can be of arbitrary complexity and overspend the inlining budget by “tricking” the inlining heuristic into counting it as just one node. So estimating code size for inlining based on the Truffle node count could lead to inefficient results.</p><p>A very welcome addition to the language implementation API available in 20.2.0 is the DynamicObject model, and library to make use of it. You can find more details in <a href="https://github.com/oracle/graal/blob/master/truffle/docs/DynamicObjectModel.md">the docs</a>, but in a nutshell — they allow language implementations better control over the layout of objects in dynamic languages, and accommodate dynamically adding members or changing types. This allows better handling of objects by shapes and makes accessing object properties more efficient.</p><h3>JavaScript</h3><p>In GraalVM 20.2.0 we updated Node.js to version 12.18.0. We also implemented a number of proposals: <a href="https://github.com/tc39/proposal-unified-intl-numberformat">Intl.NumberFormat Unified API</a>, the <a href="https://github.com/tc39/proposal-logical-assignment">Logical Assignment Operators</a>, the <a href="https://github.com/tc39/proposal-top-level-await">Top-level Await</a> proposal, even the <a href="https://github.com/tc39/proposal-promise-any">Promise.any</a> proposal (available with the ECMAScript 2021 mode).</p><p>There’s also a freshly implemented support for async stack traces that you can try.</p><h3>Ruby</h3><p>We’d like to highlight the compatibility improvements in TruffleRuby in GraalVM 20.2.0. Besides a ton of other changes you can see in the release notes, now the Ripper stdlib has been implemented using the C extension.</p><p>This release has also improved compatibility (notably refinements) and updated to Ruby 2.6.6, added better interoperability support with other languages, and includes various performance improvements.</p><h3>Python</h3><p>Among the most notable changes in GraalPython, we implemented better reference counting for native extensions to fix memory leaks.</p><p>We also introduced code serialization to .pyc files (.pyc files persistently store the Python bytecode compiled from the source .py files), which should improve startup of Python programs.</p><p>GraalVM Enterprise Python implementation now also includes a faster implementation of _struct.</p><h3>Tools</h3><p>Tools are a very important part of the GraalVM project. In 20.2.0 there was a number of improvements to <a href="https://www.graalvm.org/tools/vscode-extension/">GraalVM support in VSCode</a>.</p><p>The Language Server Protocol implementation now supports latest protocol version 3.15. GraalVM LSP is a very interesting addition to the usual LSP implementation in VS Code — it can notice dynamic information only available at the runtime of your program and use that to add suggestions to the content assist in the IDE for you.</p><p>All GraalVM VSCode extensions were merged into one, which you can obtain from the <a href="https://marketplace.visualstudio.com/">marketplace</a>.</p><p>VSCode can also now show code coverage from GraalVM LSP.</p><p>VisualVM now includes a <a href="https://visualvm.github.io/sourcessupport.html">GoToSource action</a>, so you can jump from the profiler into your preferred IDE. This is a welcome addition to quickly navigate to the place in your code that requires the most attention.</p><p>If you configure it with the source roots location:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*2bMFTDcWA-sIKjGux5JnIw.png" /></figure><p>And right click on the class or method name in one of the views, for example in the CPU profiler:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8o52o8iQrqHIA-rOAyY0NQ.png" /></figure><p>It opens that file in your favourite IDE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OScdIRd-Xxh0Kw2J8aOJFw.png" /></figure><p>These are only some of the improvements we are so proud of in the GraalVM 20.2.0 feature release! Please read a more detailed outline of the new and noteworthy features in the <a href="https://www.graalvm.org/release-notes/20_2/#2020">release notes</a> and consider looking at the changelog for the project components on <a href="https://github.com/oracle/graal">GitHub</a>!</p><p><a href="https://www.graalvm.org/downloads/">Download GraalVM 20.2</a> or <a href="https://www.oracle.com/downloads/graalvm-downloads.html">GraalVM Enterprise 20.2</a>, use it for running your applications, and build new, exciting projects. If you have any feedback please don’t hesitate to let us know on <a href="https://twitter.com/graalvm">Twitter</a>, <a href="https://www.graalvm.org/slack-invitation/">Slack</a> or <a href="https://github.com/oracle/graal">GitHub</a>!</p><p>— GraalVM Team</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=674e7f6dae27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/graalvm/announcing-graalvm-20-2-0-674e7f6dae27">Announcing GraalVM 20.2.0</a> was originally published in <a href="https://medium.com/graalvm">graalvm</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>