Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Add typed kv adapter and migrate moka to it #2222

Merged
merged 3 commits into from
May 7, 2023
Merged

Conversation

Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented May 7, 2023

This PR will close #1392.

By adding a new typed kv adapter, we can store metadata and bytes in rust containers like moka, dashmap, and avoid the extra cost of ser/de the bytes.

This PR will improve the read perf of moka at 1500%, and write perf at 160000% (the best case).

Read Before:

service_moka_read_full/4.00 KiB
                        time:   [3.1231 µs 3.1270 µs 3.1312 µs]
                        thrpt:  [1.2183 GiB/s 1.2199 GiB/s 1.2214 GiB/s]
service_moka_read_full/256 KiB
                        time:   [67.995 µs 68.043 µs 68.094 µs]
                        thrpt:  [3.5853 GiB/s 3.5881 GiB/s 3.5906 GiB/s]
service_moka_read_full/4.00 MiB
                        time:   [127.98 µs 128.19 µs 128.43 µs]
                        thrpt:  [30.415 GiB/s 30.473 GiB/s 30.522 GiB/s]
service_moka_read_full/16.0 MiB
                        time:   [731.54 µs 736.31 µs 741.73 µs]
                        thrpt:  [21.066 GiB/s 21.221 GiB/s 21.359 GiB/s]

service_moka_read_part/4.00 KiB
                        time:   [1.8117 µs 1.8238 µs 1.8349 µs]
                        thrpt:  [2.0790 GiB/s 2.0916 GiB/s 2.1056 GiB/s]
service_moka_read_part/256 KiB
                        time:   [24.402 µs 24.425 µs 24.449 µs]
                        thrpt:  [9.9856 GiB/s 9.9953 GiB/s 10.005 GiB/s]
service_moka_read_part/4.00 MiB
                        time:   [342.33 µs 342.99 µs 343.77 µs]
                        thrpt:  [11.363 GiB/s 11.389 GiB/s 11.411 GiB/s]
service_moka_read_part/16.0 MiB
                        time:   [6.1593 ms 6.1756 ms 6.1953 ms]
                        thrpt:  [2.5221 GiB/s 2.5301 GiB/s 2.5368 GiB/s]

Read After

service_moka_read_full/4.00 KiB
                        time:   [1.2101 µs 1.2125 µs 1.2151 µs]
                        thrpt:  [3.1394 GiB/s 3.1460 GiB/s 3.1525 GiB/s]
                 change:
                        time:   [-61.435% -61.358% -61.273%] (p = 0.00 < 0.05)
                        thrpt:  [+158.22% +158.79% +159.30%]
                        Performance has improved.
service_moka_read_full/256 KiB
                        time:   [5.4017 µs 5.4343 µs 5.4911 µs]
                        thrpt:  [44.462 GiB/s 44.926 GiB/s 45.197 GiB/s]
                 change:
                        time:   [-92.017% -91.914% -91.805%] (p = 0.00 < 0.05)
                        thrpt:  [+1120.2% +1136.7% +1152.6%]
                        Performance has improved.
service_moka_read_full/4.00 MiB
                        time:   [69.694 µs 71.709 µs 73.882 µs]
                        thrpt:  [52.872 GiB/s 54.474 GiB/s 56.049 GiB/s]
                 change:
                        time:   [-46.655% -45.354% -44.136%] (p = 0.00 < 0.05)
                        thrpt:  [+79.005% +82.995% +87.460%]
                        Performance has improved.
service_moka_read_full/16.0 MiB
                        time:   [225.82 µs 226.70 µs 227.88 µs]
                        thrpt:  [68.568 GiB/s 68.923 GiB/s 69.191 GiB/s]
                 change:
                        time:   [-69.957% -69.431% -68.914%] (p = 0.00 < 0.05)
                        thrpt:  [+221.69% +227.13% +232.86%]
                        Performance has improved.

service_moka_read_part/4.00 KiB
                        time:   [1.6380 µs 1.6405 µs 1.6434 µs]
                        thrpt:  [2.3212 GiB/s 2.3254 GiB/s 2.3289 GiB/s]
                 change:
                        time:   [-9.5756% -9.2733% -8.9819%] (p = 0.00 < 0.05)
                        thrpt:  [+9.8682% +10.221% +10.590%]
                        Performance has improved.
service_moka_read_part/256 KiB
                        time:   [6.0927 µs 6.1006 µs 6.1091 µs]
                        thrpt:  [39.964 GiB/s 40.019 GiB/s 40.071 GiB/s]
                 change:
                        time:   [-75.077% -75.015% -74.957%] (p = 0.00 < 0.05)
                        thrpt:  [+299.31% +300.24% +301.23%]
                        Performance has improved.
