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

Re: [PATCH 1/1] compat: modernize and simplify byte swapping functions

From
Jeff King <peff@peff.net>
Date
Jan 2, 2026, 06:16 UTC
Message-ID
<20260102061626.GA2581074@coredump.intra.peff.net>
In-Reply-To
<20260102002735.31390-2-rostiprodev@gmail.com>
On Fri, Jan 02, 2026 at 02:27:35AM +0200, Rostislav Krasny wrote:
> Replace manual bit operations with memcpy + network functions for better
> maintainability. Add missing 16-bit network byte order conversion.

This is burying the lede a bit, as they say. I don't know that the maintainability is much changed, especially as these are not functions that anybody looks at or touches very often.

But this part might be compelling:
> - Performance improvements (GCC 15.2.1, Clang 21.1.7):
>   * on x86-64 with -O0 4.2x faster (GCC), 3.7x faster (Clang)
>   * on x86-64 with -O1 4x faster (GCC), identical (Clang)
>   * on x86-64 with -O2 identical (GCC), 1.8x faster (Clang)

The -O0 numbers are IMHO not very interesting (and are entirely expected; you are comparing optimized library memcpy versus unoptimized assignments). But clang making -O2 faster is quite interesting.

If we are going to do this, I think it would be for the improved performance. And it would be nice for the commit message to go into details about what was measured and how. I'll respond elsewhere in the thread with some more thoughts.

-Peff
Previous: Rostislav KrasnyNext: Rostislav Krasny
Message 3 of 7 in “compat: modernize and simplify byte swapping functions”
  1. 0/1 compat: modernize and simplify byte swapping functionsRostislav Krasny, Jan 2, 2026
  2. 1/1 compat: modernize and simplify byte swapping functionsRostislav Krasny, Jan 2, 2026
  3. Jeff KingJan 2, 2026
  4. Rostislav KrasnyJan 2, 2026
  5. Rostislav KrasnyJan 11, 2026
  6. Jeff KingJan 14, 2026
  7. Jeff KingJan 2, 2026

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.