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

Re: [PATCH v2 7/7] trace2: make SIDs more unique

From
JHJeff Hostetler <git@jeffhostetler.com>
Date
Apr 1, 2019, 21:16 UTC
Message-ID
<5a507e32-cf84-21c9-4ffe-246ecef49370@jeffhostetler.com>
In-Reply-To
<87lg0x9voz.fsf@evledraar.gmail.com>
On 3/29/2019 6:12 PM, Ævar Arnfjörð Bjarmason wrote:
Show 57 quoted lines
> 
> On Fri, Mar 29 2019, Jeff Hostetler via GitGitGadget wrote:
> 
>> From: Jeff Hostetler <jeffhost@microsoft.com>
>>
>> Update SID component construction to use the current UTC datetime
>> and a portion of the SHA1 of the hostname.
>>
>> Use an simplified date/time format to make it easier to use the
>> SID component as a logfile filename.
>> [...]
>> +static void tr2_sid_append_my_sid_component(void)
>> +{
>> +	const struct git_hash_algo *algo = &hash_algos[GIT_HASH_SHA1];
>> +	struct tr2_tbuf tb_now;
>> +	git_hash_ctx ctx;
>> +	unsigned char hash[GIT_MAX_RAWSZ + 1];
>> +	char hex[GIT_MAX_HEXSZ + 1];
>> +	char hostname[HOST_NAME_MAX + 1];
>> +
>> +	tr2_tbuf_utc_datetime_for_filename(&tb_now);
>> +	strbuf_addstr(&tr2sid_buf, tb_now.buf);
>> +	strbuf_addch(&tr2sid_buf, '-');
>> +
>> +	if (xgethostname(hostname, sizeof(hostname)))
>> +		xsnprintf(hostname, sizeof(hostname), "localhost");
>> +
>> +	algo->init_fn(&ctx);
>> +	algo->update_fn(&ctx, hostname, strlen(hostname));
>> +	algo->final_fn(hash, &ctx);
>> +	hash_to_hex_algop_r(hex, hash, algo);
>> +	strbuf_add(&tr2sid_buf, hex, 8);
>> +
>> +	strbuf_addch(&tr2sid_buf, '-');
>> +	strbuf_addf(&tr2sid_buf, "%06"PRIuMAX, (uintmax_t)getpid());
>> +}
>> +
> 
> Thanks for turning my shitty half-formed idea into a patch :)
> 
> I wrote this on top to bikeshed this a bit further, wonder what you
> think:
> https://github.com/gitgitgadget/git/compare/pr-169/jeffhostetler/core-tr2-startup-and-sysenv-v2...avar:pr-169/jeffhostetler/core-tr2-startup-and-sysenv-v2
> 
> So e.g.:
> 
>      Before: 20190329-220413-446441-c2f5b994-018702
>      After:  20190329T220431.244562Z-Hc2f5b994-P19812F
> 
> I.e:
> 
>   * Using <date>T<time> as is ISO 8601 convention/easier to read
> 
>   * <dateime>.<microseconds>Z, so seperating with "." to indicate it's
>     the same value + add "Z" for "it's UTC". I'm least sure about the
>     ".". Is that going to cause issues on Windows these days (the rest
>     being the "extension"...).

I had a version that did just that. I checked the various ISO and RFCs and it seems like the fractional seconds is usually allowed between the whole seconds and the "Z".

I've not seen any problems with that format.

I think I got spooked by your original suggestion to put the fraction in a term after the whole "<date>T<time>Z" term.

I'll convert it back to match your suggestion.
> 
>   * I changed the hostname discovery so if gethostbyname() fails we'll
>     print "-H00000000-" for that part, instead of "-H<first 8 chars of
>     the sha1 for 'localhost'>-". Also prefix with "H" for "Host".
I like that.
> 
>   * Wrap pids to 0xffff, prefix with "P" (Pid)" and trail with either "F"
>     = Full or "W" = Wrapped (not the real PID).

I could see the "P". I'm not sure about the hex -- I sometimes want to do a "ps" or watch the processes go by in TaskManager and friends and they all print the pid in decimal. But it's not that big a deal.

Show 9 quoted lines
> 
>   * I didn't add "T<datetime>" like "H" and "P" for the rest, since it's
>     obvious what sort of value it is.
> 
> Maybe this is going a bit overboard, but I think it's easier to read at
> a glance for humans, and since it's meant to be opaque to machines
> anyway and the length is simliar enough not to matter I figure it's
> worth it.
> 

I'll re-roll. Thanks Jeff

Previous: Ævar Arnfjörð BjarmasonNext: Jeff Hostetler via GitGitGadget
Message 24 of 68 in “trace2: load trace2 settings from system config”
  1. 0/4 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Mar 28, 2019
  2. 1/4 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Mar 28, 2019
  3. 2/4 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Mar 28, 2019
  4. 3/4 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Mar 28, 2019
  5. 4/4 trace2: use system config for default trace2 settingsJeff Hostetler via GitGitGadget, Mar 28, 2019
  6. Ævar Arnfjörð BjarmasonMar 28, 2019
  7. Jeff HostetlerMar 28, 2019
  8. Josh SteadmonMar 28, 2019
  9. 0/7 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Mar 29, 2019
  10. 2/7 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Mar 29, 2019
  11. 3/7 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Mar 29, 2019
  12. 5/7 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Mar 29, 2019
  13. Ævar Arnfjörð BjarmasonMar 29, 2019
  14. Jeff HostetlerApr 1, 2019
  15. 6/7 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Mar 29, 2019
  16. 4/7 trace2: use system config for default trace2 settingsJeff Hostetler via GitGitGadget, Mar 29, 2019
  17. Josh SteadmonApr 1, 2019
  18. Jeff HostetlerApr 1, 2019
  19. Jonathan NiederApr 3, 2019
  20. Jonathan NiederApr 3, 2019
  21. Jeff HostetlerApr 9, 2019
  22. 7/7 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Mar 29, 2019
  23. Ævar Arnfjörð BjarmasonMar 29, 2019
  24. Jeff HostetlerApr 1, 2019
  25. 1/7 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Mar 29, 2019
  26. Josh SteadmonApr 1, 2019
  27. 00/10 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Apr 11, 2019
  28. 01/10 config: initialize opts structure in repo_read_config()Jeff Hostetler via GitGitGadget, Apr 11, 2019
  29. Jonathan NiederApr 12, 2019
  30. Johannes SchindelinApr 15, 2019
  31. 03/10 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Apr 11, 2019
  32. 05/10 config: add read_very_early_config()Jeff Hostetler via GitGitGadget, Apr 11, 2019
  33. 08/10 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Apr 11, 2019
  34. 07/10 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Apr 11, 2019
  35. 10/10 trace2: update docs to describe system/global config settingsJeff Hostetler via GitGitGadget, Apr 11, 2019
  36. 09/10 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Apr 11, 2019
  37. 02/10 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Apr 11, 2019
  38. 06/10 trace2: use system/global config for default trace2 settingsJeff Hostetler via GitGitGadget, Apr 11, 2019
  39. 04/10 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Apr 11, 2019
  40. Junio C HamanoApr 12, 2019
  41. Jeff HostetlerApr 12, 2019
  42. 00/10 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Apr 15, 2019
  43. 01/10 config: initialize opts structure in repo_read_config()Jeff Hostetler via GitGitGadget, Apr 15, 2019
  44. 02/10 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Apr 15, 2019
  45. 03/10 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Apr 15, 2019
  46. 05/10 config: add read_very_early_config()Jeff Hostetler via GitGitGadget, Apr 15, 2019
  47. 07/10 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Apr 15, 2019
  48. 06/10 trace2: use system/global config for default trace2 settingsJeff Hostetler via GitGitGadget, Apr 15, 2019
  49. SZEDER GáborApr 27, 2019
  50. Jeff HostetlerApr 29, 2019
  51. 10/10 trace2: update docs to describe system/global config settingsJeff Hostetler via GitGitGadget, Apr 15, 2019
  52. 04/10 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Apr 15, 2019
  53. 09/10 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Apr 15, 2019
  54. 08/10 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Apr 15, 2019
  55. 00/11 trace2: load trace2 settings from system configJeff Hostetler via GitGitGadget, Apr 29, 2019
  56. 01/11 config: initialize opts structure in repo_read_config()Jeff Hostetler via GitGitGadget, Apr 29, 2019
  57. 03/11 trace2: add absolute elapsed time to start eventJeff Hostetler via GitGitGadget, Apr 29, 2019
  58. 02/11 trace2: refactor setting process starting timeJeff Hostetler via GitGitGadget, Apr 29, 2019
  59. 07/11 trace2: report peak memory usage of the processJeff Hostetler via GitGitGadget, Apr 29, 2019
  60. 08/11 trace2: clarify UTC datetime formattingJeff Hostetler via GitGitGadget, Apr 29, 2019
  61. 09/11 trace2: make SIDs more uniqueJeff Hostetler via GitGitGadget, Apr 29, 2019
  62. 06/11 trace2: use system/global config for default trace2 settingsJeff Hostetler via GitGitGadget, Apr 29, 2019
  63. 11/11 trace2: fixup access problem on /etc/gitconfig in read_very_early_configJeff Hostetler via GitGitGadget, Apr 29, 2019
  64. 10/11 trace2: update docs to describe system/global config settingsJeff Hostetler via GitGitGadget, Apr 29, 2019
  65. 05/11 config: add read_very_early_config()Jeff Hostetler via GitGitGadget, Apr 29, 2019
  66. 04/11 trace2: find exec-dir before trace2 initializationJeff Hostetler via GitGitGadget, Apr 29, 2019
  67. Jeff HostetlerApr 29, 2019
  68. Junio C HamanoMay 7, 2019

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.