beldathas
11/16/2023, 10:36 PMopen and opendal on a dummy file of ~150MB
python
import pathlib
import timeit
import opendal
root = pathlib.Path(__file__).parent
op = opendal.Operator("fs", root=str(root))
filename = "lorem_ipsum_150mb.txt"
def read_file_with_opendal() -> bytes:
with op.open(filename, "rb") as fp:
result = fp.read()
return result
def read_file_with_normal() -> bytes:
with open(root / filename, "rb") as fp:
result = fp.read()
return result
if __name__ == "__main__":
print("normal: ", timeit.timeit(read_file_with_normal, number=100))
print("opendal: ", timeit.timeit(read_file_with_opendal, number=100))
and got the following results
shell
(venv) $ python benchmark.py
normal: 4.470868484000675
opendal: 8.993250704006641
I was a bit surprised by the result. I'm using opendal==0.42.0 Xuanwo
11/17/2023, 5:43 AMXuanwo
11/17/2023, 4:59 PMXuanwo
11/17/2023, 4:59 PMbeldathas
11/17/2023, 6:50 PMXuanwo
11/18/2023, 9:24 AMvalgrind --tool=callgrind and kcachegrind for this.Xuanwo
11/18/2023, 9:24 AMXuanwo
11/18/2023, 4:04 PMXuanwo
11/18/2023, 4:04 PMXuanwo
11/18/2023, 4:05 PMXuanwo
11/19/2023, 5:32 AMXuanwo
11/19/2023, 5:33 AMXuanwo
11/19/2023, 5:34 AMXuanwo
11/27/2023, 1:03 PMXuanwo
11/27/2023, 1:04 PMXuanwo
11/27/2023, 1:05 PMXuanwo
11/27/2023, 1:07 PMcopyout and clear_page_erms are all kernel functions that operate on buffer between users and kernel.Xuanwo
11/27/2023, 1:08 PMbeldathas
11/27/2023, 1:44 PMmemoryview with very little overhead.Xuanwo
11/27/2023, 1:48 PMXuanwo
11/27/2023, 1:49 PMXuanwo
11/27/2023, 1:49 PMbeldathas
11/27/2023, 1:52 PMXuanwo
11/27/2023, 1:53 PMsudo dmidecode --type memorybeldathas
11/27/2023, 1:54 PMXuanwo
11/28/2023, 1:43 PMbeldathas
11/28/2023, 7:38 PMshell
$ neofetch --backend off
OS: Ubuntu 20.04.6 LTS x86_64
Host: XPS 15 9510
Kernel: 5.15.0-83-generic
Uptime: 2 days, 2 hours, 44 mins
Packages: 2697 (dpkg), 14 (flatpak), 12 (snap)
Shell: bash 5.0.17
Resolution: 1920x1200
DE: GNOME
WM: Mutter
WM Theme: Adwaita
Theme: Yaru-dark [GTK2/3]
Icons: Yaru [GTK2/3]
Terminal: gnome-terminal
CPU: 11th Gen Intel i7-11800H (16) @ 4.600GHz
GPU: Intel TigerLake-H GT1 [UHD Graphics]
GPU: NVIDIA GeForce RTX 3050 Ti Mobile
Memory: 10237MiB / 15712MiB
The output of dmidecode command is too big so I shared it as attachment
https://cdn.discordapp.com/attachments/1174840499576770560/1179144399393919096/dmidecode.txt?ex=6578b6cc&is=656641cc&hm=154a42460f9b7119b914ebdcb5e881c4c37947c621b7dc280918d5ebd7a36572&beldathas
11/28/2023, 7:52 PM0x20 offset magically speeds things upXuanwo
11/29/2023, 2:39 AMbeldathas
11/29/2023, 6:44 AMXuanwo
11/29/2023, 9:21 AMXuanwo
11/29/2023, 9:22 AMbeldathas
11/29/2023, 2:53 PM