Should Partition Handles be kept around? #142
-
Pretty much what the title says, I'm thinking of using fjall for a project but the docs do not make it clear if I should keep around the partition handles I instance (I.e. share them throuhg an Arc<Mutex<...>>) or instance on each time I need to access a given partition? Thanks in advance, this project looks really nice. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
All open partitions are stored in the keyspace behind a RwLock. If the partition(s) you are using are fixed at runtime, holding onto the handle skips going through that lock each time, also it avoids the construction cost of an You can also keep them (or possibly a subset) in your own RwLock (do not use a Mutex), if you have a dynamic (sub)set of partitions during runtime. |
Beta Was this translation helpful? Give feedback.
-
Thanks, just the answer I was looking for, closing this then! Thanks again! |
Beta Was this translation helpful? Give feedback.
All open partitions are stored in the keyspace behind a RwLock. If the partition(s) you are using are fixed at runtime, holding onto the handle skips going through that lock each time, also it avoids the construction cost of an
Options
struct, which should be cheap, but is non-zero.You can also keep them (or possibly a subset) in your own RwLock (do not use a Mutex), if you have a dynamic (sub)set of partitions during runtime.