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

Impl from_reader #352

Merged
merged 1 commit into from
Dec 14, 2023
Merged

Impl from_reader #352

merged 1 commit into from
Dec 14, 2023

Conversation

wcampbell0x2a
Copy link
Collaborator

@wcampbell0x2a wcampbell0x2a commented Aug 3, 2023

Builds upon #345 and #342. Truly fixing #44 and #344. And #252, #105. And somewhat #290.

Ok that's enough. This adds from_reader which can take in a Read! I also went ahead and implemented some long standing issues with this crates and actually make a Container that can properly specialize on aligned byte reads.

There's more when I have time to review, many TODOs are still standing. But the benchmarks look good!

benchmarks

I updated the benchmarks, so you can't just compare against master:

> critcmp before after
group                  after                                  before
-----                  -----                                  ------
deku_read_bits         1.24   845.8±14.29ns        ? ?/sec    1.00   679.5±11.83ns        ? ?/sec
deku_read_byte         1.00     17.8±0.25ns        ? ?/sec    2.12     37.8±3.35ns        ? ?/sec
deku_read_enum         1.00     15.3±0.15ns        ? ?/sec    2.04     31.2±0.81ns        ? ?/sec
deku_read_vec          1.00    676.8±7.04ns        ? ?/sec    2.16  1459.5±40.22ns        ? ?/sec
deku_read_vec_perf     1.00   640.6±34.63ns        ? ?/sec    2.54  1627.4±31.78ns        ? ?/sec
deku_write_bits        1.00    125.3±3.10ns        ? ?/sec    1.04   130.2±11.12ns        ? ?/sec
deku_write_byte        1.00    161.6±4.86ns        ? ?/sec    1.02    165.0±5.91ns        ? ?/sec
deku_write_enum        1.00    105.6±1.06ns        ? ?/sec    1.03    109.0±7.20ns        ? ?/sec
deku_write_vec         1.00      4.6±0.04µs        ? ?/sec    1.06      4.9±0.07µs        ? ?/sec
deku_write_vec_perf    1.00      4.6±0.08µs        ? ?/sec    1.06      4.9±0.06µs        ? ?/sec

todo

  • Add example of using new from_reader to read from file
  • Add MSRV
  • Using --engine = llvm on tarpulin might produce more accurate coverage results? Update: still inaccurate. /~https://github.com/taiki-e/cargo-llvm-cov seems to be more accurate. cargo +nightly llvm-cov --doctests --release --html --ignore-filename-regex attributes produces very good results.
  • Fix/Enhance "logging" feature
  • I think I need to keep around the old derives that gives read(..) for no_std enviroments
  • A ton of testing. I'll test out with my own crates and make sure this whole API works.
  • Conversation about things like #[deku(cond = "!deku::rest.is_empty()")] not working. not sure the solution on this since there is no way of knowing if Read is done except trying to read [u8; 1] and seeing it it errors and buffer the results
  • BufRead impl should really be encouraged for most big reads. Results may vary but a PERFORMANCE.md might be good.

Example usage

@github-actions
Copy link

github-actions bot commented Aug 3, 2023

Benchmark for 306a2aa

Click to view benchmark
Test Base PR %
deku_read_bits 747.7±1.03ns 1161.5±1.24ns +55.34%
deku_read_byte 22.4±0.18ns 19.1±0.01ns -14.73%
deku_read_enum 38.6±0.27ns 17.3±0.18ns -55.18%
deku_read_vec 1876.6±10.41ns 831.3±0.51ns -55.70%
deku_read_vec_perf 1864.3±15.69ns 745.6±0.21ns -60.01%
deku_write_bits 133.2±0.07ns 133.4±0.31ns +0.15%
deku_write_byte 74.7±0.46ns 196.4±0.86ns +162.92%
deku_write_enum 126.4±0.53ns 131.9±0.49ns +4.35%
deku_write_vec 5.5±0.00µs 5.7±0.00µs +3.64%
deku_write_vec_perf 5.7±0.00µs 5.7±0.01µs 0.00%

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Benchmark for 83b4dcf

