On 28/04/2016 14:45, Peter Levart wrote:
Hi Alan,
I also have a little optimization for Module.extraPackages:
http://cr.openjdk.java.net/~plevart/jdk9-dev/Module.extraPackages/webrev.01/
This is only used from java.lang.reflect.Proxy presently, so what is
currently there is not performance critical, but if it gets used more,
then the provided patch gives smaller footprint and O(n) instead of
O(n^2) time to add n packages to a module + doesn't produce so much
garbage.
What do you think?
No objection to changing this from copy-on-write to a CHM. The original
implementation was to keep it simple and to special-case the one package
case. It hasn't been a performance issue so far but if we have a lot of
Proxy classes generated into the same module then it has potential.
Your patch reminds me that we should probably change
JVM_AddModulePackage to make it idempotent as dropping the
computeIfAbsent here would make this more readable.
I see you've changed to toArray in getPackages to use the size and
curious if that helps (just thinking of Aleksey essay on this topic [1]).
-Alan
[1] http://shipilev.net/blog/2016/arrays-wisdom-ancients/