This has been brought up recently in support forums:
FreeBSD UFS has a hard limit of ~32k files per directory. Most filesystems' performance degrades when they have a huge number of files per directory regardless.
A two-level structure, using for example the first two characters of md5 of the file name for the subdirectory name, would likely be sufficient.
Maybe using post id + file name would produce a more even distribution. Obviously if something like upload time or random noise can be incorporated it would be better still.