Click to view benchmark
Test Base PR %
deku_read_bits 745.6±0.42ns 1040.8±0.96ns +39.59%
deku_read_byte 22.3±0.34ns 18.4±0.01ns -17.49%
deku_read_enum 38.9±0.30ns 18.5±0.51ns -52.44%
deku_read_vec 1886.9±8.65ns 802.2±6.44ns -57.49%
deku_read_vec_perf 1768.1±12.93ns 842.7±1.94ns -52.34%
deku_write_bits 133.5±0.51ns 129.4±0.59ns -3.07%
deku_write_byte 74.9±0.45ns 192.7±0.75ns +157.28%
deku_write_enum 125.9±0.65ns 129.6±0.53ns +2.94%
deku_write_vec 5.5±0.28µs 5.3±0.02µs -3.64%
deku_write_vec_perf 5.7±0.01µs 5.4±0.40µs -5.26%

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Benchmark for 4837616

Click to view benchmark
Test Base PR %
deku_read_bits 623.8±4.15ns 950.1±1.59ns +52.31%
deku_read_byte 18.8±0.21ns 18.2±0.08ns -3.19%
deku_read_enum 31.8±0.27ns 18.4±0.23ns -42.14%
deku_read_vec 1532.9±8.04ns 818.0±2.69ns -46.64%
deku_read_vec_perf 1551.9±15.14ns 698.3±3.49ns -55.00%
deku_write_bits 114.8±0.53ns 111.4±0.80ns -2.96%
deku_write_byte 63.2±0.22ns 159.4±0.56ns +152.22%
deku_write_enum 107.2±0.50ns 106.5±0.58ns -0.65%
deku_write_vec 4.9±0.01µs 4.7±0.01µs -4.08%
deku_write_vec_perf 5.1±0.01µs 4.7±0.01µs -7.84%

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Benchmark for 07b37ee

Click to view benchmark
Test Base PR %
deku_read_bits 934.9±39.67ns 1330.5±60.77ns +42.31%
deku_read_byte 23.8±1.42ns 25.0±1.14ns +5.04%
deku_read_enum 44.2±1.64ns 23.5±0.90ns -46.83%
deku_read_vec 1917.8±95.13ns 1042.8±35.56ns -45.63%
deku_read_vec_perf 2.0±0.07µs 904.6±41.05ns -54.77%
deku_write_bits 163.3±8.82ns 156.9±6.32ns -3.92%
deku_write_byte 97.4±6.08ns 252.9±9.22ns +159.65%
deku_write_enum 151.9±7.60ns 163.5±12.29ns +7.64%
deku_write_vec 6.6±0.53µs 6.4±0.27µs -3.03%
deku_write_vec_perf 7.1±0.55µs 6.1±0.33µs -14.08%

@sharksforarms
Copy link
Owner

Very excited about this!

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Benchmark for 6dd27b2

Click to view benchmark
Test Base PR %
deku_read_bits 740.1±0.28ns 1050.1±0.67ns +41.89%
deku_read_byte 22.6±0.17ns 16.4±0.01ns -27.43%
deku_read_enum 38.9±0.25ns 15.9±0.11ns -59.13%
deku_read_vec 1858.6±8.28ns 880.7±6.56ns -52.61%
deku_read_vec_perf 1809.1±32.36ns 886.3±6.23ns -51.01%
deku_write_bits 134.4±0.10ns 129.0±0.08ns -4.02%
deku_write_byte 74.2±0.38ns 181.3±0.54ns +144.34%
deku_write_enum 126.7±0.33ns 118.6±0.51ns -6.39%
deku_write_vec 5.7±0.00µs 5.2±0.00µs -8.77%
deku_write_vec_perf 5.8±0.01µs 5.3±0.01µs -8.62%

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Benchmark for 1854139

