redis refactoring

hide Redis in a KVStore class

perform static profiling properly 

N.B. static profile counts for non-optimizations are off by 5x for the opt pass, because the pass runs 5 times. I don't think we care since optimizations and non-optimizations will always be ranked separately. profiling of non-optimizations is a niche use case anyway.
This could be moved into the main function.