ydb-platform / ydb-java-sdk

YDB Java SDK
https://ydb.tech
Apache License 2.0
37 stars 21 forks source link

Replacing synchronized blocks with ReentrantLocks in core part of SDK #341

Closed Myllyenko closed 3 days ago

Myllyenko commented 4 days ago

Continuation of https://github.com/ydb-platform/ydb-java-sdk/pull/338

codecov-commenter commented 4 days ago

Codecov Report

Attention: Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.

Project coverage is 47.21%. Comparing base (9a7adfa) to head (863193b).

Files with missing lines Patch % Lines
...src/main/java/tech/ydb/core/impl/YdbDiscovery.java 70.58% 4 Missing and 1 partial :warning:
...a/tech/ydb/core/impl/call/ReadWriteStreamCall.java 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #341 +/- ## ============================================ + Coverage 47.19% 47.21% +0.01% Complexity 1750 1750 ============================================ Files 311 311 Lines 12499 12499 Branches 1238 1238 ============================================ + Hits 5899 5901 +2 + Misses 6140 6138 -2 Partials 460 460 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

alex268 commented 4 days ago

I am not sure that we have to remove synchronized from call classes. They are just simple wrappers on GrpcCall and all their calls are not blocking. In this case, synchronized just adds thread safety to GrpcCall, especially with case data race on start() and cancel(). Replacing them by ReentrantLock makes them more complex and may reduce a performance

Myllyenko commented 3 days ago

I am not sure that we have to remove synchronized from call classes. They are just simple wrappers on GrpcCall and all their calls are not blocking. In this case, synchronized just adds thread safety to GrpcCall, especially with case data race on start() and cancel(). Replacing them by ReentrantLock makes them more complex and may reduce a performance

Reverted changes in StreamCalls.