Click to view benchmark
Test Base PR %
deku_read_bits 749.4±0.45ns 1053.7±0.53ns +40.61%
deku_read_byte 22.1±0.22ns 16.7±0.02ns -24.43%
deku_read_enum 38.2±0.30ns 15.7±0.14ns -58.90%
deku_read_vec 1865.0±4.56ns 888.5±5.58ns -52.36%
deku_read_vec_perf 1794.9±15.52ns 886.5±5.90ns -50.61%
deku_write_bits 133.3±0.09ns 129.4±0.46ns -2.93%
deku_write_byte 76.1±0.44ns 183.9±0.72ns +141.66%
deku_write_enum 128.2±0.64ns 121.6±0.60ns -5.15%
deku_write_vec 5.6±0.01µs 5.1±0.01µs -8.93%
deku_write_vec_perf 5.7±0.01µs 5.2±0.01µs -8.77%

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Benchmark for 0b38ff1

Click to view benchmark
Test Base PR %
deku_read_bits 908.5±77.25ns 1297.6±69.06ns +42.83%
deku_read_byte 24.7±1.11ns 21.3±0.98ns -13.77%
deku_read_enum 41.1±1.46ns 21.7±1.60ns -47.20%
deku_read_vec 1941.3±81.60ns 1073.9±71.39ns -44.68%
deku_read_vec_perf 1950.8±69.10ns 778.8±30.45ns -60.08%
deku_write_bits 160.4±20.00ns 155.7±6.49ns -2.93%
deku_write_byte 90.6±4.86ns 221.8±8.98ns +144.81%
deku_write_enum 153.3±10.29ns 148.8±4.34ns -2.94%
deku_write_vec 6.5±0.26µs 6.3±0.50µs -3.08%
deku_write_vec_perf 6.6±0.23µs 6.1±0.17µs -7.58%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 7908460

Click to view benchmark
Test Base PR %
deku_read_bits 922.1±34.25ns 1321.5±54.43ns +43.31%
deku_read_byte 26.2±0.90ns 23.9±1.20ns -8.78%
deku_read_enum 43.3±2.43ns 23.5±1.85ns -45.73%
deku_read_vec 2.0±0.11µs 1064.8±55.62ns -46.76%
deku_read_vec_perf 2.1±0.08µs 821.1±26.53ns -60.90%
deku_write_bits 162.2±9.20ns 158.4±11.24ns -2.34%
deku_write_byte 95.4±4.12ns 244.9±14.52ns +156.71%
deku_write_enum 160.5±6.44ns 171.7±8.37ns +6.98%
deku_write_vec 6.8±0.35µs 6.5±0.33µs -4.41%
deku_write_vec_perf 7.2±0.32µs 6.4±0.26µs -11.11%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 025b256

Click to view benchmark
Test Base PR %
deku_read_bits 888.9±16.62ns 1188.4±59.76ns +33.69%
deku_read_byte 25.5±0.93ns 21.1±0.80ns -17.25%
deku_read_enum 44.3±1.33ns 21.5±0.42ns -51.47%
deku_read_vec 2.2±0.06µs 943.1±39.47ns -57.13%
deku_read_vec_perf 2.0±0.09µs 1061.0±28.79ns -46.95%
deku_write_bits 151.8±5.93ns 148.5±3.84ns -2.17%
deku_write_byte 88.8±2.69ns 210.3±5.33ns +136.82%
deku_write_enum 151.4±4.98ns 137.3±6.24ns -9.31%
deku_write_vec 6.5±0.14µs 6.1±0.21µs -6.15%
deku_write_vec_perf 6.3±0.26µs 6.2±0.23µs -1.59%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 7c1a466

Click to view benchmark
Test Base PR %
deku_read_bits 625.1±0.47ns 936.9±0.53ns +49.88%
deku_read_byte 19.5±0.20ns 18.9±0.06ns -3.08%
deku_read_enum 33.7±0.21ns 17.9±0.10ns -46.88%
deku_read_vec 1561.6±6.43ns 779.7±0.88ns -50.07%
deku_read_vec_perf 1572.8±11.87ns 626.1±7.02ns -60.19%
deku_write_bits 109.0±0.23ns 107.6±1.16ns -1.28%
deku_write_byte 63.6±0.30ns 158.8±1.11ns +149.69%
deku_write_enum 108.0±0.48ns 112.9±0.55ns +4.54%
deku_write_vec 5.0±0.02µs 4.8±0.02µs -4.00%
deku_write_vec_perf 5.2±0.01µs 4.7±0.03µs -9.62%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 8f4785f

