fastfetch-cli / fastfetch

An actively maintained, feature-rich and performance oriented, neofetch like system information tool.
MIT License
8.08k stars 349 forks source link

Packages (Linux): Improve speed of Guix package detection. #999

Closed Dariqq closed 4 weeks ago

Dariqq commented 4 weeks ago

Here is logic of your first code. There was not much I needed to do.

Compared to it I've renamed the argument to filename to be more explicit what it acts on, have replaced the last memcmp call with compare32 and added the comment from my first try to try to explain what the code should do.

Thanks for helping me with this, I have added you as Co-author because you did almost everything.

Haven't tested how it interacts which edge cases (like malformed manifest files) as these are symlinked from a read-only filesystem and i figured if this happens problems with fastfetch are probably not the top priority.

Speed wise it is now much faster from the 200-300ms total to ~5ms and the count is at a lot more accurate (but still not perfect) as (transitive) dependencies of installed packages are now also counted.

Closes #988.

CarterLi commented 4 weeks ago

What about renaming compare32 to compareHash

Dariqq commented 4 weeks ago

What about renaming compare32 to compareHash

Done.

Dariqq commented 4 weeks ago

Awesome. Thanks again for your help :)

CarterLi commented 4 weeks ago

Do you know how can I submit fastfetch to GNU guix repo?

Dariqq commented 4 weeks ago

https://guix.gnu.org/manual/devel/en/html_node/Contributing.html.

The tldr is: Create a patch for the guix repo and mail it to guix-patches@gnu.org.

I have a (somewhat) working package definition locally (which I used to test these changes) but it is a bit thrown together eg fastfetch cant find the extra dependencies at runtime yet. Also almost surely all the vendored dependencies would need to be packaged seperately.

CarterLi commented 4 weeks ago

I have a (somewhat) working package definition locally

Good

fastfetch cant find the extra dependencies at runtime yet

Maybe CMake failed to find these deps. You need to make sure that CMake prints Library: found XXX when configuring and fastfetch --list-features prints expected features.

Dariqq commented 4 weeks ago

cmake/pkgconfig finds them fine during build.

{
    "type": "Vulkan",
    "error": "dlopen libvulkan.so failed",
    "stat": 0
  },
  {
    "type": "OpenGL",
    "error": "dlopen glx failed",
    "stat": 1
  },
  {
    "type": "OpenCL",
    "error": "dlopen libOpenCL.so failed",
    "stat": 0
  },
...
  {
    "type": "Bluetooth",
    "error": "Failed to load DBus library",
    "stat": 0
  },
  {
    "type": "Sound",
    "error": "Failed to load libpulse.so",
    "stat": 0
  },
CarterLi commented 4 weeks ago

What does lurk or strace print?

Dariqq commented 4 weeks ago

Probably because these are not in the default path? Nix seems to wrap with LD_LIBRARY_PATH, maybe I need something similiar

EDIT: That seems to work. But currently it is a bit ugly as I write out the LD_LIBRARY_PATH manually


openat(AT_FDCWD, "/gnu/store/71clg810lzlv7xw6qmapb2353jjqgjxw-fastfetch-2.14.0/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
newfstatat(4, "", {st_mode=S_IFREG|0444, st_size=5555, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 5555, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7f8ca9377000
close(4)                                = 0
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
munmap(0x7f8ca9377000, 5555)            = 0
openat(AT_FDCWD, "/gnu/store/71clg810lzlv7xw6qmapb2353jjqgjxw-fastfetch-2.14.0/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
newfstatat(4, "", {st_mode=S_IFREG|0444, st_size=5555, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 5555, PROT_READ, MAP_PRIVATE, 4, 0) = 0x7f8ca9377000
close(4)                                = 0
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/6ncav55lbk5kqvwwflrzcr41hp5jbq0c-gcc-11.3.0-lib/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/lib/libpulse.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
munmap(0x7f8ca9377000, 5555)            = 0
write(1, "Sound", 5)                    = 5
write(1, ": ", 2)                       = 2
write(1, "Failed to load libpulse.so", 26) = 26
``
CarterLi commented 4 days ago

Just saw someone submitted fastfetch to guix repo with a few features enabled but no LD_LIBRARY_PATH set

https://git.savannah.gnu.org/cgit/guix.git/commit/?id=ddb0401d82be8b1a43b6f47fb5794d08119f8d54

Does it really work?

Dariqq commented 4 days ago

I am not quite happy with the package yet.

Everything that does not need use the external libraries works.

However I am getting some errors when the guix fastfetch tries to dlopen the external libraries:

Bluetooth: Failed to load DBus library
OpenGL: dlopen egl failed

and strace suggests it is the LD_LIBRARY_PATH issue again.

Can look into submitting a patch later this week. Writing out the LIBRARY_PATH manually is kind of awkward. Dynamic linking seems to work without manual intervention.