Hi,
Aspose.TeX for .net is very slow - when I profile it it appears to be slow because it is looking for files in all the wrong places. I supply the packages through the options.InputWorkingDirectory and options.RequiredInputDirectory, but still it first seems to check the application’s current working directory. It is throwing an exception, and catching that exception to figure out that the file is not there. (This is very slow). In my case - the file will never be there, and I don’t want it to even try to look, but there is no way to tell the library to not bother.
Please Help.
Hi,
Thank you for the detailed report — your analysis is correct.
For every requested file (including LaTeX’s many “probe” lookups for optional .cfg/.fd/.aux files that normally don’t exist), the engine currently checks, in order: the process’s current directory, the directory of the main input file, InputWorkingDirectory, RequiredInputDirectory (recursively, including all subdirectories), and OutputWorkingDirectory.
The file-system implementation currently detects a missing file by catching an exception. With a large package tree in RequiredInputDirectory, this results in an exception for each subdirectory on every lookup, which is where most of the time is spent.
Workaround available now: pack your packages into a ZIP archive and supply it via InputZipDirectory instead of InputFileSystemDirectory:
using (Stream zip = File.OpenRead("packages.zip"))
{
options.RequiredInputDirectory = new InputZipDirectory(zip, "/");
// ... run TeXJob
}
The archive is indexed in memory once, and lookups are then performed without exceptions or disk access.
Alternatively, you can implement IInputWorkingDirectory yourself on top of a pre-built dictionary of file names.
We have already identified this issue and plan to address it in one of the upcoming releases by:
- replacing exception-based file probing with existence checks;
- indexing directory trees once instead of searching them on every lookup;
- adding an option to disable probing the current directory.
We’ll notify you in this thread when the fix is released.