Click to view benchmark
Test Base PR %
deku_read_bits 895.8±7.92ns 1251.3±20.20ns +39.69%
deku_read_byte 26.5±0.28ns 20.1±0.26ns -24.15%
deku_read_enum 45.5±0.96ns 22.0±0.20ns -51.65%
deku_read_vec 2.2±0.03µs 1009.8±11.16ns -54.10%
deku_read_vec_perf 2.2±0.03µs 1054.2±16.80ns -52.08%
deku_write_bits 156.6±2.18ns 151.6±2.13ns -3.19%
deku_write_byte 88.5±1.48ns 218.6±4.15ns +147.01%
deku_write_enum 150.3±2.08ns 150.4±1.20ns +0.07%
deku_write_vec 6.5±0.11µs 6.3±0.04µs -3.08%
deku_write_vec_perf 6.8±0.06µs 6.2±0.09µs -8.82%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for ebef2ca

Click to view benchmark
Test Base PR %
deku_read_bits 801.7±42.83ns 1303.9±64.90ns +62.64%
deku_read_byte 24.1±1.21ns 18.9±0.86ns -21.58%
deku_read_enum 41.7±1.89ns 20.9±1.07ns -49.88%
deku_read_vec 2.0±0.09µs 908.2±47.91ns -54.59%
deku_read_vec_perf 1999.1±95.38ns 967.7±43.25ns -51.59%
deku_write_bits 143.3±6.35ns 171.1±8.65ns +19.40%
deku_write_byte 81.3±3.68ns 242.1±11.71ns +197.79%
deku_write_enum 136.9±6.48ns 175.3±9.28ns +28.05%
deku_write_vec 5.9±0.28µs 5.7±0.27µs -3.39%
deku_write_vec_perf 6.1±0.29µs 5.8±0.26µs -4.92%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for b35b053

Click to view benchmark
Test Base PR %
deku_read_bits 756.2±0.45ns 1051.5±0.57ns +39.05%
deku_read_byte 22.3±0.18ns 17.1±0.01ns -23.32%
deku_read_enum 38.6±0.26ns 18.4±0.07ns -52.33%
deku_read_vec 1868.2±4.80ns 846.6±0.96ns -54.68%
deku_read_vec_perf 1854.1±15.57ns 884.4±4.96ns -52.30%
deku_write_bits 133.2±0.07ns 128.4±0.66ns -3.60%
deku_write_byte 75.3±0.47ns 185.5±0.31ns +146.35%
deku_write_enum 127.8±0.57ns 126.1±0.38ns -1.33%
deku_write_vec 5.6±0.00µs 5.3±0.00µs -5.36%
deku_write_vec_perf 5.8±0.01µs 5.3±0.01µs -8.62%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 3dafcce

Click to view benchmark
Test Base PR %
deku_read_bits 898.6±4.90ns 1250.7±12.22ns +39.18%
deku_read_byte 26.2±0.52ns 20.1±0.46ns -23.28%
deku_read_enum 46.5±0.52ns 21.6±0.62ns -53.55%
deku_read_vec 2.2±0.01µs 1002.3±14.15ns -54.44%
deku_read_vec_perf 2.2±0.02µs 1059.7±10.47ns -51.83%
deku_write_bits 159.7±0.67ns 153.0±1.89ns -4.20%
deku_write_byte 89.7±0.95ns 221.4±2.28ns +146.82%
deku_write_enum 152.8±1.16ns 149.2±2.01ns -2.36%
deku_write_vec 6.6±0.03µs 6.3±0.05µs -4.55%
deku_write_vec_perf 6.8±0.04µs 6.3±0.09µs -7.35%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 76c7503

