Modifying JsonObject using ACursor/HCursor performance hit due to megamorphic calls
atnoya opened this issue · comments
When modifying/traversing json, we incur into megamorphic calls whenever we call contains
or add
in JsonObject
s.
Our usecase is very performance sensitive, so I would like to have the option to optimize such method calls and avoid performance penalty, by calling the method in the concrete subclass (LinkedHashMapJsonObject
or MapAndVectorJsonObject
). But the concrete classes definition is private
. Would it be acceptable to modify it to private[circe]
.
On another note, a similar performance penalty happens when calling ACursor methods, which also incurs in megamorphic calls quite often. However, the definitions of the concrete subclasses as package private, so I can write a few "optimized" methods to workaround it.
Apologies, further investigation cleared JsonObject from blame, the source of the megamorphic calls was not JsonObject but the underlying Map (Map1/2/3/4 and HashMap), we managed to ensure using HashMap at JsonObject creation time and the megamorphic calls were gone. While I think it would still be beneficial to allow some peeking into the underlying implementation used in some circumstances. I will close this issue as it's clearly incorrect. Again, apologies!