git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] Faster git grep.

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 25, 2013, 20:41 UTC
Message-ID
<7vli4u4bkm.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20130725182905.GA7664@domone.kolej.mff.cuni.cz>
Ondřej Bílka <neleai@seznam.cz> writes:
> One solution would be to use same trick as was done in google code. 
> Build and keep database of trigraphs and which files contain how many of
> them. When querry is made then check
> only these files that have appropriate combination of trigraphs.

This depends on how you go about trying to reducing the database overhead, I think. For example, a very naive approach would be to create such trigraph hit index for each and every commit for all paths. When "git grep $commit $pattern" is run, you would consult such table with $commit and potential trigraphs derived from the $pattern to grab the potential paths your hits _might_ be in.

But the contents of a path usually do not change in each and every commit. So you may want to instead index with the blob object names (i.e. which trigraphs appear in what blobs). But once you go that route, your "git grep $commit $pattern" needs to read and enumerate all the blobs that appear in $commit's tree, and see which blobs may potentially have hits. Then you would need to build an index every time you make a new commit for blobs whose trigraphs have not been counted.

Nice thing is that once a blob (or a commit for that matter) is created and its object name is known, its contents will not change, so you can index once and reuse it many times. But I am not yet convinced if pre-indexing is an overall win, compared to the cost of maintaining such a database.

Previous: Jeff KingNext: Ondřej Bílka
Message 3 of 6 in “[RFC] Faster git grep.”
  1. Ondřej BílkaJul 25, 2013
  2. Jeff KingJul 25, 2013
  3. Junio C HamanoJul 25, 2013
  4. Ondřej BílkaJul 25, 2013
  5. Junio C HamanoJul 26, 2013
  6. Ondřej BílkaJul 26, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.