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

perf: improve apply update performance #34

Merged
merged 12 commits into from
Nov 17, 2023

Conversation

darkskygit
Copy link
Collaborator

@darkskygit darkskygit commented Nov 15, 2023

this PR partially solves #33 and greatly improves the performance of apply update
test cases show a performance improvement of about 40-50%

before after
image image

test case in #33 :
image

image

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (fa29ec1) 77.75% compared to head (048b041) 79.69%.

❗ Current head 048b041 differs from pull request most recent head ed190fd. Consider uploading reports for the commit ed190fd to get more accurate results

Files Patch % Lines
y-octo/src/doc/common/range.rs 94.59% 2 Missing ⚠️
y-octo-node/src/utils.rs 0.00% 1 Missing ⚠️
y-octo/src/doc/common/state.rs 50.00% 1 Missing ⚠️
y-octo/src/doc/document.rs 50.00% 1 Missing ⚠️
y-octo/src/doc/hasher.rs 92.85% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #34      +/-   ##
==========================================
+ Coverage   77.75%   79.69%   +1.94%     
==========================================
  Files          49       49              
  Lines        7646     7422     -224     
==========================================
- Hits         5945     5915      -30     
+ Misses       1701     1507     -194     
Flag Coverage Δ
node-binding-test ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Benchmark for Linux

Click to view benchmark
Test Base PR %
codec/jwst decode var_int (32 bit) 629.9±0.58µs 537.9±9.23µs -14.61%
codec/jwst decode var_uint (32 bit) 429.7±2.50µs 492.4±8.33µs +14.59%
codec/jwst decode var_uint (64 bit) 513.9±1.17µs 544.9±9.06µs +6.03%
codec/jwst encode var_int (32 bit) 654.9±4.65µs 602.9±11.20µs -7.94%
codec/jwst encode var_uint (32 bit) 383.4±3.15µs 341.8±6.61µs -10.85%
codec/jwst encode var_uint (64 bit) 388.8±4.95µs 341.9±5.19µs -12.06%
codec/lib0 decode var_int (64 bit) 335.2±1.09µs 328.5±5.76µs -2.00%
codec/lib0 decode var_uint (32 bit) 289.4±2.55µs 408.6±7.17µs +41.19%
codec/lib0 decode var_uint (64 bit) 289.2±0.31µs 422.6±6.72µs +46.13%
codec/lib0 encode var_int (64 bit) 525.8±7.33µs 511.3±9.41µs -2.76%
codec/lib0 encode var_uint (32 bit) 483.1±4.23µs 423.2±9.48µs -12.40%
codec/lib0 encode var_uint (64 bit) 486.1±3.61µs 471.3±8.16µs -3.04%
ops/array/jwst/insert 283.7±5.48µs 294.8±6.00µs +3.91%
ops/array/jwst/insert range 401.6±9.89µs 433.8±6.51µs +8.02%
ops/array/jwst/remove 181.9±3.89µs 184.2±2.65µs +1.26%
ops/array/yrs/insert 95.7±2.06µs 93.6±2.46µs -2.19%
ops/array/yrs/insert range 131.0±2.23µs 128.2±2.38µs -2.14%
ops/array/yrs/remove 119.4±1.44µs 119.5±2.06µs +0.08%
ops/map/jwst/get 536.2±6.51ns 410.8±8.06ns -23.39%
ops/map/jwst/insert 6.7±0.07µs 5.0±0.07µs -25.37%
ops/map/jwst/remove 8.5±0.10µs 8.2±0.09µs -3.53%
ops/map/yrs/get 386.6±5.23ns 365.7±6.06ns -5.41%
ops/map/yrs/insert 5.9±0.05µs 6.0±0.06µs +1.69%
ops/map/yrs/remove 7.6±0.10µs 7.8±0.08µs +2.63%
ops/text/jwst/insert 154.4±1.23µs 146.3±1.79µs -5.25%
ops/text/jwst/remove 3.8±0.03µs 2.9±0.01µs -23.68%
ops/text/yrs/insert 44.2±0.22µs 45.8±0.23µs +3.62%
ops/text/yrs/remove 2.9±0.01µs 2.8±0.02µs -3.45%
update/parse with jwst/basic.bin 69.9±0.49µs 73.1±0.05µs +4.58%
update/parse with jwst/database.bin 56.4±0.33µs 59.7±0.07µs +5.85%
update/parse with jwst/large.bin 5.2±0.08ms 3.1±0.01ms -40.38%
update/parse with jwst/with-subdoc.bin 9.6±0.06µs 9.7±0.01µs +1.04%
update/parse with yrs/basic.bin 54.6±0.81µs 55.3±0.20µs +1.28%
update/parse with yrs/database.bin 43.7±0.60µs 43.6±0.08µs -0.23%
update/parse with yrs/large.bin 3.9±0.05ms 4.0±0.03ms +2.56%
update/parse with yrs/with-subdoc.bin 6.6±0.10µs 7.0±0.01µs +6.06%

Benchmark for Windows

Click to view benchmark
Test Base PR %
codec/jwst decode var_int (32 bit) 471.4±7.49µs 468.6±6.12µs -0.59%
codec/jwst decode var_uint (32 bit) 390.5±5.91µs 394.8±4.69µs +1.10%
codec/jwst decode var_uint (64 bit) 324.5±4.72µs 483.7±5.87µs +49.06%
codec/jwst encode var_int (32 bit) 479.3±9.37µs 436.0±7.80µs -9.03%
codec/jwst encode var_uint (32 bit) 394.8±5.97µs 339.5±5.18µs -14.01%
codec/jwst encode var_uint (64 bit) 387.3±4.60µs 332.3±5.85µs -14.20%
codec/lib0 decode var_int (64 bit) 291.9±7.44µs 429.8±4.93µs +47.24%
codec/lib0 decode var_uint (32 bit) 242.4±2.81µs 242.3±2.65µs -0.04%
codec/lib0 decode var_uint (64 bit) 242.5±2.56µs 242.9±3.70µs +0.16%
codec/lib0 encode var_int (64 bit) 582.3±8.53µs 584.4±11.33µs +0.36%
codec/lib0 encode var_uint (32 bit) 399.9±12.15µs 398.5±5.19µs -0.35%
codec/lib0 encode var_uint (64 bit) 384.6±4.39µs 386.6±6.92µs +0.52%
ops/array/jwst/insert 285.3±3.38µs 284.6±5.44µs -0.25%
ops/array/jwst/insert range 394.6±4.28µs 398.8±3.59µs +1.06%
ops/array/jwst/remove 168.2±1.88µs 168.1±1.58µs -0.06%
ops/array/yrs/insert 108.5±1.07µs 109.9±0.99µs +1.29%
ops/array/yrs/insert range 148.3±1.40µs 150.4±1.24µs +1.42%
ops/array/yrs/remove 155.8±1.66µs 155.9±1.17µs +0.06%
ops/map/jwst/get 499.5±7.08ns 388.2±3.82ns -22.28%
ops/map/jwst/insert 7.9±0.12µs 7.0±0.06µs -11.39%
ops/map/jwst/remove 9.1±0.08µs 10.7±0.14µs +17.58%
ops/map/yrs/get 353.3±5.92ns 355.5±7.33ns +0.62%
ops/map/yrs/insert 8.1±0.06µs 8.2±0.09µs +1.23%
ops/map/yrs/remove 10.5±0.10µs 10.6±0.10µs +0.95%
ops/text/jwst/insert 160.6±1.90µs 154.6±2.40µs -3.74%
ops/text/jwst/remove 3.7±0.03µs 3.6±0.03µs -2.70%
ops/text/yrs/insert 47.9±0.39µs 47.6±0.54µs -0.63%
ops/text/yrs/remove 3.9±0.03µs 3.7±0.04µs -5.13%
update/parse with jwst/basic.bin 84.1±1.50µs 80.7±0.87µs -4.04%
update/parse with jwst/database.bin 65.3±0.74µs 64.9±0.59µs -0.61%
update/parse with jwst/large.bin 4.0±0.17ms 4.1±0.14ms +2.50%
update/parse with jwst/with-subdoc.bin 12.5±0.08µs 12.5±0.27µs -0.00%
update/parse with yrs/basic.bin 69.7±0.62µs 67.6±0.70µs -3.01%
update/parse with yrs/database.bin 53.0±0.54µs 52.6±0.49µs -0.75%
update/parse with yrs/large.bin 3.3±0.20ms 3.3±0.11ms -0.00%
update/parse with yrs/with-subdoc.bin 12.2±0.11µs 12.6±0.12µs +3.28%

Copy link

Benchmark for Linux

Click to view benchmark
Test Base PR %
codec/jwst decode var_int (32 bit) 212.3±0.73µs 212.3±0.57µs -0.00%
codec/jwst decode var_uint (32 bit) 179.3±1.40µs 180.8±1.08µs +0.84%
codec/jwst decode var_uint (64 bit) 181.4±6.21µs 193.1±0.57µs +6.45%
codec/jwst encode var_int (32 bit) 333.7±2.20µs 336.9±5.23µs +0.96%
codec/jwst encode var_uint (32 bit) 254.9±11.21µs 249.2±5.49µs -2.24%
codec/jwst encode var_uint (64 bit) 252.5±3.67µs 248.8±4.21µs -1.47%
codec/lib0 decode var_int (64 bit) 187.1±3.10µs 185.2±2.26µs -1.02%
codec/lib0 decode var_uint (32 bit) 154.3±3.09µs 155.0±6.38µs +0.45%
codec/lib0 decode var_uint (64 bit) 154.5±3.50µs 176.0±1.31µs +13.92%
codec/lib0 encode var_int (64 bit) 391.8±1.81µs 392.9±7.75µs +0.28%
codec/lib0 encode var_uint (32 bit) 374.0±3.38µs 372.9±0.31µs -0.29%
codec/lib0 encode var_uint (64 bit) 373.2±1.10µs 373.5±1.11µs +0.08%
ops/array/jwst/insert 112.2±0.71µs 105.4±0.38µs -6.06%
ops/array/jwst/insert range 169.6±4.18µs 156.9±0.57µs -7.49%
ops/array/jwst/remove 69.0±0.07µs 62.1±1.42µs -10.00%
ops/array/yrs/insert 57.5±1.51µs 57.2±0.47µs -0.52%
ops/array/yrs/insert range 75.3±0.51µs 76.7±0.30µs +1.86%
ops/array/yrs/remove 63.2±1.50µs 62.6±0.60µs -0.95%
ops/map/jwst/get 346.8±1.53ns 204.8±0.91ns -40.95%
ops/map/jwst/insert 4.3±0.03µs 2.8±0.03µs -34.88%
ops/map/jwst/remove 5.1±0.03µs 4.2±0.02µs -17.65%
ops/map/yrs/get 259.1±1.03ns 264.8±9.89ns +2.20%
ops/map/yrs/insert 3.9±0.03µs 3.9±0.03µs -0.00%
ops/map/yrs/remove 5.1±0.06µs 5.1±0.10µs -0.00%
ops/text/jwst/insert 72.8±1.17µs 67.6±1.46µs -7.14%
ops/text/jwst/remove 2.1±0.01µs 1390.6±7.21ns +66119.05%
ops/text/yrs/insert 27.8±0.21µs 26.8±0.21µs -3.60%
ops/text/yrs/remove 1787.7±32.42ns 1776.7±7.48ns -0.62%
update/parse with jwst/basic.bin 38.0±0.28µs 39.8±0.15µs +4.74%
update/parse with jwst/database.bin 30.2±0.11µs 31.6±0.22µs +4.64%
update/parse with jwst/large.bin 3.5±0.03ms 1795.7±32.71µs +51205.71%
update/parse with jwst/with-subdoc.bin 5.6±0.03µs 5.0±0.02µs -10.71%
update/parse with yrs/basic.bin 29.7±0.14µs 29.9±0.76µs +0.67%
update/parse with yrs/database.bin 23.9±0.16µs 24.4±0.15µs +2.09%
update/parse with yrs/large.bin 2.6±0.01ms 2.6±0.02ms -0.00%
update/parse with yrs/with-subdoc.bin 3.7±0.03µs 3.8±0.03µs +2.70%

