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

[PATCH 1/4] pack-objects: mark add_to_write_order() as inline

From
Dan McGee <dpmcgee@gmail.com>
Date
Oct 18, 2011, 05:21 UTC
Message-ID
<1318915284-6361-1-git-send-email-dpmcgee@gmail.com>

This function is a whole 26 bytes when compiled on x86_64, but is currently invoked over 1.037 billion times when running pack-objects on the Linux kernel git repository. This is hitting the point where micro-optimizations do make a difference, and inlining it only increases the object file size by 38 bytes.

As reported by perf, this dropped task-clock from 84183 to 83373 ms, and total cycles from 223.5 billion to 221.6 billion. Not astronomical, but worth getting for adding one word.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
---
 builtin/pack-objects.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 2b18de5..0ab3a3b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -454,7 +454,7 @@ static int mark_tagged(const char *path, const unsigned char *sha1, int flag,
 	return 0;
 }
 
-static void add_to_write_order(struct object_entry **wo,
+static inline void add_to_write_order(struct object_entry **wo,
 			       int *endp,
 			       struct object_entry *e)
 {
-- 
1.7.7
Next: Dan McGee
Message 1 of 10 in “pack-objects: mark add_to_write_order() as inline”
  1. 1/4 pack-objects: mark add_to_write_order() as inlineDan McGee, Oct 18, 2011
  2. 2/4 pack-objects: use unsigned int for counter and offset valuesDan McGee, Oct 18, 2011
  3. 3/4 pack-objects: don't traverse objects unnecessarilyDan McGee, Oct 18, 2011
  4. Junio C HamanoOct 27, 2011
  5. Dan McGeeNov 9, 2011
  6. Junio C HamanoNov 12, 2011
  7. Dan McGeeNov 13, 2011
  8. Junio C HamanoNov 14, 2011
  9. 4/4 pack-objects: rewrite add_descendants_to_write_order() iterativelyDan McGee, Oct 18, 2011
  10. Junio C HamanoOct 27, 2011

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.