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 #16 - Improving performance of profiles loading #18

Merged
merged 2 commits into from
Feb 26, 2023

Conversation

julien040
Copy link
Owner

@julien040 julien040 commented Feb 26, 2023

This pull request improves performance of gut.
Rather than loading all profiles on each launch, gut will load them only if the command requires it.

For example, status doesn't need to load any profiles. Before this pull request, gut would load all profiles even if it's not needed.

Changes done

To stop this behaviour, the ˋinit` function in the ˋprofileˋ package has been renamed.
This new function is now called on top of every exported functions of the package so that profiles are loaded when needed.
Note : the function won't run twice thanks to a global boolean variable.

Performance improvement over commands that doesn't require any profiles

This test not scientific at all has been run on Fedora on a DO 512MB ram VPS.

  1. Calling ˋgut` before the pull request
real    0m0.640s
user    0m0.040s
sys     0m0.028s
  1. Calling ˋgut` after the PR
real    0m0.100s
user    0m0.033s
sys     0m0.013s

On Linux, gut search for the path of Xorg to check if a GUI is available
If it returns an error, this means no GUI is available.
But this error must not be printed. It's only used to find out if a GUI is available
There is a lot of commands that doesn't require to load profiles
But because of how "init()" works, gut was loading every profiles and password before running the command.
This led to performance issues on Linux
@julien040 julien040 linked an issue Feb 26, 2023 that may be closed by this pull request
@julien040 julien040 marked this pull request as ready for review February 26, 2023 18:35
@julien040 julien040 self-assigned this Feb 26, 2023
@julien040 julien040 merged commit c8c8277 into main Feb 26, 2023
@julien040 julien040 deleted the fix/performance-profile branch February 26, 2023 18:42
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.

Performance on Linux - Profile loaded every time
1 participant