sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Check if entering synchronized block is necessary / double checked locking

Open adinauer opened this issue 3 years ago • 3 comments

Description

Some code uses synchronized blocks. We might gain a bit of performance by checking if we even need to acquire the lock.

  • [ ] LifecycleWatcher
  • [ ] SentryTracer
  • [ ] ...

adinauer avatar Aug 03 '22 07:08 adinauer

Did this come up from measuring something? If we're working on improving performance it's important to benchmark and find the areas that can be improved.

bruno-garcia avatar Aug 03 '22 12:08 bruno-garcia

Came up in a code review, linked above. Agree on benchmarking as not to focus on micro optimizations.

adinauer avatar Aug 03 '22 15:08 adinauer

oh, it's about adding a double check lock. If it's a heavy code path that will likely result in contention, where a double check lock can help, makes sense to add.

bruno-garcia avatar Aug 03 '22 15:08 bruno-garcia