10 comments

  • lazystone 6 hours ago
    > In theory, the whole AOT cache idea sounds like something that should only affect the class data and not perform any native compilation

    https://openjdk.org/jeps/544

    > Non-Goals

    > It is not a goal to support cross-compilation. Code compiled in a training run must run on the same CPU architecture, with the same set of features, in subsequent production runs.

    • crschnick 5 hours ago
      Your link is about a completely separate feature, called the AOT code cache (targeted for JDK28, not released yet). The post is about the AOT cache, which forms the foundation for this feature, but is separate and already available since JDK24. The JEP for the feature the post is about is https://openjdk.org/jeps/483
    • florieger 6 hours ago
      I wonder if this should trigger a warning (or even an error) at application startup whenever the CPU architectures differ.

      IMHO, that would be much better than running into crashes and having to figure out the cause yourself.

      • odo1242 3 hours ago
        Yea, it should probably warn and fallback to normal JIT
      • jayd16 4 hours ago
        Should probably just kick in the JIT at that point, no?
    • paulddraper 5 hours ago
      Yeah, there are some strange expectations going into this.

      "This is what I would like AOT cache to mean."

  • pron 5 hours ago
    For the past several years, Java features are released piecemeal, with each piece released as soon as it can be useful to some significant portion of users or users who can offer useful feedback (and when it's not expected to restrict future pieces). The AOT cache is already used in production despite not being as user-friendly as it could be, because the companies using it find it valuable.

    The first use case is the very common one (for Java) where developers control deployment (internal deployment). The last basic building block, caching machine code, will be released next year in JDK 28, and then the feature is likely to evolve to better support other use cases, such as external deployment.

    • jbellis 4 hours ago
      Yes. And this is the right tradeoff vs the ossification you saw previously in Java (and we're starting to see now in Python, see the recent ejection of the CPython JIT), especially now when you can say "GPT, source dive the JDK and figure out which cutting edge is causing the bleeding."
  • pjmlp 5 hours ago
    Note this is all about OpenJDK and Project Leyden.

    There are plenty of other AOT/JIT cache approaches in the Java ecosystem already, with more mature deployment experience of several years, namely:

    OpenJ9, Azul, PTC, Aicas, the Android cousin since Android 7

    Technology based on process snapshots CRaC for Amazon OpenJDK distro (Correcto), and OpenJ9, is also another approach available for some time.

  • deepsun 6 hours ago
    > What would be needed is some sort of compatibility switch that disables all optional CPU features. Sure, you will get some reduced performance of the compiled code, but in exchange, a faster startup time.

    I think other AOT-compiled languages don't opt in for the lowest set of CPU features -- they just detect them at runtime and use whenever present, all in compiled machine code.

  • _old_dude_ 6 hours ago
    The Inside Java podcast episode on AOT caching covers the issue in this segment:

    https://youtu.be/U2j4bKgKr-s?t=3577

  • emoII 5 hours ago
    What are the most common ways to improve warmup times, actually? Looked a bunch into this, primarily native image, aot and crac, all of them super messy to get to work with a normal JVM webapp. I understand the warmup concept is inherent in JIT compilation, but how are big companies like Netflix handling this to quickly scale microservices horizontally etc?
    • hocuspocus 5 hours ago
      Native images shouldn't be too messy anymore, Oracle put a lot of effort into DX improvements and all major web frameworks are now aware it's an important and growing use case.

      Struggling to build native images should be a sign you're reliant on libraries that are dangerously outdated and abandoned.

      • jcurtis 4 hours ago
        They can definitely be pretty messy in some ways; even the standard library doesn't work out of the box perfectly. I have certainly struggled to get image manipulation with java.awt (e.g. thumbnail generation for a fairly standard web use case) to work in a native image.
      • emoII 3 hours ago
        So it is an antipattern nowadays to manipulate the classpath after building? Iirc native image require static classpath, but it is quite common to inject e.g. environment specific data via the classpath. Should one just read from the filesystem instead, or what’s the strat there?
        • crschnick 3 hours ago
          With the AOT cache, you can actually modify the classpath (or module path as is now used for modern applications) after it has started up. The names and classes for the APIs are different, but you can still load jars at runtime even with the AOT cache enabled and functional.

          The AOT cache compatibility issues come when your boot module path differs between training and actual run. As long as that is not the case, you can use it without problem and load additional modules at runtime after it has started up.

          With GraalVM, that is not possible. It still has the closed-world assumption.

    • smrtinsert 52 minutes ago
      I mean, how fast do you need it to be? If you're running lambdas with cold starts all day long yes, java is a problem. Otherwise, occasional restarts of java services are quick assuming they're probably stateless. A few seconds? Whats the problem that needs to be solved here?
  • jiehong 6 hours ago
    When AOT came to be, I kinda hoped for GraalVM's solution would make it relatively as-is to open jdk.

    Instead, this AOT feature is not very ergonomic to use at all, with too many pitfalls to be of broad use IMO.

  • pregnenolone 3 hours ago
    I saw this on Reddit, and as expected, the replies from the Java community were quite hostile. Sometimes it feels like Java developers have never left their own ecosystem and have never seen how easy some things (like deployment) are on other platforms. Especially Java's way of deploying applications has hindered not only Java but also alt JVM languages like Kotlin and Scala.
    • wokkel 2 hours ago
      If you are regering to the mess that is python or javascript in beg to differ
      • robotnikman 2 hours ago
        Agreed, lets not try to recreate something like the npm dependency hell.
        • zbentley 1 hour ago
          Agreed, but that's not really relevant to the GP, who was comparing Java deployment ease vs. other platforms. NPM hell doesn't make deployment hard (quite the contrary); it makes security and stability/maintenance hard.

          Server-Side/Desktop JavaScript, I think, has a much better/more polished deployment experience than Java...at the cost of having a much worse build (ES module hell, bundler hell...) and maintenance (dependency hell, security hell, constantly changing APIs hell...) experience than Java, which excels at both of those.

  • JMKH42 6 hours ago
    I wonder if you could do the training run on install, so that each user gets a build tied to their specific cpu?
    • zbentley 1 hour ago
      That, and I think the cache busting based on CPU/environment probing logic will need to be significantly improved. Any difference in CPU features should not bust the cache; specific differences should bust the cache.

      There also might be a need for "downgrading" cross-compilation profiles a la "don't compile/AOT-cache this app for the current CPU, compile/cache it for <the kind of CPU that I have 10k EC2 instances running>". You'd think that would be easier to achieve by just compiling on a production-like machine, and you'd be disappointed by the number of shops running Java apps hand-built on a Windows laptop across millions of cloud Linux cores.

    • pron 5 hours ago
      Yes (or something along those lines), it's just that this isn't the first use case addressed by this capability, which is being delivered gradually (as we normally do in the JDK), and not even all the basic building blocks are out yet.
  • phi_node_48 3 hours ago
    [flagged]