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

Re: [PATCH v1 2/5] Teach git to optionally utilize a file system monitor to speed up detecting new or changed files.

From
Jeff King <peff@peff.net>
Date
May 16, 2017, 17:49 UTC
Message-ID
<20170516174948.arqbk533pihm6x46@sigill.intra.peff.net>
In-Reply-To
<29122818-71fb-5af9-59b1-03387f014151@gmail.com>
On Tue, May 16, 2017 at 01:17:56PM -0400, Ben Peart wrote:
Show 25 quoted lines
> > Thanks for the pointers.  I'll update this to use the existing get_be32
> > and have created a get_be64 and will use that for the last_update.
> 
> OK, now I'm confused as to the best path for adding a get_be64.  This one is
> trivial:
> 
> #define get_be64(p)	ntohll(*(uint64_t *)(p))
> 
> but should the unaligned version be:
> 
> #define get_be64(p)	( \
> 	(*((unsigned char *)(p) + 0) << 56) | \
> 	(*((unsigned char *)(p) + 1) << 48) | \
> 	(*((unsigned char *)(p) + 2) << 40) | \
> 	(*((unsigned char *)(p) + 3) << 32) | \
> 	(*((unsigned char *)(p) + 4) << 24) | \
> 	(*((unsigned char *)(p) + 5) << 16) | \
> 	(*((unsigned char *)(p) + 6) <<  8) | \
> 	(*((unsigned char *)(p) + 7) <<  0) )
> 
> or would it be better to do it like this:
> 
> #define get_be64(p)	( \
> 	((uint64_t)get_be32((unsigned char *)(p) + 0) << 32) | \
> 	((uint64_t)get_be32((unsigned char *)(p) + 4) <<  0)

I'd imagine the compiler would generate quite similar code between the two, and the second is much shorter and easier to read, so I'd probably prefer it.

> or with a static inline function like git_bswap64:

Try "git log -Sinline compat/bswap.h", which turns up the history of why it went from a macro to an inline function.

The get_be macros are simple enough that they can remain as macros, though I'd have no objection personally to them being inline functions. I'd expect modern compilers to be able to optimize similarly, and it removes the restriction that you can't call the macro with an argument that has side effects.

-Peff
Previous: Ben PeartNext: Johannes Sixt
Message 18 of 26 in “Fast git status via a file system watcher”
  1. 0/5 Fast git status via a file system watcherBen Peart, May 15, 2017
  2. 1/5 dir: make lookup_untracked() available outside of dir.cBen Peart, May 15, 2017
  3. Junio C HamanoMay 16, 2017
  4. 3/5 fsmonitor: add test cases for fsmonitor extensionBen Peart, May 15, 2017
  5. Junio C HamanoMay 16, 2017
  6. Ben PeartMay 16, 2017
  7. 5/5 Add a sample query-fsmonitor hook script that integrates with the cross platform Watchman file watching service.Ben Peart, May 15, 2017
  8. David TurnerMay 15, 2017
  9. Ben PeartMay 15, 2017
  10. 2/5 Teach git to optionally utilize a file system monitor to speed up detecting new or changed files.Ben Peart, May 15, 2017
  11. David TurnerMay 15, 2017
  12. Ben PeartMay 16, 2017
  13. brian m. carlsonMay 16, 2017
  14. Jeff KingMay 16, 2017
  15. Ben PeartMay 16, 2017
  16. Jeff KingMay 16, 2017
  17. Ben PeartMay 16, 2017
  18. Jeff KingMay 16, 2017
  19. Johannes SixtMay 16, 2017
  20. Ben PeartMay 17, 2017
  21. Johannes SixtMay 17, 2017
  22. Jeff KingMay 18, 2017
  23. Jonathan TanMay 16, 2017
  24. Ben PeartMay 17, 2017
  25. 4/5 Add documentation for the fsmonitor extension. This includes the core.fsmonitor setting, the query-fsmonitor hook, and the fsmonitor index extension.Ben Peart, May 15, 2017
  26. Junio C HamanoMay 16, 2017

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.