Click to view benchmark
Test Base PR %
deku_read_bits 616.7±0.71ns 927.2±2.06ns +50.35%
deku_read_byte 19.4±0.09ns 16.1±0.02ns -17.01%
deku_read_enum 34.9±0.41ns 17.9±0.21ns -48.71%
deku_read_vec 1567.0±9.27ns 821.2±4.39ns -47.59%
deku_read_vec_perf 1571.0±6.69ns 644.3±4.81ns -58.99%
deku_write_bits 109.1±0.17ns 109.6±0.31ns +0.46%
deku_write_byte 65.2±2.74ns 157.6±0.62ns +141.72%
deku_write_enum 108.0±0.97ns 104.6±0.36ns -3.15%
deku_write_vec 5.0±0.03µs 4.7±0.01µs -6.00%
deku_write_vec_perf 5.2±0.02µs 4.6±0.01µs -11.54%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 0682ede

Click to view benchmark
Test Base PR %
deku_read_bits 895.4±10.55ns 1139.9±39.24ns +27.31%
deku_read_byte 26.4±0.44ns 1.6±0.04ns -93.94%
deku_read_enum 45.1±1.06ns 13.2±0.30ns -70.73%
deku_read_vec 2.2±0.03µs 609.3±18.26ns -72.30%
deku_read_vec_perf 2.1±0.08µs 706.6±10.73ns -66.35%
deku_write_bits 157.3±4.18ns 144.8±4.85ns -7.95%
deku_write_byte 88.1±2.62ns 202.7±3.22ns +130.08%
deku_write_enum 151.5±2.22ns 131.5±3.68ns -13.20%
deku_write_vec 6.6±0.07µs 6.2±0.12µs -6.06%
deku_write_vec_perf 6.8±0.04µs 6.1±0.09µs -10.29%

@github-actions
Copy link

github-actions bot commented Aug 6, 2023

Benchmark for 5ece58f

Click to view benchmark
Test Base PR %
deku_read_bits 751.9±5.12ns 1129.3±0.64ns +50.19%
deku_read_byte 22.3±0.21ns 1.3±0.03ns -94.17%
deku_read_enum 38.7±0.22ns 11.4±0.01ns -70.54%
deku_read_vec 1866.8±4.08ns 539.2±2.21ns -71.12%
deku_read_vec_perf 1837.4±15.43ns 603.3±0.93ns -67.17%
deku_write_bits 133.2±0.08ns 126.8±0.08ns -4.80%
deku_write_byte 75.3±0.53ns 172.6±0.86ns +129.22%
deku_write_enum 127.5±0.78ns 117.9±0.58ns -7.53%
deku_write_vec 5.5±0.01µs 5.3±0.00µs -3.64%
deku_write_vec_perf 5.7±0.02µs 5.2±0.01µs -8.77%

@wcampbell0x2a wcampbell0x2a force-pushed the impl-reader branch 3 times, most recently from 7254fb9 to 218bdca Compare August 9, 2023 00:08
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Benchmark for 556bc8a

Click to view benchmark
Test Base PR %
deku_read_bits 853.7±32.88ns 1250.9±97.10ns +46.53%
deku_read_byte 24.7±1.34ns 2.0±0.10ns -91.90%
deku_read_enum 39.8±1.74ns 13.9±0.60ns -65.08%
deku_read_vec 2.0±0.19µs 644.8±61.87ns -67.76%
deku_read_vec_perf 2.2±0.24µs 724.4±28.38ns -67.07%
deku_write_bits 152.6±4.84ns 149.7±8.79ns -1.90%
deku_write_byte 90.7±5.02ns 217.6±6.79ns +139.91%
deku_write_enum 154.4±7.85ns 150.6±6.74ns -2.46%
deku_write_vec 6.7±0.41µs 6.5±0.21µs -2.99%
deku_write_vec_perf 7.0±0.70µs 6.3±0.31µs -10.00%

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Benchmark for 2fcd848

