Currently the handling for -XX:CompileCommand is not efficient:
DirectiveSet::compilecommand_compatibility_init() clones the current instance of DirectiveSet, checks and modifies with existing options in CompilerOracle, then returns the new instance, or frees up the new instance and returns the current instance. This happens every time the JIT compiles a method. This cloning mechanism also partly caused the memory leak in JDK-8241556.
It should be possible to convert all CompileCommand options into equivalent DirectiveSet objects during startup, so it can avoid the cost of allocation, deallocation, and some comparison work at runtime.