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

Re: [PATCH] hash: reduce size of algo member of object ID

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Oct 5, 2021, 00:04 UTC
Message-ID
<YVuWfXqlpZxORS8p@camp.crustytoothpaste.net>
In-Reply-To
<YVq5XCyLDr0SPBzx@coredump.intra.peff.net>
On 2021-10-04 at 08:20:44, Jeff King wrote:
Show 5 quoted lines
> Oh wait, I'm reading it totally wrong. Adding in the extra 4 bytes
> actually made it _faster_ than not having an algo field. Now I'm
> super-confused. I could believe that it gave us some better alignment,
> but the original struct was 32 bytes. 36 seems like a strictly worse
> number.

My guess is that the increased alignment means that memcpy can perform much better. Just because x86 has "fast" unaligned access doesn't mean it's free; there remains a penalty for that, although other architectures which support unaligned access have much worse ones. memcpy and memcmp will perform better when they can use 32-bit chunks to read without having to process the potentially unaligned pieces at the beginning and end.

For the record, I have no particular stylistic opinion about whether we should adopt the proposed patch, but of course if it's faster as it is, we should probably leave it.

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Previous: Jeff KingNext: René Scharfe
Message 5 of 7 in “hash: reduce size of algo member of object ID”
  1. hash: reduce size of algo member of object IDRené Scharfe, Oct 3, 2021
  2. Eric WongOct 4, 2021
  3. Jeff KingOct 4, 2021
  4. Jeff KingOct 4, 2021
  5. brian m. carlsonOct 5, 2021
  6. René ScharfeOct 5, 2021
  7. Ævar Arnfjörð BjarmasonOct 4, 2021

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.