If you are going to loop through a bunch of vectors in a shader, it probably makes sense to encode those values into a texture if possible. This will allow the GPU to sample the values relatively efficiently during each loop since all of the data will be on the GPU and memory with minimal back and forth between the CPU.
This is partially how a technique like Parallax Occlusion Mapping can loop hundreds of times without taking 30ms (although it’s still best to keep loops to a minimum).