[OS X TeX] Time penalty when using kpsewhich on mac os x?
Adam R. Maxwell
amaxwell at mac.com
Sat Oct 11 17:02:48 EDT 2014
Jean-Francois,
I tried profiling kpsewhich, and it looks like the speed hit
is almost entirely related to using locks (which getc(3)
does by default). We ran into this years ago with BibDesk,
and worked around it by using getc_unlocked(3), which is also
in POSIX.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getc_unlocked.html
Karl, can kpsewhich be compiled separately from TL? It'd be
interesting to play with this (assuming it only uses a single
thread, so getc_unlocked is safe).
To reproduce this, type the following in one Terminal and
hit return:
$ sample kpsewhich -wait -mayDie -e
In another Terminal, run the kpsewhich command:
$ kpsewhich -var-value=TEXMFLOCAL
###########
Analysis of sampling kpsewhich (pid 1855) every 1 millisecond
Process: kpsewhich [1855]
Path: /usr/local/texlive/2014/bin/universal-darwin/kpsewhich
Load Address: 0x1000
Identifier: kpsewhich
Version: ???
Code Type: X86
Parent Process: bash [411]
Date/Time: 2014-10-11 13:50:58.688 -0700
OS Version: Mac OS X 10.10 (14A388a)
Report Version: 7
Analysis Tool: /usr/bin/sample
----
Call graph:
519 Thread_558129 DispatchQueue_1: com.apple.main-thread (serial)
519 ??? (in kpsewhich) load address 0x1000 + 0x1206 [0x2206]
519 ??? (in kpsewhich) load address 0x1000 + 0x1fb6 [0x2fb6]
519 ??? (in kpsewhich) load address 0x1000 + 0xf89c [0x1089c]
519 ??? (in kpsewhich) load address 0x1000 + 0x76b7 [0x86b7]
313 ??? (in kpsewhich) load address 0x1000 + 0x8714 [0x9714]
+ 286 ??? (in kpsewhich) load address 0x1000 + 0xb21b [0xc21b]
+ ! 135 getc (in libsystem_c.dylib) + 62 [0x930a7a5d]
+ ! : 126 funlockfile (in libsystem_c.dylib) + 23 [0x930a470a]
+ ! : | 108 pthread_mutex_unlock (in libsystem_pthread.dylib) + 67 [0x968546e8]
+ ! : | + 55 __mtx_droplock (in libsystem_pthread.dylib) + 81,112,... [0x96854834,0x96854853,...]
+ ! : | + 52 OSAtomicCompareAndSwap64Barrier$VARIANT$mp (in libsystem_platform.dylib) + 26,0,... [0x944c038a,0x944c0370,...]
More information about the MacOSX-TeX
mailing list