you will need to use a hashing algorithm that can handle a sufficiently large number of items
I didn't expect SHA256 to be so slow. I just tested a simple bash loop, and get less than 1000 hashes per second. That won't scale well to 40 billion inputs.
As @vjudeu said, you used un-optimized tool. You should use optimized tool such as
hashcat. Even on single core VPS without OpenCL package, i managed to get ~5000 kH/s.