Performance impact of java.lang.System.getProperty()
ycrash.io, who produce a Java Root Cause Analyzer to help identify performance problems programmatically and quickly (not an endorsement, I have not used it), wrote a blog entry on the performance impact of java.lang.System.getProperty(), and showed why.
The short form is that getProperty()
uses a Hashtable.get()
at its heart, and as Hashtable.get()
is a synchronized call, this is a potential blocking call; hello, performance issue!
The problem with the post - which isn’t a bad post, really - is that this particular issue was gone by Java 11. The internal data structure for java.util.Properties
is a ConcurrentHashmap<Object, Object>
for Java 11, and getProperty()
uses that structure, not the Hashtable.get()
that it inherits from Hashtable
, so if you’re using a supported, valid JVM these days the problem that the blog points out is already gone.