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

POC brew grep command #35

Closed
wants to merge 1 commit into from
Closed

Conversation

apainintheneck
Copy link
Owner

@apainintheneck apainintheneck commented Nov 26, 2023

Tangentially related to Homebrew/brew#16237

This is an exploration of statically parsing the cask/formula files using grep + regexes to see if it is fast enough to allow us to parse that information on the fly each time and see if it's accurate enough to make the old command obsolete. The old technique required caching descriptions which is extra complexity and can be a security risk since it means that all package files are evaluated.

As is this is super hacky but it does show that this is a viable solution to the problem.

$ brew grep blue
==> Formulae
blazegraph: Graph database supporting RDF data model, Sesame, and Blueprint APIs
bluepill: Testing tool for iOS that runs UI tests using multiple simulators
bluetoothconnector: Connect and disconnect Bluetooth devices
blueutil: Get/set bluetooth power and discoverable state
drafter: Native C/C++ API Blueprint Parser
hidapi: Library for communicating with USB and Bluetooth HID devices
libbtbb: Bluetooth baseband decoding library

==> Casks
font-bigblue-terminal-nerd-font: (BigBlueTerm Nerd Font families (BigBlue Terminal)) Developer targeted fonts with a high number of glyphs
airunlock: (AirUnlock) Tool to lock or unlock the macbook using an Android phone via Bluetooth
bleunlock: (BLEUnlock) Lock/unlock Apple computers using the proximity of a bluetooth low energy device
bluebubbles: (BlueBubbles) Server for forwarding iMessages
bluefish: (Bluefish) Open source code editor
bluegriffon: (BlueGriffon) Web and EPUB editor
blueharvest: (BlueHarvest) Remove metadata files from external drives
bluej: (BlueJ) Java Development Environment designed for beginners
bluejeans: (BlueJeans) Video conferencing for the digital workplace
bluesense: (BlueSense) Detect the presence of your Bluetooth device
bluesnooze: (Bluesnooze) Prevents your sleeping computer from connecting to Bluetooth accessories
bluestacks: (BlueStacks) Mobile gaming platform
bluetility: (Bluetility) Bluetooth Low Energy browser
bluewallet: (BlueWallet) Bitcoin wallet and Lightning wallet
bubo: (Bubo, Spotify Bluetooth Headset Listener) Fixes broken bluetooth headset control
flic: (Flic) Driver for the Flic bluetooth button
grs-bluewallet: (GRS BlueWallet) Groestlcoin wallet and Lightning wallet
iris: (Iris) Blue light filter and eye protection software
usb-overdrive: (USB Overdrive) USB and Bluetooth device driver

This is slower than the current brew desc command but not by much and this new command doesn't used cached data at all. The main worry here would be performance though.

$ hyperfine 'brew desc --search --eval-all server' 'brew grep server'
Benchmark 1: brew desc --search --eval-all server
  Time (mean ± σ):      3.095 s ±  0.099 s    [User: 1.893 s, System: 1.013 s]
  Range (min … max):    3.018 s …  3.317 s    10 runs
 
Benchmark 2: brew grep server
  Time (mean ± σ):      3.564 s ±  0.023 s    [User: 2.111 s, System: 2.114 s]
  Range (min … max):    3.540 s …  3.602 s    10 runs
 
Summary
  brew desc --search --eval-all server ran
    1.15 ± 0.04 times faster than brew grep server

This is an exploration of statically parsing the cask/formula files
using grep + regexes to if we it is fast enough to allow us to parse
that information on the fly each time and see if it's accurate enough
to make the old command obsolete. The old technique required caching
descriptions which is extra complexity and is a security risk since
it means that all package files are evaluated.

As is this is super hacky but it does show that this is a viable
solution to the problem.
@apainintheneck
Copy link
Owner Author

Closes #32

@apainintheneck
Copy link
Owner Author

Closing because this was mostly just a POC and isn't actually something that I think is actually needed here.

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.

None yet

1 participant