tikv / yatp

Yet another thread pool in rust for both callbacks or futures.
Apache License 2.0
135 stars 32 forks source link

multilevel: use atomic for elapsed time #37

Closed BusyJay closed 4 years ago

BusyJay commented 4 years ago

This PR brings two updates:

Atomic variable is faster to be allocated, which can save some time when request is very small. A simple spawn_many bench shows about 50% improvement.

If a request has fixed level, recorded request time will not have impact on itself, so it can be skipped completely. Although there may be requests share the same task ID, but mixing dynamic and fixed level usage seems odd to me. Bench shows that if spawn_many is benched with fixed level, multilevel is almost as fast as single_level.

BusyJay commented 4 years ago

Benchmark in TiKV shows point get QPS increases by about 4%. Although there is still 1% difference from disabling it completely.