[erlang-questions] Newbie questions about file module
Scott Lystig Fritchie
Tue Feb 17 00:45:46 CET 2009
Ville Silventoinen <> wrote:
vs> [...] It shows that 82% of the time goes in file_name_1/1,
vs> which "Generates a flat file name from a deep list of atoms and
vs> characters (integers)".
Ville, I don't have a good reply (other than, yes, 82% of the app's user
time is probably being used there ... but eprof can't measure
system/in-kernel time well). But I do have a "yeah, me too!" message
for the OTP gang.
I've got an app that does a *lot* of file opening & closing.
1. Figure out what file a key is stored in.
2. Open that file.
3. Seek to some position within the file
4. Read some bytes.
5. Close the file
6. Lather, rinse, repeat...
... across tens of thousands of files in the local file system
(representing gazillions of smaller objects). After I discovered the
cost of erlang:md5/1 vs. crypto:md5/1 (see message to the list a little
while ago), the 2nd biggest time sucker was the same function that Ville
is complaining about: file:file_name_1/1.
How frequent is it to use a deep I/O list as a file name? (Perhaps I've
been in C land for too long to think that using a deep I/O list like
that is actually a good idea?) Doesn't an argument like that get
automatically flattened when passed to the efile_drv driver? If yes,
why bother flattening on the Erlang side?
More information about the erlang-questions