Paul Bjorkstrand created SLING-10969:
----------------------------------------

             Summary: Remove synchronized & rest of accessible flag during 
injection
                 Key: SLING-10969
                 URL: https://issues.apache.org/jira/browse/SLING-10969
             Project: Sling
          Issue Type: Improvement
          Components: Sling Models
    Affects Versions: Models Implementation 1.4.16
            Reporter: Paul Bjorkstrand


To improve multithreaded performance of Sling Models, the {{synchronized}} 
blocks, along with the "reset" of the {{setAccessible}} using its original 
value should be removed.

Context:
The synchronized blocks were added to resolve a race condition [1]. After 
looking into another large project that uses reflection to access members of 
classes (Felix [2]), nowhere in that project is something similar being done. 
Every reflective access is just doing {{setAccessible(true)}}.

Results from a JMH test allude to a significant performance improvement during 
multithreaded threaded access by removing the synchronized (JMH results [3]).

[1]: SLING-6584
[2]: https://github.com/apache/felix-dev/search?q=setAccessible
[3]: https://gist.github.com/paul-bjorkstrand/f3bb154665e7d2168b4656eb7b794496
[4]: https://www.mail-archive.com/[email protected]/msg113123.html
[5]: https://github.com/apache/sling-org-apache-sling-models-impl/pull/11



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to