Feature Request: Iterator::Refresh() with a snapshot
Current Iterator::Refresh() does not support snapshot, we have no way to refresh an iterator to a specified snapshot, instead we create a new iterator, but creating new iterator is heavy.
Refresh iterator to a specified snapshot, we can avoid creating new iterator thus improving performance.
I see the current Refresh() is actually pretty heavyweight and takes similar amount of work as creating a new iterator when superversion number is changed: https://github.com/facebook/rocksdb/blob/f28d0c2020d0314e66aed240f379f2a795b6c940/db/arena_wrapped_db_iter.cc#L62-L82
So supporting iterator refresh to a new snapshot might only get performance benefit when superversion number is not changed. Is that the performance improvement you expected? Or you expect some improvements could be done when superversion changes too?
I seeked for a feature to avoid creating new iterator when I need to update an iterator to a specified snapshot, then I found Refresh, I expect Refresh is much lighter than creating new iterator.
As an online service, super version change should be much less frequent than snapshot change, so Refresh with snapshot is much lighter in most cases. If super version is really changed, with carefully coding, the Refresh computation should be still lighter than creating a new iterator.
Hi @rockeet, I agree this is a reasonable feature to add, and optimizing the part where superversion is not changed should be easier to implement. It's not planned yet, so I'll leave it as up-for-grabs for now.
Hi @rockeet, I agree this is a reasonable feature to add, and optimizing the part where superversion is not changed should be easier to implement. It's not planned yet, so I'll leave it as up-for-grabs for now.
Very Thanks!