Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor:(loom) change synchronized methods on TypeInfoCache to use Lock #1958

Closed
wants to merge 1 commit into from

Conversation

rbygrave
Copy link
Contributor

Referencing #1951 for outline / motivation which is to improve compatibility with loom.

Change TypeInfoCache replacing the synchronized methods with use of ReentrantLock.

The diff for this PR is best viewed ignoring whitespace due to indentation change

Changes to Existing Features:

  • Does this break existing behaviour? If so please explain.
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

@bokken
Copy link
Member

bokken commented Nov 14, 2020

@vlsi, @davecramer the expectation is that each Connection has it's own unique TypeInfoCache instance, correct? So our synchronization concern is not /concurrent/ access to individual methods which mutate local state, but rather visibility of those mutations in a future "transaction" when the Connection is re-used on a different thread?
If that is the case, it seems better to change to ConcurrentHashMap and remove all explicit synchronization. That would not only simplify this class, it potentially improves performance. It would certainly seem to provide more /consistent/ performance irrespective of biased locking potentially being removed.
Even in the face of concurrent use (which we would not expect), the risk appears to be limited to repeated work to query from the database and populating values into the maps. There does not appear to be risk of inconsistent state causing issues for either concurrent user (which again, almost certainly has other problems).

@davecramer
Copy link
Member

@brettwooldridge I think there was some concern over people sharing connections. That said there is no guarantee that JDBC is threadsafe however some expect it to be. I like the idea of using a concurrent map though
+1

@jorsol jorsol added the jdk/loom Project Loom related change label Feb 14, 2021
@rbygrave
Copy link
Contributor Author

rbygrave commented Feb 1, 2023

Closing this PR - it was replaced by #2635

@rbygrave rbygrave closed this Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jdk/loom Project Loom related change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants