rksm / hot-lib-reloader-rs

Reload Rust code without app restarts. For faster feedback cycles.
MIT License
577 stars 21 forks source link

RWLock is a bit too heavy. Considering performance issues, can Atomic be used? #30

Closed ctemple closed 3 months ago

ctemple commented 1 year ago

result from rust-lock-bench

==== num_reader: 20, num_writer: 0 ==== mutex => mean: 45.71, std_dev: 5.35 rwlock => mean: 134.71, std_dev: 17.67 prwlock => mean: 134.71, std_dev: 17.67 seq_cst => mean: 1.00, std_dev: 0.00 relaxed => mean: 1.00, std_dev: 0.00 unsync => mean: 1.00, std_dev: 0.00

==== num_reader: 19, num_writer: 1 ==== mutex => mean: 50.29, std_dev: 7.63 rwlock => mean: 113.71, std_dev: 19.61 prwlock => mean: 113.71, std_dev: 19.61 seq_cst => mean: 4.57, std_dev: 6.80 relaxed => mean: 3.00, std_dev: 2.65 unsync => mean: 1.57, std_dev: 1.51

rksm commented 1 year ago

Not easily, no, we are currently keeping a instance of libloading::Library behind it. It would make lib reload checks a little faster but are there any indications that this would really matter? micro benchmarks are one thing but in the context of this project it seems unclear if there is anything being gained from it.

ctemple commented 10 months ago

Not easily, no, we are currently keeping a instance of libloading::Library behind it. It would make lib reload checks a little faster but are there any indications that this would really matter? micro benchmarks are one thing but in the context of this project it seems unclear if there is anything being gained from it.

For web applications, the performance of rwlock is sufficient. Now I want to use it in game servers with much higher call frequency. In this scenario, rwlock may be an issue