I did some profiling of lit while trying to optimize the libc++ test
startup for remote hosts and it turns out that there is a realpath() call
for every message printed and this shows up in the profile.
The inspect.getframeinfo() function calls realpath() internally and
moreover we don't need most of the other information returned from it.
This patch uses inspect.getsourcefile() and os.path.normpath to remove
../ from the path instead. Not resolving symlinks reduces the startup time
for running a single test with lit by about 50ms for me.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Just making sure I understand:
This is an implementation detail only and the message format stays the same (and it works on all platforms).
The only difference in behavior is that we don't resolve symlinks anymore; and we don't care about that.
LGTM, if the above is true.
Thanks!
llvm/utils/lit/lit/LitConfig.py | ||
---|---|---|
168–171 | I don't think you need to call normpath() after calling abspath(). From the Python docs:
|
llvm/utils/lit/lit/LitConfig.py | ||
---|---|---|
168–171 | Thanks I didn't read the docs and just assumed it would behave the same as pathlib Path.absolute(): >>> os.chdir("/usr/bin"); (os.getcwd(), os.path.abspath(".."), Path("..").absolute()) ('/usr/bin', '/usr', PosixPath('/usr/bin/..')) |
llvm/utils/lit/lit/LitConfig.py | ||
---|---|---|
168–171 | Good catch, thanks Louis! |
I don't think you need to call normpath() after calling abspath(). From the Python docs: