Skip to content
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

fix: optimize speed of retrieving user/group widths #1800

Closed
wants to merge 1 commit into from

Conversation

owallb
Copy link
Contributor

@owallb owallb commented Sep 14, 2024

After using the new user and group info parameters for a while I have started to notice an occasional slow-down, when quickly navigating down/up in the same directory.

I investigated the time it would take retrieve user and group max widths, where total is the whole getInfo loop:

Unoptimized, average over N=58, time in ms:

getUserWidth getGroupWidth Total
0.01 15.59 15.62

Optimized, average over N=80, time in ms:

getUserGroup Total
0.01 0.03

I'm not really sure why getGroupWidth was so slow.

15 ms is not slow enough that I would notice it, what I experienced was that the UI would freeze for about 1 second. But it's probably related to the cause of it.

@owallb
Copy link
Contributor Author

owallb commented Sep 14, 2024

I made a mistake and didn't call groupName for retrieving the group name. Now that I fixed it, the original issue still remains, which is that calling groupName will sometimes be very slow. I will close this and continue to investigate a different solution.

@owallb owallb closed this Sep 14, 2024
@owallb
Copy link
Contributor Author

owallb commented Sep 14, 2024

For future reference, the issue was that I had built with CGO_ENABLED=1. Instead building with CGO_ENABLED=0 fixed the random freezes. It seems the cgo implementation of LookupGroupId in os/user is slow for whatever reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant