The class MappingMetamodelImpl is extremely hot during load, as a frequent operation is to lookup EntityPersister based on entity name (a String). Same for collection’s persisters. This is currently implemented using a ConcurrentHashMap , but I suspect could be optimised further by taking advantage of the fact that we know all valid entity names after boot: normally CHM is optimised for some balance of read and write operations, but we effectively need an immutable data structure which is optimised for read operations: write operations can be expensive as we’d compute the optimal data structure just once. A simple idea could be to sort the strings, and then implement some form of binary search; this theory is untested though - we should experiment. |