If you are calling 'getbit' for all bits in a bitmap, you would be better off performing a single "get" and doing the scan on the client side.
It would be significantly faster than what you are doing, use less bandwidth, etc. You could also write your scan using Lua scripting, though I would suggest that you use 'bitcount' to determine if a block has any bits set, and if so, then scan a block. If you size your blocks properly based on the actual density of bits set in your data, then you may save significant time in scanning blocks on the Lua side. I would also suggest that you not scan the whole bitmap at once, and instead provide a "start" position so you can scan your data incrementally, receiving say 1000 bit set positions at a time.
- Josiah