Skip to content

Thread-safety enhancements, unit tests, and benchmarking #104

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

Merged
merged 15 commits into from
Aug 18, 2022

Conversation

Stephen-Bao
Copy link
Contributor

@Stephen-Bao Stephen-Bao commented Jul 19, 2022

Issue #, if available: #61

Description of changes: Added thread-safety enhancements, unit tests, and benchmarking code.
The benchmarking code measures the performance of the library under 3 diffrent internal synchronization situations:

  1. no internal sync for flush()
  2. using ReentrantReadWriteLock to make flush excute exclusively
  3. using Stamped to make flush excute exclusively

The main purposes of the benchmarking are:

  1. measure the extra overhead introduced by adding an extra lock on single-threaded users
  2. gather information to decide whether to provide a separate synced flush() while preserving the old one
  3. compare the performance of ReentrantReadWriteLock & StampedLock

Here are the benchmarking results:

  1. Single-threaded Use Cases

image

This proves that adding either lock would not cause an significant extra delay to single-threaded users.
  1. Single Method Performance in Async Context
    a. each thread publishes 1000 metrics

image

b. each thread flushes 100 times

image

These tests indicates that internal sync with a lock increases average ops time on single method, but overall ops time is still fast enough.
  1. Mixed Methods Performance in Async Context
    Each thread executing mixed metheds 100 times:

image

This illustrates the overall performance under different lock situations, especially the performance difference between the two locks.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Stephen-Bao Stephen-Bao requested a review from paggynie July 19, 2022 03:47
Copy link
Contributor

@paggynie paggynie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to set the syncronized list for new setDimension from your recent reset clear dimension change

@Stephen-Bao Stephen-Bao merged commit f5119f2 into awslabs:thread-safety Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants