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

Speed up write operations of Synchronizer #12

Merged
merged 5 commits into from
Jul 10, 2024
Merged

Conversation

bocharov
Copy link
Collaborator

@bocharov bocharov commented Jul 9, 2024

List of changes:

  • Added hasher template parameter H for Synchronizer with WyHash as default. This will speed up checksum calculation during writes.
  • Added read/write benchmarks from Synchronizer.
  • Optimize Synchronizer::write and write_raw methods to re-use opened maps.
  • Speed up writes further with re-usable buffer backed by AlignedVec.

Benchmarks:

synchronizer/write      time:   [250.71 ns 251.42 ns 252.41 ns]
                        thrpt:  [3.9619 Melem/s 3.9774 Melem/s 3.9887 Melem/s]
                 change:
                        time:   [-99.152% -99.147% -99.142%] (p = 0.00 < 0.05)
                        thrpt:  [+11559% +11627% +11699%]
                        Performance has improved.
synchronizer/write_raw  time:   [145.25 ns 145.53 ns 145.92 ns]
                        thrpt:  [6.8531 Melem/s 6.8717 Melem/s 6.8849 Melem/s]
                 change:
                        time:   [-98.508% -98.471% -98.443%] (p = 0.00 < 0.05)
                        thrpt:  [+6322.7% +6441.2% +6602.9%]
                        Performance has improved.
synchronizer/read/check_bytes_true
                        time:   [40.114 ns 40.139 ns 40.186 ns]
                        thrpt:  [24.884 Melem/s 24.914 Melem/s 24.929 Melem/s]
                 change:
                        time:   [-0.1031% -0.0200% +0.0753%] (p = 0.69 > 0.05)
                        thrpt:  [-0.0752% +0.0200% +0.1032%]
                        No change in performance detected.
synchronizer/read/check_bytes_false
                        time:   [26.658 ns 26.673 ns 26.696 ns]
                        thrpt:  [37.458 Melem/s 37.491 Melem/s 37.512 Melem/s]
                 change:
                        time:   [-0.9845% -0.9083% -0.7959%] (p = 0.00 < 0.05)
                        thrpt:  [+0.8023% +0.9167% +0.9943%]
                        Change within noise threshold.

…as default.

This will speed up checksum calculation during writes.
…ed maps.

Benchmarks:
```
synchronizer/write      time:   [17.183 µs 17.387 µs 17.647 µs]
                        thrpt:  [56.666 Kelem/s 57.515 Kelem/s 58.195 Kelem/s]
                 change:
                        time:   [-47.134% -45.506% -43.898%] (p = 0.00 < 0.05)
                        thrpt:  [+78.247% +83.508% +89.156%]
                        Performance has improved.
synchronizer/write_raw  time:   [147.12 ns 147.76 ns 148.57 ns]
                        thrpt:  [6.7310 Melem/s 6.7676 Melem/s 6.7970 Melem/s]
                 change:
                        time:   [-98.463% -98.442% -98.422%] (p = 0.00 < 0.05)
                        thrpt:  [+6236.1% +6320.0% +6405.5%]
                        Performance has improved.
synchronizer/read/check_bytes_true
                        time:   [41.194 ns 41.271 ns 41.369 ns]
                        thrpt:  [24.172 Melem/s 24.230 Melem/s 24.275 Melem/s]
                 change:
                        time:   [-0.3344% +0.8124% +1.6734%] (p = 0.12 > 0.05)
                        thrpt:  [-1.6458% -0.8058% +0.3355%]
                        No change in performance detected.
synchronizer/read/check_bytes_false
                        time:   [26.658 ns 26.668 ns 26.685 ns]
                        thrpt:  [37.475 Melem/s 37.498 Melem/s 37.513 Melem/s]
                 change:
                        time:   [-4.4520% -3.5968% -2.8378%] (p = 0.00 < 0.05)
                        thrpt:  [+2.9206% +3.7309% +4.6595%]
                        Performance has improved.
```
Also added template parameter `N` for scratch space size.

Benchmarks:
```
synchronizer/write      time:   [250.71 ns 251.42 ns 252.41 ns]
                        thrpt:  [3.9619 Melem/s 3.9774 Melem/s 3.9887 Melem/s]
                 change:
                        time:   [-99.152% -99.147% -99.142%] (p = 0.00 < 0.05)
                        thrpt:  [+11559% +11627% +11699%]
                        Performance has improved.
synchronizer/write_raw  time:   [145.25 ns 145.53 ns 145.92 ns]
                        thrpt:  [6.8531 Melem/s 6.8717 Melem/s 6.8849 Melem/s]
                 change:
                        time:   [-98.508% -98.471% -98.443%] (p = 0.00 < 0.05)
                        thrpt:  [+6322.7% +6441.2% +6602.9%]
                        Performance has improved.
synchronizer/read/check_bytes_true
                        time:   [40.114 ns 40.139 ns 40.186 ns]
                        thrpt:  [24.884 Melem/s 24.914 Melem/s 24.929 Melem/s]
                 change:
                        time:   [-0.1031% -0.0200% +0.0753%] (p = 0.69 > 0.05)
                        thrpt:  [-0.0752% +0.0200% +0.1032%]
                        No change in performance detected.
synchronizer/read/check_bytes_false
                        time:   [26.658 ns 26.673 ns 26.696 ns]
                        thrpt:  [37.458 Melem/s 37.491 Melem/s 37.512 Melem/s]
                 change:
                        time:   [-0.9845% -0.9083% -0.7959%] (p = 0.00 < 0.05)
                        thrpt:  [+0.8023% +0.9167% +0.9943%]
                        Change within noise threshold.
```
@bocharov bocharov merged commit d0afe4e into main Jul 10, 2024
7 checks passed
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.

2 participants