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

Use muxed inbox to handle jetstream publishes #1130

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

paolobarbolini
Copy link
Contributor

This makes Jetstream publishes re-use the muxed subscriber logic from #1069.

I'm not really happy with the implementation, but the current internal API is quite strict on what it allowed.

@caspervonb caspervonb self-requested a review October 6, 2023 17:05
Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

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

lgtm!

@caspervonb caspervonb requested a review from Jarema October 6, 2023 17:56
@Jarema
Copy link
Member

Jarema commented Oct 6, 2023

Will be green after #113 is merged.

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

LGTM!

@Jarema Jarema merged commit 4222b83 into nats-io:main Oct 7, 2023
10 checks passed
@paolobarbolini
Copy link
Contributor Author

I originally did this for the bandwidth savings but performance is also much better 🥳

nats::publish_throughput/32
                        time:   [124.94 ms 153.61 ms 182.71 ms]
                        thrpt:  [83.515 MiB/s 99.333 MiB/s 122.12 MiB/s]
                 change:
                        time:   [-14.089% +10.725% +42.338%] (p = 0.43 > 0.05)
                        thrpt:  [-29.744% -9.6862% +16.400%]
                        No change in performance detected.
nats::publish_throughput/1024
                        time:   [212.51 ms 217.28 ms 223.59 ms]
                        thrpt:  [2.1326 GiB/s 2.1946 GiB/s 2.2438 GiB/s]
                 change:
                        time:   [-10.231% -6.4495% -2.1940%] (p = 0.01 < 0.05)
                        thrpt:  [+2.2432% +6.8941% +11.397%]
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe
Benchmarking nats::publish_throughput/8192: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 13.3s.
nats::publish_throughput/8192
                        time:   [1.2944 s 1.3524 s 1.4149 s]
                        thrpt:  [2.6962 GiB/s 2.8208 GiB/s 2.9471 GiB/s]
                 change:
                        time:   [-7.8688% -1.4949% +5.8324%] (p = 0.69 > 0.05)
                        thrpt:  [-5.5110% +1.5176% +8.5409%]
                        No change in performance detected.

nats::publish_amount/32 time:   [132.80 ms 154.70 ms 175.16 ms]
                        thrpt:  [2.8545 Melem/s 3.2322 Melem/s 3.7650 Melem/s]
                 change:
                        time:   [-21.385% -7.7038% +9.2086%] (p = 0.39 > 0.05)
                        thrpt:  [-8.4321% +8.3468% +27.202%]
                        No change in performance detected.
nats::publish_amount/1024
                        time:   [210.38 ms 221.36 ms 232.66 ms]
                        thrpt:  [2.1490 Melem/s 2.2587 Melem/s 2.3766 Melem/s]
                 change:
                        time:   [-10.944% -5.5929% -0.2375%] (p = 0.07 > 0.05)
                        thrpt:  [+0.2380% +5.9243% +12.289%]
                        No change in performance detected.
Benchmarking nats::publish_amount/8192: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 13.9s.
nats::publish_amount/8192
                        time:   [1.2446 s 1.3317 s 1.4242 s]
                        thrpt:  [351.08 Kelem/s 375.47 Kelem/s 401.74 Kelem/s]
                 change:
                        time:   [-9.5909% -1.1196% +9.2297%] (p = 0.84 > 0.05)
                        thrpt:  [-8.4498% +1.1323% +10.608%]
                        No change in performance detected.

Benchmarking nats::subscribe_amount/32: Collecting 10 samples in estimated 6.3280 s (20 iterations)thread 'tokio-runtime-worker' panicked at async-nats/benches/core_nats.rs:104:38:
called `Result::unwrap()` on an `Err` value: PublishError(SendError { .. })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at async-nats/benches/core_nats.rs:104:38:
called `Result::unwrap()` on an `Err` value: PublishError(SendError { .. })
nats::subscribe_amount/32
                        time:   [284.20 ms 308.79 ms 331.05 ms]
                        thrpt:  [1.5103 Melem/s 1.6192 Melem/s 1.7593 Melem/s]
                 change:
                        time:   [-10.739% -0.2023% +12.246%] (p = 0.97 > 0.05)
                        thrpt:  [-10.910% +0.2028% +12.030%]
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  2 (20.00%) low mild
nats::subscribe_amount/1024
                        time:   [364.38 ms 386.24 ms 401.89 ms]
                        thrpt:  [1.2441 Melem/s 1.2945 Melem/s 1.3722 Melem/s]
                 change:
                        time:   [-7.3419% -0.2555% +7.4484%] (p = 0.95 > 0.05)
                        thrpt:  [-6.9321% +0.2562% +7.9237%]
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  1 (10.00%) low severe
  1 (10.00%) high mild
Benchmarking nats::subscribe_amount/8192: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 16.2s.
nats::subscribe_amount/8192
                        time:   [1.5902 s 1.6251 s 1.6564 s]
                        thrpt:  [301.86 Kelem/s 307.67 Kelem/s 314.44 Kelem/s]
                 change:
                        time:   [-1.9404% +0.3293% +2.6009%] (p = 0.80 > 0.05)
                        thrpt:  [-2.5349% -0.3282% +1.9788%]
                        No change in performance detected.
Found 3 outliers among 10 measurements (30.00%)
  1 (10.00%) low severe
  1 (10.00%) low mild
  1 (10.00%) high mild

Benchmarking nats::request_amount/32: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 8.4s.
nats::request_amount/32 time:   [800.36 ms 825.25 ms 847.28 ms]
                        thrpt:  [11.802 Kelem/s 12.117 Kelem/s 12.494 Kelem/s]
                 change:
                        time:   [-1.8710% +3.5543% +9.7295%] (p = 0.25 > 0.05)
                        thrpt:  [-8.8668% -3.4323% +1.9067%]
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  2 (20.00%) low mild
Benchmarking nats::request_amount/1024: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 7.8s.
nats::request_amount/1024
                        time:   [813.04 ms 834.67 ms 856.98 ms]
                        thrpt:  [11.669 Kelem/s 11.981 Kelem/s 12.300 Kelem/s]
                 change:
                        time:   [-0.8851% +4.3529% +10.272%] (p = 0.15 > 0.05)
                        thrpt:  [-9.3150% -4.1713% +0.8930%]
                        No change in performance detected.
Benchmarking nats::request_amount/8192: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 8.7s.
nats::request_amount/8192
                        time:   [846.85 ms 864.41 ms 879.86 ms]
                        thrpt:  [11.365 Kelem/s 11.569 Kelem/s 11.808 Kelem/s]
                 change:
                        time:   [-1.0695% +2.4685% +6.0769%] (p = 0.19 > 0.05)
                        thrpt:  [-5.7288% -2.4090% +1.0811%]
                        No change in performance detected.

Benchmarking jetstream::sync_publish_throughput/32: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 31.7s.
jetstream::sync_publish_throughput/32
                        time:   [3.2062 s 3.3077 s 3.4032 s]
                        thrpt:  [459.13 KiB/s 472.38 KiB/s 487.33 KiB/s]
                 change:
                        time:   [-16.994% -14.057% -11.247%] (p = 0.00 < 0.05)
                        thrpt:  [+12.672% +16.356% +20.473%]
                        Performance has improved.
Benchmarking jetstream::sync_publish_throughput/1024: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 32.7s.
jetstream::sync_publish_throughput/1024
                        time:   [3.5053 s 3.5860 s 3.6678 s]
                        thrpt:  [13.313 MiB/s 13.616 MiB/s 13.930 MiB/s]
                 change:
                        time:   [-15.132% -12.696% -10.206%] (p = 0.00 < 0.05)
                        thrpt:  [+11.366% +14.542% +17.830%]
                        Performance has improved.
Benchmarking jetstream::sync_publish_throughput/8192: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 43.9s.
jetstream::sync_publish_throughput/8192
                        time:   [4.4282 s 4.4879 s 4.5514 s]
                        thrpt:  [85.825 MiB/s 87.039 MiB/s 88.214 MiB/s]
                 change:
                        time:   [-11.200% -9.5154% -7.7415%] (p = 0.00 < 0.05)
                        thrpt:  [+8.3910% +10.516% +12.613%]
                        Performance has improved.

Benchmarking jetstream sync publish messages amount/32: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 33.3s.
jetstream sync publish messages amount/32
                        time:   [3.2541 s 3.3085 s 3.3649 s]
                        thrpt:  [14.859 Kelem/s 15.113 Kelem/s 15.365 Kelem/s]
                 change:
                        time:   [-18.122% -16.244% -14.135%] (p = 0.00 < 0.05)
                        thrpt:  [+16.463% +19.394% +22.132%]
                        Performance has improved.
Benchmarking jetstream sync publish messages amount/1024: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 34.9s.
Benchmarking jetstream sync publish messages amount/1024: Collecting 10 samples in estimated 34.902 s (10 iterations)
jetstream sync publish messages amount/1024
                        time:   [3.5083 s 3.5700 s 3.6310 s]
                        thrpt:  [13.770 Kelem/s 14.005 Kelem/s 14.252 Kelem/s]
                 change:
                        time:   [-14.553% -12.388% -10.289%] (p = 0.00 < 0.05)
                        thrpt:  [+11.469% +14.139% +17.031%]
                        Performance has improved.
Benchmarking jetstream sync publish messages amount/8192: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 46.5s.
jetstream sync publish messages amount/8192
                        time:   [4.5190 s 4.5571 s 4.6023 s]
                        thrpt:  [10.864 Kelem/s 10.972 Kelem/s 11.064 Kelem/s]
                 change:
                        time:   [-9.7281% -8.6007% -7.3482%] (p = 0.00 < 0.05)
                        thrpt:  [+7.9310% +9.4101% +10.776%]
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild

Benchmarking jetstream async publish throughput/32: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 5.0s or enable flat sampling.
jetstream async publish throughput/32
                        time:   [97.644 ms 106.41 ms 111.77 ms]
                        thrpt:  [13.652 MiB/s 14.340 MiB/s 15.627 MiB/s]
                 change:
                        time:   [-56.483% -46.290% -34.786%] (p = 0.00 < 0.05)
                        thrpt:  [+53.341% +86.186% +129.79%]
                        Performance has improved.
Found 2 outliers among 10 measurements (20.00%)
  2 (20.00%) low mild
jetstream async publish throughput/1024
                        time:   [87.582 ms 101.26 ms 112.64 ms]
                        thrpt:  [433.48 MiB/s 482.19 MiB/s 557.51 MiB/s]
                 change:
                        time:   [-65.035% -57.247% -47.426%] (p = 0.00 < 0.05)
                        thrpt:  [+90.209% +133.90% +186.00%]
                        Performance has improved.
jetstream async publish throughput/8192
                        time:   [204.94 ms 216.23 ms 226.77 ms]
                        thrpt:  [1.6822 GiB/s 1.7642 GiB/s 1.8614 GiB/s]
                 change:
                        time:   [-50.470% -42.777% -34.464%] (p = 0.00 < 0.05)
                        thrpt:  [+52.587% +74.754% +101.90%]
                        Performance has improved.

Benchmarking jetstream::async_publish_messages_amount/32: Warming up for 1.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 7.0s or enable flat sampling.
jetstream::async_publish_messages_amount/32
                        time:   [105.46 ms 115.15 ms 124.27 ms]
                        thrpt:  [402.35 Kelem/s 434.23 Kelem/s 474.11 Kelem/s]
                 change:
                        time:   [-44.690% -31.632% -13.207%] (p = 0.01 < 0.05)
                        thrpt:  [+15.217% +46.268% +80.799%]
                        Performance has improved.
jetstream::async_publish_messages_amount/1024
                        time:   [92.714 ms 99.937 ms 108.16 ms]
                        thrpt:  [462.27 Kelem/s 500.32 Kelem/s 539.29 Kelem/s]
                 change:
                        time:   [-62.840% -53.845% -40.741%] (p = 0.00 < 0.05)
                        thrpt:  [+68.749% +116.66% +169.11%]
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) low mild
jetstream::async_publish_messages_amount/8192
                        time:   [206.98 ms 220.08 ms 233.56 ms]
                        thrpt:  [214.08 Kelem/s 227.19 Kelem/s 241.57 Kelem/s]
                 change:
                        time:   [-35.535% -30.730% -25.077%] (p = 0.00 < 0.05)
                        thrpt:  [+33.471% +44.362% +55.122%]
                        Performance has improved.

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