service_moka_read_part/4.00 MiB
                        time:   [95.818 µs 95.949 µs 96.095 µs]
                        thrpt:  [40.650 GiB/s 40.712 GiB/s 40.767 GiB/s]
                 change:
                        time:   [-72.177% -71.859% -71.610%] (p = 0.00 < 0.05)
                        thrpt:  [+252.23% +255.35% +259.41%]
                        Performance has improved.
service_moka_read_part/16.0 MiB
                        time:   [375.72 µs 378.70 µs 381.96 µs]
                        thrpt:  [40.908 GiB/s 41.260 GiB/s 41.586 GiB/s]
                 change:
                        time:   [-93.900% -93.826% -93.745%] (p = 0.00 < 0.05)
                        thrpt:  [+1498.6% +1519.8% +1539.4%]
                        Performance has improved.

Write before:

service_moka_write_once/4.00 KiB
                        time:   [2.4354 µs 2.4410 µs 2.4477 µs]
                        thrpt:  [1.5585 GiB/s 1.5628 GiB/s 1.5664 GiB/s]
service_moka_write_once/256 KiB
                        time:   [117.32 µs 117.43 µs 117.54 µs]
                        thrpt:  [2.0770 GiB/s 2.0791 GiB/s 2.0811 GiB/s]
service_moka_write_once/4.00 MiB
                        time:   [223.68 µs 225.31 µs 227.32 µs]
                        thrpt:  [17.184 GiB/s 17.337 GiB/s 17.464 GiB/s]
service_moka_write_once/16.0 MiB
                        time:   [3.1602 ms 3.2230 ms 3.2908 ms]
                        thrpt:  [4.7481 GiB/s 4.8480 GiB/s 4.9443 GiB/s]

Write after:

service_moka_write_once/4.00 KiB
                        time:   [1.4844 µs 1.4906 µs 1.4977 µs]
                        thrpt:  [2.5470 GiB/s 2.5592 GiB/s 2.5699 GiB/s]
                 change:
                        time:   [-38.877% -38.651% -38.452%] (p = 0.00 < 0.05)
                        thrpt:  [+62.474% +63.001% +63.605%]
                        Performance has improved.
service_moka_write_once/256 KiB
                        time:   [1.9958 µs 2.0072 µs 2.0204 µs]
                        thrpt:  [120.84 GiB/s 121.63 GiB/s 122.33 GiB/s]
                 change:
                        time:   [-98.297% -98.288% -98.280%] (p = 0.00 < 0.05)
                        thrpt:  [+5714.8% +5742.7% +5772.0%]
                        Performance has improved.
service_moka_write_once/4.00 MiB
                        time:   [1.9519 µs 1.9536 µs 1.9560 µs]
                        thrpt:  [1997.1 GiB/s 1999.5 GiB/s 2001.3 GiB/s]
                 change:
                        time:   [-99.128% -99.122% -99.117%] (p = 0.00 < 0.05)
                        thrpt:  [+11227% +11292% +11362%]
                        Performance has improved.
service_moka_write_once/16.0 MiB
                        time:   [1.9317 µs 1.9340 µs 1.9373 µs]
                        thrpt:  [8065.2 GiB/s 8079.1 GiB/s 8088.7 GiB/s]
                 change:
                        time:   [-99.941% -99.940% -99.939%] (p = 0.00 < 0.05)
                        thrpt:  [+163072% +166323% +169800%]
                        Performance has improved.

Xuanwo added 2 commits May 7, 2023 19:29
Signed-off-by: Xuanwo <github@xuanwo.io>
Signed-off-by: Xuanwo <github@xuanwo.io>
@Xuanwo Xuanwo requested review from PsiACE, ClSlaid and sundy-li as code owners May 7, 2023 11:43
Signed-off-by: Xuanwo <github@xuanwo.io>
@Xuanwo Xuanwo mentioned this pull request May 7, 2023
3 tasks
Copy link
Member

@suyanhanx suyanhanx left a comment

Choose a reason for hiding this comment

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

Great work! Thanks!

@Xuanwo Xuanwo merged commit c3c3c9f into main May 7, 2023
@Xuanwo Xuanwo deleted the add-typed-kv branch May 7, 2023 12:55
suyanhanx pushed a commit to suyanhanx/opendal that referenced this pull request May 8, 2023
* feat: Add typed kv adapter and migrate moka to it

Signed-off-by: Xuanwo <github@xuanwo.io>

* Add bench for moka

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix typo

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
@Xuanwo Xuanwo mentioned this pull request May 9, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kv: Use Bytes as value to avoid copy between read/write
2 participants