[tex-k] Speed of kpsewhich when querying the repertories of the TeX installation

Norbert Preining preining at logic.at
Fri May 1 09:10:17 CEST 2015


Hi,

> > * reading the main texmf.cnf
> > * searching for other texmf.cnf
> > * evaluating their contents
> > there is only hard coded path, and that is a no-go.
> > 
> 
> There must be at least one initial hard-coded path no? I can't
> relocate kpsewhich anywhere on my system or can I ?

You can relocate, check the installation of TeX Live, you can
choose whereever you want.

kpsewhich searches for the initial texmf.cnf in a (long) list
of defined locations, that allows for relocation, plus some
fixed locations.

> Are you sure kpsewhich does not do, apart from evaluating the
> contents of the texmf.cnf files, do some un-needed parsing of ls-R

Of course it does ls-R parsing, but it is not unneeded. Because 
the ls-R is used to find the other files, including other texmf.cnf
files (as far as I know).

So yes of course it parses, but it is not unnecessary.

> files, I mean unneeded when kpsewhich is invoked as kpsewhich
> --expand-path $TEXMFHOME (or whatever)?

And how is kpsewhich supposed to find all texmf.cnf files that might
change the behaviour?

> This is why I suggested providing a separate utility to provide
> only that service of identifying the locations of the repertories:
> where is the DIST tree?, where is the LOCAL tree?, where is the
> HOME tree?

The problem is you *CANNOT* decide it without the full parsing.

It is like TeX (well, not really), you need a full parser to
provide the same feature.

> It appears that there is no issue if the user has set-up
> corresponding environment variables.

Of course not, there is always a shortcut in this case, as Karl
stated.

> But in that cas TeXLive installation's manual should be explicit
> about it. I am sure this brings other complications.

For what? How many kpsewhich calls a user does in his *whole*life*,
I am wondering ....

> TEXMF_local = $(shell kpsewhich -var-value TEXMFLOCAL)
> 
> # as kpsewhich is very slow (.5s) I want to evaluate once only.
> installlocal: xint.tds.zip
> 	$(eval $@_tmp := $(TEXMF_local))
> 	unzip xint.tds.zip -d $($@_tmp) && texhash $($@_tmp)

Scrapping .5s from an *install* routine that is called *once*
every whatever, weeks, months?

If you don't have *any* other problem you must be happy.

Try instead improving the TeX parsing speed, that is *much* more
effective support for everyone.

> If I resuscitated this issue after some months, it is because I
> discovered yesterday that Emacs/AUCTeX 11.88 on Mac OS X very
> lengthy launch was entirely to be explained by its nine calls to
> kpsewhich.

According to your statement, 9 * 0.2 sec is about 1.8sec. Taking
caching of the ls-R from the OS into account, my guess is that
the actual time spent in kpsewhich calls is about 1.5sec.

IF you are so conservative about it, why not add to your .profile:
	TEXMFLOCAL=$(kpsewhich -var-value TEXMFLOCAL)
	TEXMFHOME=$(kpsewhich -var-value TEXMFHOME)
	export TEXFMLOCAL TEXMFHOME
and all will be hell of a speed fast....

Isn't that the simplest solution for all your problems?

> Earlier AUCTeX 11.86 did only 2, and furthermore it happened
> during initial launch of Emacs, not on (first) opening a .tex file
> 
> With 9 calls to kpsewhich, on my (comparatively quite fast, with
> SSD) MBA with Mavericks and TeXLive 2014, this meant a 5 seconds
> wait when first launching AUCTeX 11.88

End after that? 0 .. right. Aehmmm, well.

> 
> On an older Mac machine, as the one Adam Maxwell tested my October
> 2014 findings about the slowness of kpsewhich --var-value
> TEXMFHOME, it would have been 15 seconds.

15sec??? I would be surprised, that must be a very bad machine that
loading a ls-R file into memory and parsing it takes that much
time.

> Let me explicitely mention to people reading this thread that this
> issue does concern also Linux boxes, but may well be hidden to
> most because their TeXLive installation has set-up environment
> variables for TEXMFLOCAL, TEXMFHOME, etc...

As the main dev of the TeX Live infra, I am running several installation
of TeX Live, and I do NOT have *any* env variable. As a logician and
mathematician I am editing TeX files in Emcas with AucTeX on a daily 
basis, and never had the feeling that *this* is the prbolems.

As said above, there is no fast way unless you do something like
a server. But that needs to monitor the file system for changes
in the texmf.cnf files, and this is something that nobody wants to
do for kpsewhcih calls ...

Norbert

------------------------------------------------------------------------
PREINING, Norbert                               http://www.preining.info
JAIST, Japan                                 TeX Live & Debian Developer
GPG: 0x860CDC13   fp: F7D8 A928 26E3 16A1 9FA0  ACF0 6CAC A448 860C DC13
------------------------------------------------------------------------


More information about the tex-k mailing list