LuciferYang commented on PR #37999: URL: https://github.com/apache/spark/pull/37999#issuecomment-1259031253
@srowen From the above test results, there is no significant performance difference between using global and local singletons. From a code perspective, thread safety should not be guaranteed by locks, it seems guaranteed by using a new `JsonParser/JsonGenerator` every serialization and deserialization. https://github.com/FasterXML/jackson-databind/blob/492334da383b0677c19b08964fddad18230546af/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java#L3838-L3851 <img width="949" alt="image" src="https://user-images.githubusercontent.com/1475305/192445439-80fc6740-767f-4848-b444-f6c22a40d1cc.png"> https://github.com/FasterXML/jackson-databind/blob/492334da383b0677c19b08964fddad18230546af/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java#L3647-L3658 <img width="885" alt="image" src="https://user-images.githubusercontent.com/1475305/192445680-6c2065ff-7cf4-4d60-8c01-df219eb629ab.png"> So there seems to be no problem with the global instance. `ObjectMapper` is only used as a configuration template, so I am both ok to use a global singleton or local singleton -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
