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.
When creating a set, you generally do not want to use a hashing algorithm that will result in zero collisions for any number of inputs.
A general solution is to use a linked-list when there are collisions. This will result in a worse big O notation, however, it should improve actual runtime.