Benchmark for Windows

Click to view benchmark
Test Base PR %
codec/jwst decode var_int (32 bit) 213.0±3.09µs 213.6±6.95µs +0.28%
codec/jwst decode var_uint (32 bit) 180.6±3.03µs 181.0±3.19µs +0.22%
codec/jwst decode var_uint (64 bit) 182.8±3.25µs 195.1±2.80µs +6.73%
codec/jwst encode var_int (32 bit) 303.4±3.54µs 302.9±5.83µs -0.16%
codec/jwst encode var_uint (32 bit) 255.1±2.85µs 252.4±5.33µs -1.06%
codec/jwst encode var_uint (64 bit) 264.5±2.01µs 261.7±3.13µs -1.06%
codec/lib0 decode var_int (64 bit) 189.4±6.31µs 193.8±7.75µs +2.32%
codec/lib0 decode var_uint (32 bit) 151.0±2.03µs 153.8±5.09µs +1.85%
codec/lib0 decode var_uint (64 bit) 156.2±5.82µs 159.8±11.64µs +2.30%
codec/lib0 encode var_int (64 bit) 387.8±8.96µs 384.3±1.48µs -0.90%
codec/lib0 encode var_uint (32 bit) 373.6±1.13µs 374.4±1.63µs +0.21%
codec/lib0 encode var_uint (64 bit) 373.8±1.64µs 386.4±1.66µs +3.37%
ops/array/jwst/insert 124.1±1.45µs 122.8±0.77µs -1.05%
ops/array/jwst/insert range 178.9±0.82µs 179.9±1.42µs +0.56%
ops/array/jwst/remove 66.7±0.20µs 67.2±0.19µs +0.75%
ops/array/yrs/insert 71.1±0.58µs 73.0±0.44µs +2.67%
ops/array/yrs/insert range 98.9±0.73µs 96.8±0.48µs -2.12%
ops/array/yrs/remove 101.8±0.49µs 102.5±0.39µs +0.69%
ops/map/jwst/get 376.2±2.60ns 259.8±2.58ns -30.94%
ops/map/jwst/insert 5.9±0.05µs 4.7±0.04µs -20.34%
ops/map/jwst/remove 6.6±0.02µs 10.2±0.04µs +54.55%
ops/map/yrs/get 268.2±4.61ns 269.2±6.55ns +0.37%
ops/map/yrs/insert 5.7±0.05µs 5.7±0.02µs -0.00%
ops/map/yrs/remove 7.0±0.04µs 6.9±0.11µs -1.43%
ops/text/jwst/insert 86.7±1.00µs 89.9±0.72µs +3.69%
ops/text/jwst/remove 2.5±0.04µs 2.1±0.02µs -16.00%
ops/text/yrs/insert 33.8±0.48µs 32.9±0.28µs -2.66%
ops/text/yrs/remove 2.6±0.01µs 2.5±0.01µs -3.85%
update/parse with jwst/basic.bin 52.3±0.37µs 54.0±0.65µs +3.25%
update/parse with jwst/database.bin 41.2±0.29µs 42.3±0.26µs +2.67%
update/parse with jwst/large.bin 2.5±0.06ms 2.5±0.04ms -0.00%
update/parse with jwst/with-subdoc.bin 7.7±0.08µs 8.2±0.04µs +6.49%
update/parse with yrs/basic.bin 44.2±0.30µs 44.0±0.39µs -0.45%
update/parse with yrs/database.bin 35.4±0.21µs 35.2±0.12µs -0.56%
update/parse with yrs/large.bin 2.2±0.08ms 2.2±0.09ms -0.00%
update/parse with yrs/with-subdoc.bin 7.5±0.04µs 7.3±0.03µs -2.67%