Click to view benchmark
Test Base PR %
deku_read_bits 858.8±101.99ns 1235.9±65.78ns +43.91%
deku_read_byte 23.4±1.04ns 1.9±0.10ns -91.88%
deku_read_enum 38.6±1.79ns 13.1±0.53ns -66.06%
deku_read_vec 1932.8±59.11ns 606.0±40.48ns -68.65%
deku_read_vec_perf 1959.6±54.66ns 677.5±28.48ns -65.43%
deku_write_bits 164.8±10.20ns 149.8±9.29ns -9.10%
deku_write_byte 87.5±7.11ns 201.4±11.34ns +130.17%
deku_write_enum 146.6±7.10ns 140.8±8.45ns -3.96%
deku_write_vec 6.4±0.19µs 6.3±0.19µs -1.56%
deku_write_vec_perf 6.7±0.16µs 6.1±0.22µs -8.96%

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Benchmark for 941c52d

Click to view benchmark
Test Base PR %
deku_read_bits 904.5±1.54ns 1211.0±1.39ns +33.89%
deku_read_byte 26.4±0.16ns 1.6±0.00ns -93.94%
deku_read_enum 45.9±0.24ns 24.9±0.02ns -45.75%
deku_read_vec 2.3±0.01µs 645.8±1.52ns -71.92%
deku_read_vec_perf 2.2±0.01µs 688.4±0.69ns -68.71%
deku_write_bits 161.0±0.29ns 152.6±0.15ns -5.22%
deku_write_byte 91.8±0.42ns 206.9±0.74ns +125.38%
deku_write_enum 154.4±3.23ns 141.0±0.67ns -8.68%
deku_write_vec 6.7±0.02µs 6.3±0.01µs -5.97%
deku_write_vec_perf 6.9±0.16µs 6.2±0.01µs -10.14%

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Benchmark for 15dc49e

Click to view benchmark
Test Base PR %
deku_read_bits 750.7±0.93ns 1016.5±0.56ns +35.41%
deku_read_byte 22.0±0.41ns 1.3±0.01ns -94.09%
deku_read_enum 38.1±0.21ns 11.5±0.01ns -69.82%
deku_read_vec 1866.1±2.30ns 539.4±1.27ns -71.09%
deku_read_vec_perf 1806.9±21.07ns 593.1±0.54ns -67.18%
deku_write_bits 133.4±0.19ns 126.9±0.05ns -4.87%
deku_write_byte 76.1±0.40ns 173.8±0.84ns +128.38%
deku_write_enum 127.5±0.48ns 118.0±0.68ns -7.45%
deku_write_vec 5.6±0.01µs 5.2±0.02µs -7.14%
deku_write_vec_perf 5.7±0.01µs 5.1±0.01µs -10.53%

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Benchmark for 42a62d8

Click to view benchmark
Test Base PR %
deku_read_bits 620.8±4.32ns 881.6±1.26ns +42.01%
deku_read_byte 19.1±0.12ns 1.2±0.01ns -93.72%
deku_read_enum 34.9±0.13ns 9.3±0.01ns -73.35%
deku_read_vec 1681.2±5.38ns 500.7±2.14ns -70.22%
deku_read_vec_perf 1584.4±13.95ns 583.3±6.23ns -63.18%
deku_write_bits 108.9±0.15ns 105.9±0.75ns -2.75%
deku_write_byte 64.0±0.30ns 155.8±0.47ns +143.44%
deku_write_enum 108.3±0.42ns 103.5±0.41ns -4.43%
deku_write_vec 5.0±0.02µs 4.7±0.01µs -6.00%
deku_write_vec_perf 5.2±0.01µs 4.6±0.01µs -11.54%

@github-actions
Copy link

github-actions bot commented Aug 9, 2023

Benchmark for a344877

Click to view benchmark
Test Base PR %
deku_read_bits 751.6±6.52ns 1057.2±0.54ns +40.66%
deku_read_byte 22.0±0.16ns 1.3±0.01ns -94.09%
deku_read_enum 38.0±0.22ns 11.5±0.01ns -69.74%
deku_read_vec 1867.3±3.48ns 547.4±1.40ns -70.68%
deku_read_vec_perf 1818.7±27.14ns 608.5±0.69ns -66.54%
deku_write_bits 133.3±0.09ns 126.6±0.16ns -5.03%
deku_write_byte 76.7±2.17ns 174.3±0.67ns +127.25%
deku_write_enum 127.7±0.63ns 118.2±0.65ns -7.44%
deku_write_vec 5.6±0.01µs 5.3±0.02µs -5.36%
deku_write_vec_perf 5.7±0.01µs 5.2±0.02µs -8.77%

