Quote:
Originally Posted by kovidgoyal
If you set CALIBRE_TEMP_DIR so that it exists before the calibre GUI is launched it will be used in preference to all other variables. I think on OS X that means you have to set it for lauchd via the launchd environment plist file, a bit of googling should tell you how to do that.
|
Got it! With CALIBRE_TEMP_DIR set, all the calibre conversion temp files go to that directory. It has to be set by setenv in a suitable launchd configuration file at login, or later using launchctl setenv in Terminal.
Thank you, Kovid and itimpi, for the clues above, and thank you, GRiker, for additional clues in the thread:
https://www.mobileread.com/forums/sho...d.php?t=186069
which included a link to:
http://www.dowdandassociates.com/con...etclaunchdconf
explaining how to set a system-wide environment variable during OS X startup, per the launchd configuration file /etc/launchd.conf. That works for CALIBRE_TEMP_DIR, but it does not work for the environment variable TMPDIR. (The older method of setting environment variables in ~/.MacOSX/environment.plist doesn't work in Mountain Lion, at least for me. And apparently launchd.conf per user is not yet supported.)
I modified the startup script to mount a ramdisk on a new directory CalibreTempDir dedicated to calibre temporary files, set as CALIBRE_TEMP_DIR per /etc/launchd.conf. The script also mounts ramdisks on /private/tmp and /var/run. I was possibly wrong earlier when I said a ramdisk didn't work for /var/folders or any of its subdirectories, including the directory pointed to by that other environment variable TMPDIR. OS X doesn't show the contents of a ramdisk mounted on var/folders or its subdirectories, while OS X does show the contents of ramdisks mounted on /private/tmp, /var/run, and my new CalibreTempDir, so I assumed either it didn't work or wasn't working right. I figure that messing with /var/folders or its subdirectories is too dangerous, until I learn more, such as how to successfully redirect the directory pointed to by TMPDIR to a ramdisk'd directory I can see the contents of.
I was mostly concerned about the calibre conversion temp files, because calibre generates and deletes a lot of them during conversions (deleting any remaining temp files at calibre Quit). So redirecting those temp files to ramdisk preserves the life of the SSD.
This kludge uses hdik and mounts ramdisks on directories. Surprisingly putting calibre conversion temp files on ramdisk results in the same conversion times as with no ramdisk. I suspect the lack of speedup may have something to do with memory management in OS X, though turning dynamic pager off or on didn't affect the speed of calibre conversions. The script I'm using is in this spoiler: