-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reuse FileType from DirEntry #833
Conversation
There are some very insightful ideas here, particularly around the style/theme-ing. I've been working on the config/theme file, which required a pretty huge refactor in this area, so I think it would be a good time to implement some of these ideas. Excuse me if this sounds like a stupid idea, as I haven't gotten much sleep. But if the check for an executable file is seemingly what is responsible for fetching the full metadata when we otherwise wouldn't be, if the majority of other files are styled based off their extensions, could we simply apply some base style to the files, and only style executable files by their permission, which we would have anyway as it's part of the EDIT: I understand this would indeed change the current behavior, but on windows anyway, they could be styled by file extension instead, although I have no clue about windows in general 😅 |
@PThorpe92 I never responded, how rude of me! Yes, with this change, there will be a single statx call for the styling and the permissions if I'm still unsure what would be a good solution here (maybe there is none except providing themes that would be faster/slower depending on what the user wants). |
2e4c3f5
to
8ddefc9
Compare
How close are we to merging this? |
I'm so confused about what git has done 😄 |
1fe7310
to
f43124b
Compare
999f2ec
to
c2b9344
Compare
Here are some benchmarks using hyperfine:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, I just got done reviewing the code, and it looks good to me.
The ~23% speed increase is very appreciated :D
This is a draft because I made this PR more to spark some conversation than to actually change the code. It could still be merged if I clean it up but (spoiler alert) the improvement is very small for now. So here goes.
eza
is super fancy, but sometimes quite slow. As seen in some issues and discussions:(and probably some more, I've only started tracking this recently)
This is not necessarily a problem: as I understand it,
eza
is meant for fancy output first and fast output second. It fulfills the promise of being fancy very well and that fanciness sets it apart from e.g. GNU (and uutils)ls
. Still, the fact that complains are coming in shows that people would likeeza
to be faster.Now, I've done a bunch of work on uutils
ls
, including performance work, so I figured I'd share some of my experience. In my experience, it's quite hard to getls
-like programs to a low number of syscalls. If you want to try this for yourself, compare these commands (on Linux):Here's the top of both, first
eza
:and then GNU
ls
:You can see that
eza
spends a lot of time on syscalls that's probably not necessary!So, I set out to see if I could reduce that with a similar technique as we used in uutils
ls
: retrieving metadata and filetype only when necessary. In code, it's similar to how the extended attributes and canonicalized name are computed with aOnceLock
. Now there are two options:DirEntry
, which already contains aFileType
, so if we have that, we can often skip getting the metadata.So I implemented that and the number of statx calls from running
eza
on its own repository went from 33 to... 23. Not quite what I had hoped. Turns out that's because on every regular file,eza
wants to know whether the file is executable, which requires the full metadata. Removing that check drops the statx calls to 0, which I think would lead to a measurable speedup, but I've left that out of this PR, because that would changeeza
's behaviour.This all raises some interesting questions (which are probably worth spinning off into an issue):
readlink
/getcwd
calls for? They take up a lot of time and are probably unnecessary.eza
even more with--color=never
.Hope this all makes sense :)