Need help understanding LambdaDeserializer which does very costly loadClass

Hello Scala users,
I’m using Apache Spark and seeing a heavy thread contention problem due to the classLoader.loadClass. The code is here

For my use-case, the lookup class

lookup.lookupClass()

is always same class as

serialized.getImplClass

I’m wondering if we can check if it is necessary to call loadClass

    val loader = lookup.lookupClass().getClassLoader
    val className = slashDot(serialized.getImplClass)
    val implClass = if (lookup.lookupClass().getName() == className) { <--- check if those are same
      lookup.lookupClass()
    } else {
      loader.loadClass(className)
    }

obviously I know nothing about this class and its purpose, so if anybody has any idea / comment, it would be appreciated.

Thanks
-Kohki Nishio