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

Re: [PATCH v3 4/9] index-helper: new daemon for caching index and related stuff

From
Duy Nguyen <pclouds@gmail.com>
Date
Jul 30, 2014, 10:39 UTC
Message-ID
<CACsJy8Bngi8-eMSvNAPmT4_o4A_f1dq-Hs+dC7FNiVHNmoL7+g@mail.gmail.com>
In-Reply-To
<CAPig+cTDxTpo53WhfkQbt8EuY15Ttj1NHbh2Do-TKYq2xVvP+g@mail.gmail.com>
On Wed, Jul 30, 2014 at 3:08 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 13 quoted lines
>> +static void share_index(struct index_state *istate, struct index_shm *is)
>> +{
>> +       void *new_mmap;
>> +       if (istate->mmap_size <= 20 ||
>> +           hashcmp(istate->sha1,
>> +                   (unsigned char *)istate->mmap + istate->mmap_size - 20) ||
>> +           !hashcmp(istate->sha1, is->sha1) ||
>> +           git_shm_map(O_CREAT | O_EXCL | O_RDWR, 0700, istate->mmap_size,
>> +                       &new_mmap, PROT_READ | PROT_WRITE, MAP_SHARED,
>> +                       "git-index-%s", sha1_to_hex(istate->sha1)) < 0)
>
> Do any of these failure conditions deserve a diagnostic message to let
> the user know that there was a problem?

Hmm.. diagnostic messages are a problem already. This most likely runs as a daemon, nowhere to print to. But if running on foreground, some messages would help.

Show 11 quoted lines
>> +static int try_shm(struct index_state *istate)
>> +{
>> +       void *new_mmap = NULL;
>> +       size_t old_size = istate->mmap_size;
>
> Is old_size needed? Can you not simply reference istate->mmap_size
> directly each place old_size is mentioned?
>
>> +       ssize_t new_length;
>
> Nit: 'size' vs. 'length' inconsistency in variable name choices.
Leftovers after many iterations. Will fix.
Show 9 quoted lines
>> +#define SHM_PATH_LEN 72                /* we don't create very long paths.. */
>> +
>> +ssize_t git_shm_map(int oflag, int perm, ssize_t length, void **mmap,
>> +                   int prot, int flags, const char *fmt, ...)
>> +{
>> +       va_list ap;
>> +       char path[SHM_PATH_LEN];
>
> Is there a reason to avoid strbuf here?

Laziness (which is ironic as I'm working on patches to clean up fixed size buffers)

-- 
Duy
Previous: Eric SunshineNext: David Turner
Message 7 of 13 in “Speed up cache loading time”
  1. 0/9 Speed up cache loading timeNguyễn Thái Ngọc Duy, Jul 28, 2014
  2. 1/9 trace.c: add GIT_TRACE_PACK_STATS for pack usage statisticsNguyễn Thái Ngọc Duy, Jul 28, 2014
  3. 2/9 read-cache.c: fix constness of verify_hdr()Nguyễn Thái Ngọc Duy, Jul 28, 2014
  4. 3/9 read-cache: allow to keep mmap'd memory after readingNguyễn Thái Ngọc Duy, Jul 28, 2014
  5. 4/9 index-helper: new daemon for caching index and related stuffNguyễn Thái Ngọc Duy, Jul 28, 2014
  6. Eric SunshineJul 30, 2014
  7. Duy NguyenJul 30, 2014
  8. David TurnerJul 31, 2014
  9. 5/9 trace.c: add GIT_TRACE_INDEX_STATS for index statisticsNguyễn Thái Ngọc Duy, Jul 28, 2014
  10. 6/9 index-helper: add --strictNguyễn Thái Ngọc Duy, Jul 28, 2014
  11. 7/9 daemonize(): set a flag before exiting the main processNguyễn Thái Ngọc Duy, Jul 28, 2014
  12. 8/9 index-helper: add --detachNguyễn Thái Ngọc Duy, Jul 28, 2014
  13. 9/9 index-helper: add Windows supportNguyễn Thái Ngọc Duy, Jul 28, 2014

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.