GithubHelp home page GithubHelp logo

Comments (6)

cjjdespres avatar cjjdespres commented on May 28, 2024

Attn @mpirvu, @AlexeyKhrabrov.

from openj9.

AlexeyKhrabrov avatar AlexeyKhrabrov commented on May 28, 2024

Currently the AOT cache can generate class records for the [L class, which isn't really a class name at all - it's the romClass->className of an array class, which is incorrect. These classes can't be stored in the SCC - there happens to be a workaround for this issue in SVM, but otherwise if the old AOT cache implementation ever tried to rememberClass() a class with an array class in its chain somewhere it would simply fail to store the chain in the SCC and the AOT compilation would fail. Fixing this could be as easy as recording the correct class name in the ClassSerializationRecord (I haven't tried this) but we also speculated in one of our weekly meetings that a new ArrayClassSerializationRecord could also be created, which would record the arity of the array class and the element class name.

I already have a working implementation of handling object array classes. I needed it for caching profiling data at JITServer, but I don't remember this being an issue for AOT cache. Storing the full array class name in the ClassSerializationRecord and extracting the element class name and the arity from the full name during deserialization works fine, there is no need for a separate ArrayClassSerializationRecord. But the ROMClass hash stored in the class record must be a combination of the hashes for the L[ and array element ROMClasses, and the arity. I'll contribute the implementation eventually.

from openj9.

AlexeyKhrabrov avatar AlexeyKhrabrov commented on May 28, 2024

Lambda class names (which have $$Lambda$<index>/<address> at the end) are less normalized without an SCC present. With an SCC, the <address> part is just NULL, and I think the <index> is also calculated differently (but I'm less sure about that). Performing the same transformation with an SCC not present (even if it's just at the point where a ClassSerializationRecord is created) would improve matching, as currently the "Failed to find class in class loader" deserialization error comes up more frequently in the new implementation if the original ClassSerializationRecord was created for a client that did not have a local SCC present.

This is more complicated than that, and doesn't have much to do with the local SCC (except for the <address> part being NULL or not). As far as I understand, lambda classes currently cannot be looked up by name at all using any existing APIs, they are anonymous by design. Any AOT method (for both local SCC and AOT cache) that refers to any lambda classes in relocation/validation records cannot be loaded in the current implementation.

The <index> part can vary from run to run because it depends on the order in which lambdas classes are loaded, which is generally non-deterministic. So we have to keep track of all lambda classes defined by the same host class, and disambiguate them based on the ROMClass hash instead of the index, and exclude non-deterministic parts of class name strings when computing those hashes. The same applies to other types of classes defined at runtime such as proxy classes and generated reflection accessors. Anyway, I also have a working implementation that handles all that, I'll contribute it at some point.

By the way, the same issue applies to hidden classes because they are ignored in class lookup by name. But this is a much easier fix, we simply need to add a flag to jitGetClassInClassloaderFromUTF8() and propagate it down to wherever the check for a hidden class happens.

from openj9.

AlexeyKhrabrov avatar AlexeyKhrabrov commented on May 28, 2024

I think there is an assert in ClientSessionData::getClassRecord(ClientSessionData::ClassInfo &classInfo, bool &missingLoaderInfo) that's firing in the new implementation. It indicates that there is a class chain offset being cached without a corresponding loader name. It's not fatal, really. Just odd that it's happening. I still have to track down the cause.

Which assertion?

from openj9.

cjjdespres avatar cjjdespres commented on May 28, 2024

This assert:

         TR_ASSERT(TR_SharedCache::INVALID_CLASS_CHAIN_OFFSET != classInfo._classChainOffsetIdentifyingLoader,
                   "Valid class chain offset but missing class name identifying loader");

from openj9.

AlexeyKhrabrov avatar AlexeyKhrabrov commented on May 28, 2024

Class loader and class re-caching can still be implemented in the new deserializer, if we save the name of the class loader and the name and hash of the class when we cache the records initially.

This should be easier to do with the infrastructure I have for AOT prefetching where I store not-yet-valid records in the deserializer cache until corresponding classes get loaded. When a class gets unloaded, we can simply recreate and store its serialization record.

Another approach would be to invalidate known IDs for unloaded classes and loaders on the server side, which would be preferable in terms of client memory usage. But we would have to figure out how to synchronize things properly, maybe using the existing mechanism with critical compilation requests.

from openj9.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.