Why using TRUENAME + ERROR + HANDLER-CASE instead of PROBE-FILE?
I have been tracking a completely unrelated bug in ECL but found that for loading all files ASDF calls TRUENAME with the names of FASLs that do not exist. It finds out that by catching the corresponding error and then tries something else.
Throwing and catching errors is costly. Why doing that instead of using PROBE-FILE?
Juanjo
On 14 July 2010 16:40, Juan Jose Garcia-Ripoll juanjose.garciaripoll@googlemail.com wrote:
Why using TRUENAME + ERROR + HANDLER-CASE instead of PROBE-FILE? I have been tracking a completely unrelated bug in ECL but found that for loading all files ASDF calls TRUENAME with the names of FASLs that do not exist. It finds out that by catching the corresponding error and then tries something else. Throwing and catching errors is costly. Why doing that instead of using PROBE-FILE? Juanjo
Dear Juanjo,
we use TRUENAME + HANDLER-CASE precisely because the file (or directory, most of the time) doesn't necessarily exist and we're trying to fully resolve any symlinks along the path, so that in the end we may apply translations to normalized pathnames.
If you know of a less brutish approach to the problem, or of an ECL-specific optimization, I'll be glad to apply a patch. How do you think we could improve things? Is it causing a big performance hit for you? I would have supposed the filesystem caches would handle all this traffic gracefully.
[ François-René ÐVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ] Who released the most slaves? The one who spent his wealth buying them back? Or the capitalist who found a way to power mills with water?
On Thu, Jul 15, 2010 at 12:59 AM, Faré fahree@gmail.com wrote:
we use TRUENAME + HANDLER-CASE precisely because the file (or directory, most of the time) doesn't necessarily exist and we're trying to fully resolve any symlinks along the path, so that in the end we may apply translations to normalized pathnames.
But Rene, (ignore-errors (return (truename p))) = (probe-file p) with the difference that the latter can be implemented much more efficiently.
TRUENAME has a cost that is proportional to the number of directory components and to this you must add the cost of establishing a handler-bind and the jump outside the function due to the error.
PROBE-FILE first probes the existence of the file, which can be done with a *single* system call. No error handling is required: if the file does not exist, nothing else is done, but if the file exists, then its truename is returned -- as per TRUENAME, with symlinks resolved.
Am I missing something?
Juanjo