Skip to content

Conversation

@Kumassy
Copy link
Owner

@Kumassy Kumassy commented Aug 17, 2025

ControlPacketV2Codec.decode consumed 16% of the total CPU time.

This patch use serde_bytes to improve bytes handling.

Benchmark results before applying this patch:

control_packet_encode_init
                        time:   [263.36 ns 267.60 ns 271.75 ns]
                        change: [-2.4515% +0.3082% +3.1307%] (p = 0.83 > 0.05)
                        No change in performance detected.
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) high mild
  2 (2.00%) high severe

control_packet_decode_init
                        time:   [149.76 ns 150.41 ns 151.22 ns]
                        change: [-1.7949% +0.3853% +2.2385%] (p = 0.74 > 0.05)
                        No change in performance detected.
Found 8 outliers among 100 measurements (8.00%)
  1 (1.00%) high mild
  7 (7.00%) high severe

control_packet_encode_data
                        time:   [4.4245 µs 4.4452 µs 4.4704 µs]
                        change: [-1.3477% -0.4227% +0.4060%] (p = 0.37 > 0.05)
                        No change in performance detected.
Found 9 outliers among 100 measurements (9.00%)
  4 (4.00%) high mild
  5 (5.00%) high severe

control_packet_decode_data
                        time:   [2.7874 µs 2.7985 µs 2.8137 µs]
                        change: [-1.1917% -0.4400% +0.1894%] (p = 0.23 > 0.05)
                        No change in performance detected.
Found 11 outliers among 100 measurements (11.00%)
  3 (3.00%) high mild
  8 (8.00%) high severe

This patch improve encode/decode performance up to 95%:


control_packet_encode_init
                        time:   [290.56 ns 301.68 ns 316.32 ns]
                        change: [+7.5892% +12.124% +17.295%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 10 outliers among 100 measurements (10.00%)
  3 (3.00%) high mild
  7 (7.00%) high severe

Benchmarking control_packet_decode_init: Collecting 100 samples i
control_packet_decode_init
                        time:   [149.62 ns 157.33 ns 170.57 ns]
                        change: [-1.2249% +3.8508% +11.721%] (p = 0.31 > 0.05)
                        No change in performance detected.
Found 13 outliers among 100 measurements (13.00%)
  6 (6.00%) high mild
  7 (7.00%) high severe

Benchmarking control_packet_encode_data: Collecting 100 samples in 
control_packet_encode_data
                        time:   [291.05 ns 306.31 ns 330.79 ns]
                        change: [-93.530% -93.285% -92.833%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
  2 (2.00%) low mild
  1 (1.00%) high mild
  9 (9.00%) high severe

Benchmarking control_packet_decode_data: Collecting 100 samples in estimat
control_packet_decode_data
                        time:   [147.19 ns 151.91 ns 158.46 ns]
                        change: [-94.586% -94.343% -94.000%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 14 outliers among 100 measurements (14.00%)
  5 (5.00%) high mild
  9 (9.00%) high severe

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