{"id":2018,"date":"2019-12-13T01:00:00","date_gmt":"2019-12-13T01:00:00","guid":{"rendered":"https:\/\/www.javaadvent.com\/?p=2018"},"modified":"2019-12-15T20:44:43","modified_gmt":"2019-12-15T20:44:43","slug":"project-valhalla-fast-and-furious-java","status":"publish","type":"post","link":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html","title":{"rendered":"Project Valhalla: fast and furious java"},"content":{"rendered":"<h2>Exploring the performance improvements of new Inline Types<\/h2>\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<p>Project Valhalla is one of the most interesting projects regarding the future of Java and of all JVM. It is still in an experimental state, but in this post we will look at how to try it, and we will implement a small program to verify the kind of performance improvements are possible with it.<\/p>\n\n\n\n<p>Valhalla\u2019s aim is to bring a new Inline Types (aka Value Types) that will: <em>\u201cCodes like a class works like an int\u201d<\/em>.<\/p>\n\n\n\n<p>Currently, in the JVM there are 8 kinds of primitive types, each one is associated with a \u201csignature letter\u201d of the alphabet:<\/p>\n\n\n\n<p><strong>B<\/strong> byte signed byte<br><strong>C<\/strong> char Unicode character encoded with UTF-16<br><strong>D<\/strong> double double-precision floating-point value<br><strong>F<\/strong> float single-precision floating-point value<br><strong>I<\/strong> int integer<br><strong>J<\/strong> long long integer<br><strong>S<\/strong> short signed short<br><strong>Z<\/strong> boolean true or false<\/p>\n\n\n\n<p>On top of these, we have objects:<\/p>\n\n\n\n<p><strong>L<\/strong> ClassName reference an instance of class ClassName<\/p>\n\n\n\n<p>You may have noted the signature letter if you printed out the result of <code>toString()<\/code> method for a generic object.<\/p>\n\n\n\n<p>Project Valhalla introduces a new letter for a new kind of types:<\/p>\n\n\n\n<p><strong>Q<\/strong> ClassName inline types<\/p>\n\n\n\n<p>These new types will eventually replace the primitive types in our applications, removing current boxed types (Integer and such) and bringing a new seamless world based on Reference and Inline types only.<\/p>\n\n\n\n<p>This is still in the future, for the moment let&#8217;s enjoy what is already available in the current Early-Access build.<\/p>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">Getting Started<\/h2>\n\n\n\n<p>To simplify the set-up, the Project Valhalla team released an Early-Access Build on August the 30th.&nbsp;<\/p>\n\n\n\n<p>You can download it from here and configure it in JAVA_HOME as a normal JDK (version 14): <a href=\"http:\/\/jdk.java.net\/valhalla\/\" rel=\"noreferrer noopener\" target=\"_blank\">http:\/\/jdk.java.net\/valhalla\/<\/a><\/p>\n\n\n\n<p>Unfortunately at the moment (December 2019) IntelliJ and Gradle are not able to compile a source with the new features of the language. We need to use the JDK command-line tools or ant.<\/p>\n\n\n\n<p>I shared on Github a <a href=\"https:\/\/github.com\/uberto\/testValueTypes\" rel=\"noreferrer noopener\" target=\"_blank\">repository<\/a> with several examples and the ant build scripts needed to run them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Valhalla POINT<\/h2>\n\n\n\n<p>Let&#8217;s start from something very simple, let&#8217;s define a Point type with two fields for the coordinates.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\ninline public class Point {\n    public int x;\n    public int y;\n\n    public Point(int x, int y) {\n        this.x = x;\n        this.y = y;\n    }\n}\n<\/pre><\/div>\n\n\n<p>The only change is the inline keyword on line 1.  Point is an Inline Type and now we will look at the differences with a normal class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code like a Class<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>It can be created using <strong>new<\/strong><\/li><li>As you can see, you can declare fields, constructors, and methods like a normal class<\/li><li>It can implement an Interface, overriding the methods.<\/li><li>It can be used by generics and can have generic parameters<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Work like an int<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>The type Point is <strong>immutable<\/strong>. The fields x and y are automatically treated as final. We can decide if we want them private or public but we cannot change them.<\/li><li>Point has automatically generated methods equals, toString, and hashcode. We can test its equality using the <strong>==<\/strong> operator like int and double.<\/li><li>Point has no <strong>null<\/strong> value. If you want to represent a null Point you need to use the new &#8220;inline widening&#8221; which are a kind of boxing on steroids.<\/li><li>Point instances are not allocated separately from their references, they are represented directly in memory, like int now.<\/li><li>Point has a default value, that corresponds to Point(0,0). It can be created with Point.default.<\/li><li>Point cannot inherit from another type and nothing can inherit from it.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Work in progress<\/h2>\n\n\n\n<p>Some characteristics are still unfinished and they may not work in the current build or change how they work in future releases. In particular: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>It is not possible to use synchronization operations on Inline Types. So no synchronized methods, locks, wait\/notify.<\/li><li>Reflection: It&#8217;s not possible to distinguish them from reference objects. There will be some special interface for this.<\/li><li>Thread-safe: it&#8217;s currently not possible to have a volatile behavior and to use them in Atomic operations.<\/li><\/ul>\n\n\n\n<p>For a more comprehensive look at Project Valhalla features, see the articles linked at the end. Here we will concentrate on the performance aspect of it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Compact Arrays<\/h2>\n\n\n\n<p>One of the most exciting features of the Inline Classes is the way in which arrays are created.<\/p>\n\n\n\n<p>In the case of primitives, each position of the array has the direct representation of the type; for example, the 64 bits of a long in case of an array of long.<\/p>\n\n\n\n<p>In the case of the referenced object instead, the array will only contain the reference to the object allocated memory on the heap.<\/p>\n\n\n\n<p>This means that reading an object from an array involves first reading the reference and then fetching the memory from its actual location. If the object has referenced fields, those would also cause data to be fetched from a remote memory location. <\/p>\n\n\n\n<p>Inline Types on the other side work like primitives.<\/p>\n\n\n\n<p>To have a taste of how much this matters, let&#8217;s make a simple test program to sum all trades from a given account in a big array.<\/p>\n\n\n\n<p>Here is our trade&#8217;s simple representation, with an amount, an account and a traded security.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\npublic class TradeRef {\n    public final double amount;\n    public final String account;\n    public final String security;\n\n    public TradeRef(double amount, String account, String security) {\n        this.amount = amount;\n        this.account = account;\n        this.security = security;\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n        TradeRefEncoded that = (TradeRefEncoded) o;\n        return Double.compare(that.amount, amount) == 0 &amp;&amp;\n                account == that.account &amp;&amp;\n                security == that.security;\n    }\n\n    @Override\n    public int hashCode() {\n        return Objects.hash(amount, account, security);\n    }\n}\n<\/pre><\/div>\n\n\n<p>Similarly, we will define a <code>TradeInline<\/code> class, identical with the inline modifier:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\ninline public class TradeInline {\n    final double amount;\n    final String account;\n    final String security;\n\n    public TradeInline(double amount, String account, String security) {\n        this.amount = amount;\n        this.account = account;\n        this.security = security;\n    }\n}\n<\/pre><\/div>\n\n\n<p>After the compilation, we can use <code>javap<\/code> from the command line to print the generated ByteCode:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\njavap -s antbuild\/com\/ubertob\/ministring\/TradeInline.class \n<\/pre><\/div>\n\n\n<p>And this is the output:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\npublic final value class com.ubertob.ministring.TradeInline {\n  final double amount;\n    descriptor: D\n  final java.lang.String account;\n    descriptor: Ljava\/lang\/String;\n  final java.lang.String security;\n    descriptor: Ljava\/lang\/String;\n  public final int hashCode();\n    descriptor: ()I\n\n  public final boolean equals(java.lang.Object);\n    descriptor: (Ljava\/lang\/Object;)Z\n\n  public final java.lang.String toString();\n    descriptor: ()Ljava\/lang\/String;\n\n  public static com.ubertob.ministring.TradeInline com.ubertob.ministring.TradeInline(double, java.lang.String, java.lang.String);\n    descriptor: (DLjava\/lang\/String;Ljava\/lang\/String;)Qcom\/ubertob\/ministring\/TradeInline;\n}\n<\/pre><\/div>\n\n\n<p>Note the value modifier in the first line and the methods hashCode, equals, and toString that are not present in our class. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">encoding a string into a long<\/h2>\n\n\n\n<p>Our <code>TradeInline<\/code> class has still two String inside as fields. Can we inline them?<\/p>\n\n\n\n<p>Unfortunately at the moment is not possible to flatten String and Arrays inside an Inline type. There are future plans for something called Array 2.0 that would allow for that.<\/p>\n\n\n\n<p>What we can do now instead, is to squeeze a String inside a <code>long<\/code> type, although we need to accept some limitations.<\/p>\n\n\n\n<p>The <code>long<\/code> type has 64 bits, so using a base 64 encoding (6 bits) we can store up to 10 characters inside.<\/p>\n\n\n\n<p>In our case, we assume that the Security and the Account have a maximum length of 10 characters and they are composed only of uppercase letters, numbers and a limited number of special characters.<\/p>\n\n\n\n<p>This is the code of our <code>MiniString<\/code> inline type, with the encoding and decoding static functions:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\ninline public class MiniString {\n\n    long raw;\n\n    public MiniString(String str) {\n        raw = encode(str);\n    }\n\n    public String get() {\n        return decode(raw);\n    }\n\n    public static final int MAX_MINISTR_LEN = 10;\n    public static final int MINI_STR_BASE = 64;\n    public static final String letters = &quot;=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 _-!?.$&amp;%@#:&#x5B;]{}()*&lt;&gt;:;',\/^&quot;;\n\n    public static long encode(String str) {\n        String prepared = prepareString(str);\n        long encoded = 0;\n        for (char c : prepared.toCharArray()) {\n            int x = letters.indexOf(c);\n            encoded = encoded * MINI_STR_BASE + x;\n        }\n        return encoded;\n    }\n\n    private static String prepareString(String str) {\n        StringBuilder prepared = new StringBuilder();\n        for (char c : str.toCharArray()) {\n            if (letters.indexOf(c) &gt;= 0)\n                prepared.append(c);\n            if (prepared.length() &gt; MAX_MINISTR_LEN)\n                break;\n        }\n        return prepared.toString();\n    }\n\n    public static String decode(long number) {\n        StringBuilder decoded = new StringBuilder();\n        long remaining = number;\n\n        while (true) {\n            int mod = (int) ( remaining % MINI_STR_BASE);\n            char c = letters.charAt(mod);\n            decoded.insert(0, c);\n            if ( remaining &lt; MINI_STR_BASE)\n                break;\n            remaining = remaining \/ MINI_STR_BASE;\n        }\n        return decoded.toString();\n    }\n}\n\n<\/pre><\/div>\n\n\n<p>We will define a <code>TradeMiniString<\/code> inline type using our new <code>MiniString<\/code> for Account and Security.<\/p>\n\n\n\n<p>This is the generated ByteCode:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npublic final value class com.ubertob.ministring.TradeMiniString {\n  final double amount;\n    descriptor: D\n  final com.ubertob.ministring.MiniString account;\n    descriptor: Qcom\/ubertob\/ministring\/MiniString;\n  final com.ubertob.ministring.MiniString security;\n    descriptor: Qcom\/ubertob\/ministring\/MiniString;\n  public final int hashCode();\n    descriptor: ()I\n\n  public final boolean equals(java.lang.Object);\n    descriptor: (Ljava\/lang\/Object;)Z\n\n  public final java.lang.String toString();\n    descriptor: ()Ljava\/lang\/String;\n\n  public static com.ubertob.ministring.TradeMiniString com.ubertob.ministring.TradeMiniString(double, java.lang.String, java.lang.String);\n    descriptor: (DLjava\/lang\/String;Ljava\/lang\/String;)Qcom\/ubertob\/ministring\/TradeMiniString;\n}\n\n<\/pre><\/div>\n\n\n<p>Note how the descriptor for the <code>MiniString<\/code> account starts with the Q of inline types and not with the L of the reference types.<\/p>\n\n\n\n<p>Finally, to have a fair comparison, we also define a <code>TradeRefEncoded<\/code> class using the same trick to encode an Account and Security in a field of type <code>long<\/code>.<\/p>\n\n\n\n<p>You can find the complete code in my GitHub <a href=\"https:\/\/github.com\/uberto\/testValueTypes\">repository<\/a>.<\/p>\n\n\n\n<p>Before looking at the performance, let&#8217;s look how our Trade objects are using the memory.<\/p>\n\n\n\n<p>First the standard <code>TradeRef<\/code> object:<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdn-images-1.medium.com\/max\/1040\/1%2AMJ5EQT7q64jc_Up7VW9EPQ.jpeg?w=600&#038;ssl=1\" alt=\"\" \/><\/figure>\n\n\n\n<p>On the left, there is our big array. Then a pointer to the TradeRef object, and then two other pointers to the strings.<\/p>\n\n\n\n<p>Depending on the order of creation, these can be quite far apart in our heap.<\/p>\n\n\n\n<p>This is a performance problem because fetching memory from different regions is one of the slowest operations for a CPU.<\/p>\n\n\n\n<p>This classic post from Martin Thomson is one of the better explanations:<br><a href=\"https:\/\/mechanical-sympathy.blogspot.com\/2012\/08\/memory-access-patterns-are-important.html\">https:\/\/mechanical-sympathy.blogspot.com\/2012\/08\/memory-access-patterns-are-important.html<\/a><\/p>\n\n\n\n<p>Let&#8217;s look at a simple diagram of the InlineTrade value memory representation now:<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdn-images-1.medium.com\/max\/1040\/1%2ABeXWJLZ86v7_HJeRUllzlA.jpeg?w=600&#038;ssl=1\" alt=\"\" \/><\/figure>\n\n\n\n<p>Here the whole value is directly on the array. For this reason, the array is actually bigger than in the first case. If you don&#8217;t allocate all objects, in other words, if your array mostly contains null values, this can be a drawback.<\/p>\n\n\n\n<p>Finally, let&#8217;s see how the TradeMiniString is allocated in the memory:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/cdn-images-1.medium.com\/max\/1040\/1%2A8HKp5hn4sX5yRv93uvLC4Q.jpeg?w=600&#038;ssl=1\" alt=\"\" \/><\/figure><\/div>\n\n\n\n<p>You can see that it stays completely inside the array element, with no external pointers.<\/p>\n\n\n\n<p>This is possible only because we accept big limitations on what can be contained in those strings; still, it&#8217;s an acceptable compromise when using strings only for storing ID from a database or the stock ticker symbols.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Performance Comparison<\/h2>\n\n\n\n<p>To compare the performance we can create four arrays of 5 million elements, one for each of our trade types:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n    static final int arraySize = 5_000_000;\n\n    public TradeRef&#x5B;] tradeRefs = new TradeRef&#x5B;arraySize];\n    public TradeRefEncoded&#x5B;] tradesRefEncoded = new TradeRefEncoded&#x5B;arraySize];\n    public TradeInline&#x5B;] tradesInline = new TradeInline&#x5B;arraySize];\n    public TradeMiniString&#x5B;] tradesMiniString = new TradeMiniString&#x5B;arraySize];\n\n<\/pre><\/div>\n\n\n<p>Then we fill them with identical random values:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n    public static void generatingTradesAndBrowing() {\n\n        var tr = new TradeRepository();\n        tr.fillWithRandomData();\n\n        var searcherRef = new TradeRefBrowser(tr.tradeRefs);\n        var searcherInline = new InlineTradeBrowser(tr.tradesInline);\n        var searcherRefEncoded = new TradeRefEncodedBrowser(tr.tradesRefEncoded);\n        var searcherMiniString = new MiniStringTradeBrowser(tr.tradesMiniString);\n\n        var account = tr.tradeRefs&#x5B;1000].account;\n\n        while (true) {\n            benchmarks(searcherRef, searcherInline, searcherRefEncoded, searcherMiniString, account);\n        }\n    }\n<\/pre><\/div>\n\n\n<p>And finally, we do searches on each one repeatedly, printing out the time elapsed.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n    private static void benchmarks(TradeRefBrowser searcherRef, InlineTradeBrowser searcherInline, TradeRefEncodedBrowser searcherRefEncoded, MiniStringTradeBrowser searcherMiniString, String account) {\n        cronoSum(() -&gt; searcherRef.sumByAccountFor(account), &quot;Ref with for&quot;);\n        cronoSum(() -&gt; searcherRef.sumByAccountStream(account), &quot;Ref with stream&quot;);\n\n        cronoSum(() -&gt; searcherRefEncoded.sumByAccountFor(account), &quot;RefEncoded with for&quot;);\n        cronoSum(() -&gt; searcherRefEncoded.sumByAccountStream(account), &quot;RefEncoded with stream&quot;);\n\n        cronoSum(() -&gt; searcherInline.sumByAccountFor(account), &quot;Inline with for&quot;);\n        cronoSum(() -&gt; searcherMiniString.sumByAccountFor(account), &quot;MiniString with for&quot;);\n    }\n<\/pre><\/div>\n\n\n<p>We don&#8217;t care much about specific numbers here, so we just keep looping and print the results. The timings tend to stabilize after a few minutes when the Java Hotspot compiler optimizes and inlines most of the methods.<\/p>\n\n\n\n<p>We can filter and sum using two methods: a for loop or a nicer stream map and reduce:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n    public double sumByAccountStream(String account){\n        return Arrays.stream(repo)\n                .filter( trade -&amp;gt; trade.account.equals(account))\n                .map(trade -&amp;gt; trade.amount)\n                .reduce(0.0, (a, b) -&amp;gt; a+b);\n    }\n\n    public double sumByAccountFor(String account){\n        double res = 0;\n        for (int i = 0; i &amp;lt; repo.length; i++) {\n            TradeRef tradeRef = repo&#x5B;i];\n            if (tradeRef.account.equals(account))\n                res = res + tradeRef.amount;\n        }\n        return res;\n    }\n<\/pre><\/div>\n\n\n<p>Unfortunately, streams are not (yet) working with Inline Classes:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nException in thread &quot;main&quot; java.lang.ClassFormatError: Illegal class name &quot;Qcom\/ubertob\/ministring\/TradeMiniString;&quot; in class file &amp;lt;Unknown&amp;gt;\n        at java.base\/jdk.internal.misc.Unsafe.defineAnonymousClass0(Native Method)\n        at java.base\/jdk.internal.misc.Unsafe.defineAnonymousClass(Unsafe.java:1345)\n        at java.base\/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:324)\n        at java.base\/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:192)\n        at java.base\/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:329)\n        at java.base\/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:127)\n        at java.base\/java.lang.invoke.CallSite.makeSite(CallSite.java:307)\n        at java.base\/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:259)\n        at java.base\/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:249)\n        at com.ubertob.ministring.MiniStringTradeBrowser.sumByAccountStream(Unknown Source)\n\n<\/pre><\/div>\n\n\n<p>So for the moment we can only measure performance using for loops.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Fancy Graphs (finally)<\/h2>\n\n\n\n<p>The actual numbers are not very important here, so I just grabbed a significative sample running the application on my Linux laptop.<\/p>\n\n\n\n<p>Rather than the numbers, we are interested in how fast they are relative to each other.<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"360\" data-attachment-id=\"2156\" data-permalink=\"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html\/screenshot-from-2019-12-10-21-26-37\" data-orig-file=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-37.png?fit=888%2C533&amp;ssl=1\" data-orig-size=\"888,533\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-from-2019-12-10-21-26-37\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-37.png?fit=600%2C360&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-37.png?resize=600%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-2156\" srcset=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-37.png?w=888&amp;ssl=1 888w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-37.png?resize=300%2C180&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-37.png?resize=768%2C461&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-37.png?resize=508%2C305&amp;ssl=1 508w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption>time in millisec, small are better<\/figcaption><\/figure>\n\n\n\n<p>We can see here how in this case the improvement is really huge: inline TradeMiniString is more than 20x faster!<\/p>\n\n\n\n<p>Event compared with the TradeRefEncoded is still 6x faster!<\/p>\n\n\n\n<p>This seems almost too good to be true, so we can use a better method to measure the actual performance.<\/p>\n\n\n\n<p>Brendan Gregg wrote some very useful tools to use Linux kernel perf tool to profile Java programs.<\/p>\n\n\n\n<p>There are several blog posts on how to produce and how to read flame graphs:<a href=\"https:\/\/medium.com\/netflix-techblog\/java-in-flames-e763b3d32166\"><br>https:\/\/medium.com\/netflix-techblog\/java-in-flames-e763b3d32166<a href=\"https:\/\/medium.com\/netflix-techblog\/java-in-flames-e763b3d32166\"><\/a><\/a><\/p>\n\n\n\n<p>And here are our flames:<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"438\" data-attachment-id=\"2155\" data-permalink=\"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html\/flame_java_4\" data-orig-file=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?fit=1200%2C438&amp;ssl=1\" data-orig-size=\"1200,438\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"flame_java_4\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?fit=600%2C219&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?fit=600%2C219&amp;ssl=1\" alt=\"\" class=\"wp-image-2155\" srcset=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?w=1200&amp;ssl=1 1200w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?resize=300%2C110&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?resize=1024%2C374&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?resize=768%2C280&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/flame_java_4.png?resize=508%2C185&amp;ssl=1 508w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n\n\n\n<p>You can find the actual svg file in the GitHub repository <a href=\"https:\/\/github.com\/uberto\/testValueTypes\/blob\/master\/flame_java_4.svg\">here<\/a>.<\/p>\n\n\n\n<p>We can see four green blocks (including the one with the arrow) that are a representation of how much time these four methods used the CPU. In this graph, the green blocks are Java calls, while the red ones are kernel system calls.<\/p>\n\n\n\n<p>The spikes are other methods, related to the print out of results and garbage collection. We can ignore them.<\/p>\n\n\n\n<p>From the left, the first block is the InlineTrade, using normal strings. It is clearly smaller than the last two blocks which represent the TradeRef and TradeRefEncoded.<\/p>\n\n\n\n<p>As you may have guessed, the block pointed by the arrow is the TradeMiniString duration, it is so brief that you can read only a few characters of the name.<\/p>\n\n\n\n<p>The relative duration of each method from the perf profile is reported in this graph:<\/p>\n\n\n\n<figure class=\"wp-block-image alignwide size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"353\" data-attachment-id=\"2157\" data-permalink=\"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html\/screenshot-from-2019-12-10-21-26-52\" data-orig-file=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-52.png?fit=923%2C543&amp;ssl=1\" data-orig-size=\"923,543\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-from-2019-12-10-21-26-52\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-52.png?fit=600%2C353&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-52.png?resize=600%2C353&#038;ssl=1\" alt=\"\" class=\"wp-image-2157\" srcset=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-52.png?w=923&amp;ssl=1 923w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-52.png?resize=300%2C176&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-52.png?resize=768%2C452&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/Screenshot-from-2019-12-10-21-26-52.png?resize=508%2C299&amp;ssl=1 508w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption>number of perf samples, smaller are better<\/figcaption><\/figure>\n\n\n\n<p>The relative timings are similar, Inline is 6 times faster than Ref and Inline Encoded is 5.5 times faster than Ref Encoded.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusions<\/h2>\n\n\n\n<p>It is still too early for precise measurements, but it is already clear that Valhalla inline types have the potential to bring a massive performance boost for a certain type of critical applications.<\/p>\n\n\n\n<p>There are still many rough edges and painful decisions to make but the overall shape of the Valhalla project is very exciting.<\/p>\n\n\n\n<p>Since the last Early-Access build there have already been many improvements in the source code, let&#8217;s hope to have another stable build to test soon with more features.<\/p>\n\n\n\n<hr class=\"wp-block-separator\" \/>\n\n\n\n<h2 class=\"wp-block-heading\">resources to learn more<\/h2>\n\n\n\n<p>The full code of this and other examples:<br><a href=\"https:\/\/github.com\/uberto\/testValueTypes\">https:\/\/github.com\/uberto\/testValueTypes<\/a><\/p>\n\n\n\n<p>A Recent video about Valhalla at Devoxx BE<br><a rel=\"noreferrer noopener\" href=\"https:\/\/devoxx.be\/talk\/?id=41660\" target=\"_blank\">https:\/\/devoxx.be\/talk\/?id=41660<\/a><\/p>\n\n\n\n<p>Brian Goetz on the State of Valhalla<br><a href=\"http:\/\/cr.openjdk.java.net\/~briangoetz\/valhalla\/sov\/02-object-model.html\">http:\/\/cr.openjdk.java.net\/~briangoetz\/valhalla\/sov\/02-object-model.html<\/a><\/p>\n\n\n\n<p>An in-depth explanation of Inline Types from Ben Evans:<br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.infoq.com\/articles\/inline-classes-java\/?itm_source=infoq&amp;itm_campaign=user_page&amp;itm_medium=link\" target=\"_blank\">https:\/\/www.infoq.com\/articles\/inline-classes-java<\/a><\/p>\n\n\n\n<p>My post on the previous early-access build:<br><a rel=\"noreferrer noopener\" href=\"https:\/\/medium.com\/@ramtop\/a-taste-of-value-types-1a8a136fcfe2\" target=\"_blank\">https:\/\/medium.com\/@ramtop\/a-taste-of-value-types-1a8a136fcfe2<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Exploring the performance improvements of new Inline Types Project Valhalla is one of the most interesting projects regarding the future of Java and of all JVM. It is still in an experimental state, but in this post we will look at how to try it, and we will implement a small program to verify the [&hellip;]<\/p>\n","protected":false},"author":57,"featured_media":2171,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[381,11,4,158,397],"tags":[489,262,492,491,490],"coauthors":[328],"class_list":["post-2018","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-christmas-2019-is-coming","category-java","category-java-advent","category-memory","category-performance","tag-java-valhalla","tag-jdk","tag-memory","tag-peformance","tag-project-valhalla"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Project Valhalla: fast and furious java - JVM Advent<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Project Valhalla: fast and furious java - JVM Advent\" \/>\n<meta property=\"og:description\" content=\"Exploring the performance improvements of new Inline Types Project Valhalla is one of the most interesting projects regarding the future of Java and of all JVM. It is still in an experimental state, but in this post we will look at how to try it, and we will implement a small program to verify the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html\" \/>\n<meta property=\"og:site_name\" content=\"JVM Advent\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Java-Advent-Calendar-229536173843473\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-13T01:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-15T20:44:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javaadvent.com\/content\/uploads\/2019\/12\/RefObject.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"468\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Uberto Barbini\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/ramtop\" \/>\n<meta name=\"twitter:site\" content=\"@javaadvent\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Uberto Barbini\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html\"},\"author\":{\"name\":\"Uberto Barbini\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#\\\/schema\\\/person\\\/45ab5c6c8f051edf24cabf86806530f8\"},\"headline\":\"Project Valhalla: fast and furious java\",\"datePublished\":\"2019-12-13T01:00:00+00:00\",\"dateModified\":\"2019-12-15T20:44:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html\"},\"wordCount\":1908,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2019\\\/12\\\/RefObject.jpg?fit=825%2C468&ssl=1\",\"keywords\":[\"java. valhalla\",\"jdk\",\"memory\",\"peformance\",\"project Valhalla\"],\"articleSection\":[\"2019\",\"java\",\"Java Advent\",\"memory\",\"Performance\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html\",\"url\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html\",\"name\":\"Project Valhalla: fast and furious java - JVM Advent\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2019\\\/12\\\/RefObject.jpg?fit=825%2C468&ssl=1\",\"datePublished\":\"2019-12-13T01:00:00+00:00\",\"dateModified\":\"2019-12-15T20:44:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#\\\/schema\\\/person\\\/45ab5c6c8f051edf24cabf86806530f8\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2019\\\/12\\\/RefObject.jpg?fit=825%2C468&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2019\\\/12\\\/RefObject.jpg?fit=825%2C468&ssl=1\",\"width\":825,\"height\":468},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2019\\\/12\\\/project-valhalla-fast-and-furious-java.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javaadvent.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Project Valhalla: fast and furious java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javaadvent.com\\\/\",\"name\":\"JVM Advent\",\"description\":\"The JVM Programming Advent Calendar\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javaadvent.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#\\\/schema\\\/person\\\/45ab5c6c8f051edf24cabf86806530f8\",\"name\":\"Uberto Barbini\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/577905fd141e081a88981f8b1c2ed348b4769831075cc75902ebba332bffbbe1?s=96&d=retro&r=ge2566195ea3a745d5cd6017b1936f735\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/577905fd141e081a88981f8b1c2ed348b4769831075cc75902ebba332bffbbe1?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/577905fd141e081a88981f8b1c2ed348b4769831075cc75902ebba332bffbbe1?s=96&d=retro&r=g\",\"caption\":\"Uberto Barbini\"},\"description\":\"Uberto is a very passionate and opinionated programmer, he helps big and small organizations in delivering value. Trainer, public speaker, and blogger. Currently working on a book on Kotlin and Functional Programming. Google Developer Expert.\",\"sameAs\":[\"https:\\\/\\\/medium.com\\\/@ramtop\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/uberto\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/ramtop\"],\"url\":\"https:\\\/\\\/www.javaadvent.com\\\/author\\\/uberto\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Project Valhalla: fast and furious java - JVM Advent","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html","og_locale":"en_US","og_type":"article","og_title":"Project Valhalla: fast and furious java - JVM Advent","og_description":"Exploring the performance improvements of new Inline Types Project Valhalla is one of the most interesting projects regarding the future of Java and of all JVM. It is still in an experimental state, but in this post we will look at how to try it, and we will implement a small program to verify the [&hellip;]","og_url":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html","og_site_name":"JVM Advent","article_publisher":"https:\/\/www.facebook.com\/Java-Advent-Calendar-229536173843473\/","article_published_time":"2019-12-13T01:00:00+00:00","article_modified_time":"2019-12-15T20:44:43+00:00","og_image":[{"width":825,"height":468,"url":"https:\/\/www.javaadvent.com\/content\/uploads\/2019\/12\/RefObject.jpg","type":"image\/jpeg"}],"author":"Uberto Barbini","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/ramtop","twitter_site":"@javaadvent","twitter_misc":{"Written by":"Uberto Barbini","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#article","isPartOf":{"@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html"},"author":{"name":"Uberto Barbini","@id":"https:\/\/www.javaadvent.com\/#\/schema\/person\/45ab5c6c8f051edf24cabf86806530f8"},"headline":"Project Valhalla: fast and furious java","datePublished":"2019-12-13T01:00:00+00:00","dateModified":"2019-12-15T20:44:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html"},"wordCount":1908,"commentCount":0,"image":{"@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/RefObject.jpg?fit=825%2C468&ssl=1","keywords":["java. valhalla","jdk","memory","peformance","project Valhalla"],"articleSection":["2019","java","Java Advent","memory","Performance"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html","url":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html","name":"Project Valhalla: fast and furious java - JVM Advent","isPartOf":{"@id":"https:\/\/www.javaadvent.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#primaryimage"},"image":{"@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/RefObject.jpg?fit=825%2C468&ssl=1","datePublished":"2019-12-13T01:00:00+00:00","dateModified":"2019-12-15T20:44:43+00:00","author":{"@id":"https:\/\/www.javaadvent.com\/#\/schema\/person\/45ab5c6c8f051edf24cabf86806530f8"},"breadcrumb":{"@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#primaryimage","url":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/RefObject.jpg?fit=825%2C468&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/RefObject.jpg?fit=825%2C468&ssl=1","width":825,"height":468},{"@type":"BreadcrumbList","@id":"https:\/\/www.javaadvent.com\/2019\/12\/project-valhalla-fast-and-furious-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javaadvent.com\/"},{"@type":"ListItem","position":2,"name":"Project Valhalla: fast and furious java"}]},{"@type":"WebSite","@id":"https:\/\/www.javaadvent.com\/#website","url":"https:\/\/www.javaadvent.com\/","name":"JVM Advent","description":"The JVM Programming Advent Calendar","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javaadvent.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.javaadvent.com\/#\/schema\/person\/45ab5c6c8f051edf24cabf86806530f8","name":"Uberto Barbini","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/577905fd141e081a88981f8b1c2ed348b4769831075cc75902ebba332bffbbe1?s=96&d=retro&r=ge2566195ea3a745d5cd6017b1936f735","url":"https:\/\/secure.gravatar.com\/avatar\/577905fd141e081a88981f8b1c2ed348b4769831075cc75902ebba332bffbbe1?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/577905fd141e081a88981f8b1c2ed348b4769831075cc75902ebba332bffbbe1?s=96&d=retro&r=g","caption":"Uberto Barbini"},"description":"Uberto is a very passionate and opinionated programmer, he helps big and small organizations in delivering value. Trainer, public speaker, and blogger. Currently working on a book on Kotlin and Functional Programming. Google Developer Expert.","sameAs":["https:\/\/medium.com\/@ramtop","https:\/\/www.linkedin.com\/in\/uberto\/","https:\/\/x.com\/https:\/\/twitter.com\/ramtop"],"url":"https:\/\/www.javaadvent.com\/author\/uberto"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/RefObject.jpg?fit=825%2C468&ssl=1","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":5457,"url":"https:\/\/www.javaadvent.com\/2024\/12\/jvm-in-the-age-of-ai-a-birds-eye-view-for-the-mechanical-sympathizers.html","url_meta":{"origin":2018,"position":0},"title":"JVM in the Age of AI: A Bird&#8217;s-Eye View for the Mechanical Sympathizers","author":"Artur Skowronski","date":"December 10, 2024","format":false,"excerpt":"Alright, hold on tight, because in today's edition of the advent calendar, we're going to talk about AI! Cause you know, we have 2024 and we do not need any other reason. Let's start by discussing what this article will cover. Each time the topic of AI arises, everyone tends\u2026","rel":"","context":"In &quot;2017&quot;","block_context":{"text":"2017","link":"https:\/\/www.javaadvent.com\/category\/2017"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-10.png?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-10.png?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-10.png?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-10.png?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2538,"url":"https:\/\/www.javaadvent.com\/2020\/12\/java-2077.html","url_meta":{"origin":2018,"position":1},"title":"Java 2077","author":"Nicolai Parlog","date":"December 10, 2020","format":false,"excerpt":"(Imagine a desolate urban area. Smoke rising from the rubble, worn-down people hiding in collapsed buildings. Text appearing on the screen, read with a raspy voice.) The year is 2077. The Java version is 128. It doesn't have long-term support. We were worried about climate change. Global pandemics. Antibiotic-resistant bacteria.\u2026","rel":"","context":"In &quot;2020&quot;","block_context":{"text":"2020","link":"https:\/\/www.javaadvent.com\/category\/2020"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2020\/12\/city-2444516_1920.jpg?fit=1200%2C726&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2020\/12\/city-2444516_1920.jpg?fit=1200%2C726&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2020\/12\/city-2444516_1920.jpg?fit=1200%2C726&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2020\/12\/city-2444516_1920.jpg?fit=1200%2C726&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2020\/12\/city-2444516_1920.jpg?fit=1200%2C726&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":4208,"url":"https:\/\/www.javaadvent.com\/2022\/12\/a-sneak-peek-at-the-java-performance-toolbox.html","url_meta":{"origin":2018,"position":2},"title":"A Sneak Peek at The Java Performance Toolbox","author":"Ana-Maria Mihalceanu","date":"December 7, 2022","format":false,"excerpt":"Performance, performance, performance - applications need performance! We hear, see, and breathe that with every change in Java applications. But making such changes in our code should result from a careful analysis: knowing what happened to the application and environment during a specific time. Understanding what is going on in\u2026","rel":"","context":"In &quot;2022&quot;","block_context":{"text":"2022","link":"https:\/\/www.javaadvent.com\/category\/jvm-advent-2022"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-7.png?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-7.png?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-7.png?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-7.png?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":5607,"url":"https:\/\/www.javaadvent.com\/2024\/12\/java-the-brave-companion-in-the-world-of-enterprise-software-solutions.html","url_meta":{"origin":2018,"position":3},"title":"Java: The Brave Companion in the World of Enterprise Software Solutions!","author":"Ixchel Ruiz","date":"December 23, 2024","format":false,"excerpt":"Enterprise solutions are designed to address the multifaceted requirements of businesses and organisations. Compared to solutions designed for consumer use, enterprise solutions typically have a longer development lifecycle and require a higher level of investment, and it is not only the development cycle, enterprise software tends to have a longer\u2026","rel":"","context":"In &quot;2017&quot;","block_context":{"text":"2017","link":"https:\/\/www.javaadvent.com\/category\/2017"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":6289,"url":"https:\/\/www.javaadvent.com\/2025\/12\/chicory-webassembly-on-the-jvm.html","url_meta":{"origin":2018,"position":4},"title":"Bring WebAssembly to the JVM. How Chicory Is Powering a New Generation of Java Libraries","author":"Andrea Peruffo","date":"December 23, 2025","format":false,"excerpt":"Introduction: the promise of \u201cembed once, run anywhere\u201d reimagined \u00a0 What if you could embed native\u2011level capabilities into your Java applications, think of database engines, scripting runtimes, policy interpreters, even compilers and still remain pure Java, with no JNI, no native binaries, no concerns about OS or architecture compatibility? That\u2026","rel":"","context":"In &quot;2017&quot;","block_context":{"text":"2017","link":"https:\/\/www.javaadvent.com\/category\/2017"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":59,"url":"https:\/\/www.javaadvent.com\/2013\/12\/part-1-of-3-synopsis-of-articles-videos-on-performance-tuning-jvm-gc-in-java-mechanical-sympathy-et-al.html","url_meta":{"origin":2018,"position":5},"title":"(Part 1 of 3): Synopsis of articles &#038; videos on Performance tuning, JVM, GC in Java, Mechanical Sympathy, et al","author":"gpanther","date":"December 1, 2013","format":false,"excerpt":"I have been contemplating for a number of months about reviewing a cache of articles and videos on topics like Performance tuning, JVM, GC in Java, Mechanical Sympathy, etc... and finally took the time to do it - may be this was the point in my intellectual progress when was\u2026","rel":"","context":"In &quot;2013&quot;","block_context":{"text":"2013","link":"https:\/\/www.javaadvent.com\/category\/2013"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts\/2018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/users\/57"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/comments?post=2018"}],"version-history":[{"count":19,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts\/2018\/revisions"}],"predecessor-version":[{"id":2177,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts\/2018\/revisions\/2177"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/media\/2171"}],"wp:attachment":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/media?parent=2018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/categories?post=2018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/tags?post=2018"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/coauthors?post=2018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}