@github-actions
Copy link

Benchmark for ac19ec7

Click to view benchmark
Test Base PR %
deku_read_bits 900.3±0.72ns 1082.3±5.18ns +20.22%
deku_read_byte 26.8±0.18ns 31.4±0.22ns +17.16%
deku_read_enum 45.9±0.33ns 13.5±0.05ns -70.59%
deku_read_vec 2.2±0.01µs 83.3±0.16ns -96.21%
deku_read_vec_perf 2.2±0.01µs N/A N/A
deku_write_bits 161.0±0.23ns 153.8±2.16ns -4.47%
deku_write_byte 91.5±0.27ns 222.1±0.59ns +142.73%
deku_write_enum 156.4±0.69ns 147.4±2.09ns -5.75%
deku_write_vec 6.9±0.04µs 5.6±0.01µs -18.84%
deku_write_vec_perf 7.2±0.19µs N/A N/A

@wcampbell0x2a
Copy link
Collaborator Author

@sharksforarms I misspoke previously and said that from_bytes(..) wasn't possible anymore. It can be added back with the same signature 🎊 which should ease API adoption.

I added it with this commit: 9c75e27.

I'll add it back into the API docs and update the CHANGELOG. (and test it more)

The documentation here relies more on your own opinions. Should I replace all the docs that I replaced back with from_bytes, or should I keep then from_reader?

I think in src/lib.rs I'll reset the first example back to from_bytes and add a overview of from_bytes and from_reader.

@sharksforarms
Copy link
Owner

The documentation here relies more on your own opinions. Should I replace all the docs that I replaced back with from_bytes, or should I keep then from_reader?

I think in src/lib.rs I'll reset the first example back to from_bytes and add a overview of from_bytes and from_reader.

Yeah I think having an example for both makes sense!

@github-actions
Copy link

Benchmark for aae5406

Click to view benchmark
Test Base PR %
deku_read_bits 746.1±35.71ns 941.5±57.47ns +26.19%
deku_read_byte 21.0±1.45ns 23.7±1.76ns +12.86%
deku_read_enum 44.3±2.31ns 12.3±1.44ns -72.23%
deku_read_vec 2.1±0.07µs 68.5±2.83ns -96.74%
deku_read_vec_perf 2.1±0.06µs N/A N/A
deku_write_bits 130.5±18.13ns 134.8±8.10ns +3.30%
deku_write_byte 73.1±5.44ns 187.3±14.12ns +156.22%
deku_write_enum 151.6±8.19ns 130.0±8.10ns -14.25%
deku_write_vec 6.7±0.39µs 4.2±0.30µs -37.31%
deku_write_vec_perf 6.8±0.26µs N/A N/A

sharksforarms
sharksforarms previously approved these changes Oct 12, 2023
Copy link
Owner

@sharksforarms sharksforarms left a comment

Choose a reason for hiding this comment

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

Thanks @wcampbell0x2a ! Sorry for the delayed review, I don't have too much time for open source these days. Feel free to merge and @ me for more reviews!

@github-actions
Copy link

Benchmark for af456ae

Click to view benchmark
Test Base PR %
deku_read_bits 725.6±0.41ns 877.2±1.73ns +20.89%
deku_read_byte 23.1±0.23ns 26.1±0.21ns +12.99%
deku_read_enum 38.3±0.26ns 11.5±0.15ns -69.97%
deku_read_vec 1789.4±7.61ns 67.2±0.39ns -96.24%
deku_read_vec_perf 1821.8±9.33ns N/A N/A
deku_write_bits 133.3±0.11ns 127.3±0.26ns -4.50%
deku_write_byte 76.2±0.34ns 174.0±0.37ns +128.35%
deku_write_enum 128.2±0.39ns 116.3±1.45ns -9.28%
deku_write_vec 5.5±0.01µs 4.3±0.01µs -21.82%
deku_write_vec_perf 5.8±0.01µs N/A N/A

@wcampbell0x2a
Copy link
Collaborator Author

Thanks @wcampbell0x2a ! Sorry for the delayed review, I don't have too much time for open source these days. Feel free to merge and @ me for more reviews!

@sharksforarms make some last changes, should be ready to merge

sharksforarms
sharksforarms previously approved these changes Nov 16, 2023
Copy link
Owner

@sharksforarms sharksforarms left a comment

Choose a reason for hiding this comment

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

Thanks for all your efforts here! Feel free to merge.

sharksforarms
sharksforarms previously approved these changes Nov 16, 2023
Copy link
Owner

@sharksforarms sharksforarms left a comment

Choose a reason for hiding this comment

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

Rebased to fix merge conflict

@wcampbell0x2a
Copy link
Collaborator Author

Rebased to fix merge conflict

Sweet. I'll squash and make a nice commit msg then merge.

@wcampbell0x2a wcampbell0x2a added this to the 0.17.0 milestone Nov 17, 2023
Add from_reader and use Read internally to improve the codegen of deku,
the performance of derived parsers. Internally, this is implemented
using the new src/reader.rs interface in deku parses. This has a waterfall
effect on DekuReader implementations and the deku-derive/deku_read Derived impl.
Previous usage with from_bytes and other API's are unchanged.
There is somewhat of a performance hit for bit-only parses,
but I find the major improvments in the bytes-wise parsing to be great enough
to warrent this change.

The following are some sample benchmarks:
> critcmp before after
group                  after                                  before
-----                  -----                                  ------
deku_read_bits         1.24   845.8±14.29ns        ? ?/sec    1.00   679.5±11.83ns        ? ?/sec
deku_read_byte         1.00     17.8±0.25ns        ? ?/sec    2.12     37.8±3.35ns        ? ?/sec
deku_read_enum         1.00     15.3±0.15ns        ? ?/sec    2.04     31.2±0.81ns        ? ?/sec
deku_read_vec          1.00    676.8±7.04ns        ? ?/sec    2.16  1459.5±40.22ns        ? ?/sec
deku_write_bits        1.00    125.3±3.10ns        ? ?/sec    1.04   130.2±11.12ns        ? ?/sec
deku_write_byte        1.00    161.6±4.86ns        ? ?/sec    1.02    165.0±5.91ns        ? ?/sec
deku_write_enum        1.00    105.6±1.06ns        ? ?/sec    1.03    109.0±7.20ns        ? ?/sec
deku_write_vec         1.00      4.6±0.04µs        ? ?/sec    1.06      4.9±0.07µs        ? ?/sec

The above change removes DekuRead, and replaces it with DekuReader. This contains
the from_reader_with_ctx. DekuContainerRead contains from_reader.

The crate no_std_io was picked to supply a Read impl
for the no_std feature. These are "re-export"ed.

Add "`Read` enabled" docs to lib.rs

Add tests/test_tuple.rs tests

Update CHANGELOG.md to reflect changes and help migration to this usage

Use llvm-cov in ci for the generation of more accurate coverage reports

Update benchmarks to test more complex parser speeds

Disable Miri CI

Update ensure_no_std to work with new Read usage. Remove wee-alloc in favour
of an updated crate for the allocator.

Add inline to small functions
@wcampbell0x2a
Copy link
Collaborator Author

@sharksforarms can only merge with 1 approving review

Copy link
Owner

@sharksforarms sharksforarms left a comment

Choose a reason for hiding this comment

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

Thanks feel free to merge! I propose we do squash-merge via github in the future, makes it easier to review as a rebase+force-push could introduce some unreviewed code, I'll change the project setting

@wcampbell0x2a wcampbell0x2a merged commit 7176d1b into master Dec 14, 2023
18 of 19 checks passed
@wcampbell0x2a wcampbell0x2a deleted the impl-reader branch December 14, 2023 01:53
@TaeHagen TaeHagen mentioned this pull request May 13, 2024
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