labring / sealfs

The storage system of sealos, aims to be a high-performance, high-reliability, and auto-scaling distributed file system
Apache License 2.0
142 stars 20 forks source link

Improve circularQueue and fixed cleanup(). #77

Closed mond77 closed 1 year ago

mond77 commented 1 year ago

close #75

changed:

  1. fix that cleanup() sometimes doesn't work.
  2. when calling client::new() a daemon thread will be created for cleanup loop. (that avoid concurrency raced so atomicU32 could replace mutex)
  3. add mpsc::sync_channel(1) named occupied; block register_callback if the id has already been occupied.

tested: 10000 Tokio task for call_remote() every 20 seconds, totally 10 times.

result: when main exited, start_index was 78192.(forget to wait all callbacks done) cleanup can reasonably work. call_remote without occurring error.

luanshaotong commented 1 year ago

Another problem is that the new channel may increase latency. Pls test it in the future.

mond77 commented 1 year ago

Another problem is that the new channel may increase latency. Pls test it in the future.

yeah, the expense of sync_channel will be significant when repeated id was registered.