I want to try to speed up bulk iterator operations...
# dev
a
I want to try to speed up bulk iterator operations by prefetching. The easy way to express a "value that will show up" is with a future. Futures have a pretty simple implementation in terms of channels, see e.g. ChanOnlyOne which effectively inlines an implementation of futures into a sync.Map. So... 1. use an existing futures library? [go-promise](https://github.com/fanliao/go-promise) is sort-of promising and makes the most sense, but introduces needless promises along the way. 2. Write my own? I could, how familiar are futures (not promises, but probably familiar to anyone who's used those)? 3. Inline my own implementation? Least scary, but hardest to grasp because it melds multiple concepts into the same objects. Right now I'm going with 3 and mixing channels into it, but will happily hear options.
o
what kind of performace gains are you expecting?
a
2x? We read 3 metaranges when we diff. Every time we call
Next
on any iterator, we wait for a round-trip to the OS. But... if I can run
Next
in a separate goroutine before I need it, I can win! Obviously this applies only to iterators used in batch operations.