Commit graph

8 commits

Author SHA1 Message Date
Félix Baylac Jacqué 97e35d20fa Rename nixglhost_wrapper -> nixglhost 2022-12-14 19:20:31 +01:00
Félix Baylac Jacqué 3ff2f01812 Hot Cache: use the DSO last write time/size instead of content hash
After profiling a nixglhost hot run, it turns out that we were
spending more than 98% of the run time reading and sha256-hashing
files.

Let's give up on content hashing the files and assume that using their
name, size and last write time is good enough.

On a hot run, we reduce the run time from about 3s to 0.3s on a
nvme-powered ryzen 7 desktop.

I guess this 10x speedup probably worth the little cache corectness we
lose on the way.
2022-12-14 19:20:10 +01:00
Félix Baylac Jacqué 61a5fcdae8 Re-thinking the host library auto detection mechanism.
We made the incorrect assumption that the first DSO we'd stumble upon
in the load path would be the most appropriate one for the host
system. IE. it'd be the x86_64-gnu-linux on such a system. It turned
out not being the case, meaning we can't take such a shortcut and have
to handle the case where we end up with multiple same libraries for
different archs.

This forced us to do two things:

1. It forced us to rethink the cache directory structure. We now have
   to cache each library directory separately. Meaning we now have to
   inject the GLX/EGL/Cuda directories of *all* these library
   directories subpaths to the LD_LIBRARY_PATH. The dynamic linker
   will then try to open these DSOs (and fail) until it stumble upon
   the appropriate one.
2. We had to give up on the way we injected EGL libraries using
   asolute paths. We don't know which DSO is adapted to the wrapped
   program arch. Instead of injecting the absolute paths through the
   JSON configuration files, we just stipulate the libraries names in
   them. We then inject the various EGL DSOs we find through the
   LD_LIBRARY_PATH, similarly to what we already do for GLX and Cuda.
2022-12-14 14:32:54 +01:00
Félix Baylac Jacqué 19ae538413 Add a flag to print the nix-gl-host LD_LIBRARY_PATH
In some situations, such as environment setup scripts, we'd like to
print the nix-gl-host LD_LIBRARY_PATH instead of running a binary.
2022-12-06 18:06:41 +01:00
Ivor Wanders 95456b5ed1 Make the copied library writable.
We need to make sure the library is writable before trying to patchelf
it.
2022-12-06 10:54:21 +01:00
Félix Baylac Jacqué 8e93fe5dea DSO search: Add escape hatch
We add a -d/--driver-directory flag allowing the user to circomvent
the DSO automatic lookup and instead force nix-gl-host to load its
dynamic libraries from a specific directory.
2022-12-05 15:34:29 +01:00
Félix Baylac Jacqué d020c8f4fe Exec: search for executables in the PATH
Using execvp instead of execv. It'll look for the binary in PATH if
the bin_path provided is not an explicit path.
2022-12-05 15:30:43 +01:00
Félix Baylac Jacqué 375148c949 Introduce a cache system
Copying & patching all the DSOs is a time consuming process (~10s on a
slow hard drive computer). We definitely don't want to go through it
for each process start, we need to introduce a cache.

For this cache, we go the concervative way. We're going to "resolve" a
DSO name (ie. find the DSO absolute path) and sha256-hash each DSO.
We're then going to compare the fingerprints to determine whether or
not we need to nuke and rebuild the DSO cache.

The cache state is persisted through a JSON file saved in the cache dir.
2022-12-05 13:33:01 +01:00
Renamed from nixglhost-wrapper.py (Browse further)