XmacsLabs / lolly

lolly: A user-friendly C++ library
https://xmacslabs.github.io/lolly/
GNU General Public License v3.0
10 stars 6 forks source link

[8_4] improve error handling and performance of mimalloc #254

Closed jingkaimori closed 9 months ago

jingkaimori commented 9 months ago

by register error handler to avoid checking NULL pointer at every allocation. Thus lolly must be initialized by init_tbox before any invocation. Therefore many tests are rewritten.

Such optimization cannot be performed on jemalloc or fast_alloc.

da-liii commented 9 months ago

I do not think it is a perf pr, but it is a pr for better error handling.

da-liii commented 9 months ago

You can disable wasm CI on windows, it is better to do wasm development on linux.

I think wasm dev env on Windows is nice to have but it is not necessary. What's your idea on wasm dev env, if you agree my idea, just disable the ci in this pr.

da-liii commented 9 months ago

I do not think it is a perf pr

Could you provide the benchmark result? Null check here is not the bottle neck of performance here.

but it is a pr for better error handling.

For error handling, this pr is important for developer to finding bugs for the memory allocator.

jingkaimori commented 9 months ago

Performance

Before this pr:

ns/alloc & free alloc & free/s err% total benchmark
18.10 55,251,393.84 0.4% 0.09 basic type, fast collect
19.69 50,795,585.86 1.1% 0.09 basic type, bulk collect
18.85 53,062,126.91 0.4% 0.02 char, bulk collect
19.69 50,795,800.88 0.3% 0.02 int, bulk collect
20.37 49,087,420.23 1.8% 0.02 long, bulk collect
21.94 45,585,777.24 0.8% 0.03 double, bulk collect
22.71 44,042,456.68 0.3% 0.01 struct
7.28 137,449,849.42 1.6% 17.64 large array of basic type
6.42 155,811,536.60 3.3% 3.87 large array of complex structure
68.53 14,592,923.76 1.4% 0.08 `frequent allocation of array, space reused

After this pr:

ns/alloc & free alloc & free/s err% total benchmark
15.11 66,180,341.43 1.5% 0.07 basic type, fast collect
16.09 62,167,966.54 1.0% 0.08 basic type, bulk collect
15.70 63,686,892.08 0.5% 0.02 char, bulk collect
16.22 61,638,462.40 0.5% 0.02 int, bulk collect
16.89 59,213,005.33 1.5% 0.02 long, bulk collect
17.69 56,534,438.90 0.6% 0.02 double, bulk collect
19.29 51,832,998.20 7.0% 0.01 :wavy_dash: struct (Unstable with ~52,283.3 iters. Increase minEpochIterations to e.g. 522833)
7.36 135,847,019.41 0.3% 17.66 large array of basic type
7.21 138,732,639.50 1.8% 4.28 large array of complex structure
67.95 14,717,605.94 1.4% 0.08 frequent allocation of array, space reused