What's the fastest way to store 300 million unique values in a HashSet?

If the strings are read from a file on disk, you could skip most of the overhead using a memmap:

use std::collections::HashSet;
use std::fs::File;
use memmap2::Mmap;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = File::open("custom_1988_2020.csv")?;
    let memmap = unsafe { Mmap::map(&file)? };
    let mut set: HashSet<&[u8]> = HashSet::with_capacity(200_000_000);
    memmap.split(|c| *c == b'\n')
        .for_each(|v| {
            set.insert(v);
        });

    println!("length: {}", set.len());
    Ok(())
}

I was surprised my maximum insert rate was only about 250k entries per second on a M1 Apple though