Behaviour of kpsea re symlinks to directories

Yann Salmon contact at yannsalmon.fr
Mon Mar 28 09:29:16 CEST 2022


Hello,

> Yes. https://tug.org/texinfohtml/kpathsea.html#Subdirectory-expansion

Thank you for that pointer ; I had read it a long time ago but it is not 
easy to find because in the use case I am dealing with, the user is not 
explicitly using kpsea, and in fact may not be even aware of its existence.


> All entries should not get stat-ed, when there are no subdirs.
> (Normally.) Kpse would not recurse into the directory to look for
> subdirs. That's the whole point.

IIUC, we can get just the names of the files in a dir (without getting 
their nature as a regular file, symlink or directory) and the 
information that there is (or not) at least a directory, and this is 
faster than getting all info I would get by doing ls -l ? (I am a noob 
wrt these things). And the ls-R cache is to even avoid fetching that 
list of names from the filesystem each time, to get even more performance.


> I feel unsure. Can you try an analogous "symlink search" in TEXMFLOCAL?

My TEXMFLOCAL is /opt/yann/texlive/texmf-local (and it has !! in the 
path setting). Putting a file there without mktexlsr'ing does not let 
kpsewhich find it, which iiuc is intended.

Putting a symlink to a file works after mktexlsr (ie. mktexlsr indexes it).

The same holds with a symlink to a folder containing a file, even if 
there is no folder in the folder (so that's different from TEXMFHOME, 
presumably because of mktexlsr's behaviour).

> Can you run a simple "symlink search" in TEXMFHOME under strace, and see
> what stat() is called on?

Attached is what happens when doing

kpsewhich thing2.sty

when that file is located in .../essai, a folder containing no folder 
and two files : thing.sty and thing2.sty.

Notice thing2.sty is stat'ed (probably because that is the requested 
file) but not thing.sty. If I add a dummy folder in essai, then 
thing.sty gets stat'ed. As intended.

Notice that we are stat'ing a lot of files anyway…

In fact I feel that the current behaviour brings a significant 
performance improvement when dealing with a folder that has no subfolder 
but a lot of files.

For example, there is no stat to files in 
/home/yann/texmf/tex/latex/descartes, which is actually a symlink to the 
repository containing files for producing my courses, but there are in 
/home/yann/texmf/tex/latex/nsi/, because in that repository we put the 
fonts in a subfolder.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kpse-stat.log
Type: text/x-log
Size: 7451 bytes
Desc: not available
URL: <https://tug.org/pipermail/tex-live/attachments/20220328/2c7bc55f/attachment.bin>


More information about the tex-live mailing list.