-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Improve performance of brew cask list #1416
Conversation
@hanxue Please add tests 😄 |
@nanoxd Sorry, I am a newbie here. Is there an example I can start from? How can I invoke Cask::Locations.caskroom from within list.rb's self.run method? |
The current tests are here and they use the following to run the list command: lambda { Cask::CLI::List.run } |
You can load the code into a REPL like IRB or Pry |
% It's hard to believe it was once even slower - has this regressed?
|
@paulp it's possible that the recent Tap migration changes made it worse. Probably the fundamental culprit is trying to match Homebrew semantics exactly. That might not even be necessary. I never saw this issue the first time around. I'm re-opening it as a reminder to look into this. |
I'm sure that corner cases abound somewhere, but for what it is worth, on my machine the output of the 3ms ls -1 is identical to that of the 3497ms brew cask list. |
Or for columns, unix is still there for us.
|
The perf issue arises from the fact that each installed Cask definition is loaded. (Load failures are annotated with the For this use case, we can tell |
I've seen the (!)s before, but it was very unclear what I was expected to do with that knowledge. You mean the ! means there's something wrong with the formula of an installed cask? Why would this occur in the normal course of events, and how does it bear on which casks I have installed? I think when people say "list" they are looking for the list of installed casks, and not looking to perform verification on the cask infrastructure - especially not super-expensive verification, every time. |
I guess I wasn't very clear above. Instantiating a Cask isn't expensive. The Thanks for bringing the problem to my attention. |
See Issue #911 for original bug. This hack will list the contents of Caskroom. This should work reasonably well because the directory name of the installed cask is exactly the same as the cask name.
TODO: Use Cask::Locations::caskroom instead of absolute path name
I don't know how to use Cask::Locations::caskroom, can someone patch instead?
The previous commit has
*arguments
does not seem to be used. Can it be removed, so that there is no need to wrap the code inif-else
?