y-octo/src/doc/hasher.rs Outdated Show resolved Hide resolved
@darkskygit darkskygit merged commit d29799a into main Nov 17, 2023
12 checks passed
@darkskygit darkskygit deleted the darksky/improve-apply-update-performance branch November 17, 2023 04:15
Copy link

Benchmark for Linux

Click to view benchmark
Test Base PR %
codec/jwst decode var_int (32 bit) 212.2±0.81µs 212.4±0.64µs +0.09%
codec/jwst decode var_uint (32 bit) 178.3±1.05µs 180.7±0.70µs +1.35%
codec/jwst decode var_uint (64 bit) 181.6±8.83µs 193.3±0.78µs +6.44%
codec/jwst encode var_int (32 bit) 333.3±1.43µs 345.1±3.83µs +3.54%
codec/jwst encode var_uint (32 bit) 254.3±16.56µs 250.6±3.99µs -1.45%
codec/jwst encode var_uint (64 bit) 251.0±9.50µs 250.4±3.67µs -0.24%
codec/lib0 decode var_int (64 bit) 186.3±2.62µs 186.6±2.70µs +0.16%
codec/lib0 decode var_uint (32 bit) 155.4±12.34µs 153.6±3.04µs -1.16%
codec/lib0 decode var_uint (64 bit) 154.4±3.40µs 176.1±1.42µs +14.05%
codec/lib0 encode var_int (64 bit) 389.2±24.80µs 385.6±11.21µs -0.92%
codec/lib0 encode var_uint (32 bit) 375.6±5.77µs 372.9±1.38µs -0.72%
codec/lib0 encode var_uint (64 bit) 374.1±1.75µs 372.8±0.82µs -0.35%
ops/array/jwst/insert 110.8±1.90µs 107.4±1.66µs -3.07%
ops/array/jwst/insert range 163.7±4.02µs 161.9±1.77µs -1.10%
ops/array/jwst/remove 65.6±0.40µs 62.1±0.31µs -5.34%
ops/array/yrs/insert 57.8±0.84µs 58.2±0.81µs +0.69%
ops/array/yrs/insert range 75.3±3.54µs 75.1±0.59µs -0.27%
ops/array/yrs/remove 62.6±0.48µs 66.7±1.79µs +6.55%
ops/map/jwst/get 346.5±1.45ns 207.8±5.47ns -40.03%
ops/map/jwst/insert 4.2±0.10µs 3.0±0.05µs -28.57%
ops/map/jwst/remove 5.0±0.02µs 4.3±0.11µs -14.00%
ops/map/yrs/get 259.8±2.18ns 259.9±4.14ns +0.04%
ops/map/yrs/insert 3.9±0.05µs 4.0±0.10µs +2.56%
ops/map/yrs/remove 5.1±0.19µs 5.0±0.02µs -1.96%
ops/text/jwst/insert 72.2±0.85µs 66.6±0.76µs -7.76%
ops/text/jwst/remove 2.1±0.02µs 1390.4±20.70ns +66109.52%
ops/text/yrs/insert 27.7±0.16µs 26.7±0.33µs -3.61%
ops/text/yrs/remove 1755.1±23.04ns 1747.6±17.48ns -0.43%
update/parse with jwst/basic.bin 37.7±0.70µs 37.0±0.20µs -1.86%
update/parse with jwst/database.bin 31.0±0.33µs 30.1±0.24µs -2.90%
update/parse with jwst/large.bin 3.5±0.05ms 1735.8±17.19µs +49494.29%
update/parse with jwst/with-subdoc.bin 4.8±0.04µs 4.6±0.11µs -4.17%
update/parse with yrs/basic.bin 30.0±0.25µs 30.2±0.95µs +0.67%
update/parse with yrs/database.bin 24.7±0.61µs 24.3±0.27µs -1.62%
update/parse with yrs/large.bin 2.6±0.05ms 2.6±0.03ms -0.00%
update/parse with yrs/with-subdoc.bin 4.1±0.02µs 4.0±0.01µs -2.44%

Benchmark for Windows

Click to view benchmark
Test Base PR %
codec/jwst decode var_int (32 bit) 213.8±5.22µs 212.7±1.48µs -0.51%
codec/jwst decode var_uint (32 bit) 181.4±4.10µs 180.9±3.89µs -0.28%
codec/jwst decode var_uint (64 bit) 183.0±3.67µs 195.8±3.59µs +6.99%
codec/jwst encode var_int (32 bit) 303.4±2.50µs 302.3±1.26µs -0.36%
codec/jwst encode var_uint (32 bit) 269.7±1.79µs 265.7±3.16µs -1.48%
codec/jwst encode var_uint (64 bit) 250.1±3.69µs 262.1±5.24µs +4.80%
codec/lib0 decode var_int (64 bit) 190.2±7.14µs 191.7±6.90µs +0.79%
codec/lib0 decode var_uint (32 bit) 157.8±6.70µs 155.2±4.07µs -1.65%
codec/lib0 decode var_uint (64 bit) 159.1±7.05µs 156.4±8.40µs -1.70%
codec/lib0 encode var_int (64 bit) 385.7±5.17µs 384.9±3.45µs -0.21%
codec/lib0 encode var_uint (32 bit) 374.4±1.09µs 374.0±0.96µs -0.11%
codec/lib0 encode var_uint (64 bit) 385.7±1.46µs 373.1±0.80µs -3.27%
ops/array/jwst/insert 124.2±1.96µs 121.9±1.16µs -1.85%
ops/array/jwst/insert range 183.9±3.23µs 183.1±2.61µs -0.44%
ops/array/jwst/remove 68.1±0.21µs 66.7±0.82µs -2.06%
ops/array/yrs/insert 71.7±0.77µs 71.9±0.59µs +0.28%
ops/array/yrs/insert range 96.9±0.70µs 99.9±0.56µs +3.10%
ops/array/yrs/remove 102.0±0.35µs 106.2±1.70µs +4.12%
ops/map/jwst/get 375.4±1.64ns 259.7±2.75ns -30.82%
ops/map/jwst/insert 5.9±0.05µs 4.6±0.05µs -22.03%
ops/map/jwst/remove 6.8±0.02µs 9.8±0.06µs +44.12%
ops/map/yrs/get 269.3±4.66ns 269.4±7.21ns +0.04%
ops/map/yrs/insert 5.8±0.07µs 5.8±0.06µs -0.00%
ops/map/yrs/remove 7.0±0.12µs 6.9±0.03µs -1.43%
ops/text/jwst/insert 86.5±1.79µs 85.7±1.04µs -0.92%
ops/text/jwst/remove 2.5±0.01µs 2.1±0.01µs -16.00%
ops/text/yrs/insert 34.2±0.17µs 32.6±0.41µs -4.68%
ops/text/yrs/remove 2.6±0.02µs 2.5±0.01µs -3.85%
update/parse with jwst/basic.bin 53.2±0.67µs 53.4±0.57µs +0.38%
update/parse with jwst/database.bin 41.3±0.32µs 43.8±0.45µs +6.05%
update/parse with jwst/large.bin 2.7±0.07ms 2.6±0.06ms -3.70%
update/parse with jwst/with-subdoc.bin 7.7±0.05µs 8.2±0.05µs +6.49%
update/parse with yrs/basic.bin 44.0±0.96µs 44.7±0.42µs +1.59%
update/parse with yrs/database.bin 34.9±0.17µs 35.4±0.19µs +1.43%
update/parse with yrs/large.bin 2.2±0.05ms 2.1±0.10ms -4.55%
update/parse with yrs/with-subdoc.bin 7.3±0.05µs 7.3±0.05µs -0.00%

darkskygit added a commit to toeverything/OctoBase that referenced this pull request Dec 28, 2023
this PR partially solves y-crdt/y-octo##33 and greatly improves the performance of
apply update
test cases show a performance improvement of about 40-50%
darkskygit added a commit to toeverything/OctoBase that referenced this pull request Jan 31, 2024
this PR partially solves y-crdt/y-octo##33 and greatly improves the performance of
apply update
test cases show a performance improvement of about 40-50%
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