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

Re: [PATCH v2 12/16] pathspec: create parse_long_magic function

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 12, 2016, 06:19 UTC
Message-ID
<xmqqfultoej1.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAGZ79kbbk4vdW_mbC0riXOf=31V9AQV7zKEh56G+sxjjzAr2-g@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 7 quoted lines
>> I do not see how it would work without further splitting the
>> attr_stack.  I think you made it per check[], but you would further
>> split it per <check, thread> before losing the mutex, no?
>
> Well I have not yet looked into it again, so my memories are
> rusty, but the <check> is read only, such that the answers only
> need to be per thread?

<check> is read-only, so as long as you populate the singleton attr's beforehand, they can be shared across threads. <answer> of course needs an instance per thread, and that is why you have them typically on stack.

The process of filling <answer> by asking for a set of attrs in <check> for one <path> goes roughly like:

 - make sure attr_stack is set up for <path>, namely, the
   info/attributes and .gitattributes files for each leading
   directory are parsed.
 - go over the attr_stack entries and see what entries match <path>,
   and collect the result for <check> in <answer>

Before d90675c151 ("attr: keep attr stack for each check", 2016-11-10), I had only one instance of an attr stack [*1*], but with that commit, you made it per <check>, which is a good move to allow us to optimize by keeping only the attributes relevant to <check> on the attr stack.

But it does not solve the threading issue.

If multiple threads are asking for the same set of attrs (i.e. running the same codepath using the same <check>) but for <path>s in different parts of the working tree (e.g. "git checkout" that is multi-threaded, each thread asking for eol related attributes and checking out different subdirectories), you'd need mutex for correct operation at least, but that won't perform well because you'd end up thrashing the attr stack. You'd need to split attr stack further and make it per (<check>, thread) tuple and you no longer need mutex at that point, but not before that.

[footnote]
*1* This is because the attr subsystem originally wasn't designed to
    be used from multiple threads at the same time hence it was
    sufficient to have a single "currently interested are of the
    directory hierarchy".
Previous: Stefan BellerNext: Brandon Williams
Message 65 of 142 in “pathspec cleanup”
  1. 00/17 pathspec cleanupBrandon Williams, Dec 6, 2016
  2. 01/17 mv: convert to using pathspec struct interfaceBrandon Williams, Dec 6, 2016
  3. Duy NguyenDec 7, 2016
  4. Brandon WilliamsDec 8, 2016
  5. Duy NguyenDec 8, 2016
  6. Brandon WilliamsDec 8, 2016
  7. 02/17 dir: convert create_simplify to use the pathspec struct interfaceBrandon Williams, Dec 6, 2016
  8. Duy NguyenDec 7, 2016
  9. Brandon WilliamsDec 8, 2016
  10. Duy NguyenDec 8, 2016
  11. Brandon WilliamsDec 8, 2016
  12. Duy NguyenDec 9, 2016
  13. Brandon WilliamsDec 9, 2016
  14. Brandon WilliamsDec 13, 2016
  15. 03/17 dir: convert fill_directory to use the pathspec struct interfaceBrandon Williams, Dec 6, 2016
  16. Duy NguyenDec 7, 2016
  17. Brandon WilliamsDec 7, 2016
  18. 10/17 pathspec: simpler logic to prefix original pathspec elementsBrandon Williams, Dec 6, 2016
  19. Stefan BellerDec 6, 2016
  20. Brandon WilliamsDec 6, 2016
  21. 08/17 pathspec: remove unused variable from unsupported_magicBrandon Williams, Dec 6, 2016
  22. 09/17 pathspec: always show mnemonic and name in unsupported_magicBrandon Williams, Dec 6, 2016
  23. Duy NguyenDec 7, 2016
  24. Brandon WilliamsDec 7, 2016
  25. Duy NguyenDec 7, 2016
  26. Brandon WilliamsDec 7, 2016
  27. 16/17 pathspec: small readability changesBrandon Williams, Dec 6, 2016
  28. Stefan BellerDec 6, 2016
  29. Duy NguyenDec 7, 2016
  30. Brandon WilliamsDec 7, 2016
  31. Duy NguyenDec 8, 2016
  32. Duy NguyenDec 7, 2016
  33. Junio C HamanoDec 7, 2016
  34. Brandon WilliamsDec 7, 2016
  35. 13/17 pathspec: create parse_long_magic functionBrandon Williams, Dec 6, 2016
  36. 14/17 pathspec: create parse_element_magic helperBrandon Williams, Dec 6, 2016
  37. 11/17 pathspec: factor global magic into its own functionBrandon Williams, Dec 6, 2016
  38. Duy NguyenDec 7, 2016
  39. Brandon WilliamsDec 7, 2016
  40. Duy NguyenDec 8, 2016
  41. 12/17 pathspec: create parse_short_magic functionBrandon Williams, Dec 6, 2016
  42. 07/17 mv: small code cleanupBrandon Williams, Dec 6, 2016
  43. 06/17 pathspec: copy and free owned memoryBrandon Williams, Dec 6, 2016
  44. 04/17 ls-tree: convert show_recursive to use the pathspec struct interfaceBrandon Williams, Dec 6, 2016
  45. Duy NguyenDec 7, 2016
  46. Brandon WilliamsDec 7, 2016
  47. 05/17 pathspec: remove the deprecated get_pathspec functionBrandon Williams, Dec 6, 2016
  48. 17/17 pathspec: remove outdated commentBrandon Williams, Dec 6, 2016
  49. 15/17 pathspec: create strip submodule slash helpersBrandon Williams, Dec 6, 2016
  50. Junio C HamanoDec 7, 2016
  51. 00/16 pathspec cleanupBrandon Williams, Dec 8, 2016
  52. 01/16 mv: remove use of deprecated 'get_pathspec()'Brandon Williams, Dec 8, 2016
  53. 02/16 dir: convert create_simplify to use the pathspec struct interfaceBrandon Williams, Dec 8, 2016
  54. 03/16 dir: convert fill_directory to use the pathspec struct interfaceBrandon Williams, Dec 8, 2016
  55. 06/16 pathspec: copy and free owned memoryBrandon Williams, Dec 8, 2016
  56. 11/16 pathspec: create parse_short_magic functionBrandon Williams, Dec 8, 2016
  57. 10/16 pathspec: factor global magic into its own functionBrandon Williams, Dec 8, 2016
  58. 09/16 pathspec: simpler logic to prefix original pathspec elementsBrandon Williams, Dec 8, 2016
  59. 12/16 pathspec: create parse_long_magic functionBrandon Williams, Dec 8, 2016
  60. Junio C HamanoDec 9, 2016
  61. Stefan BellerDec 9, 2016
  62. Brandon WilliamsDec 10, 2016
  63. Junio C HamanoDec 10, 2016
  64. Stefan BellerDec 12, 2016
  65. Junio C HamanoDec 12, 2016
  66. 16/16 pathspec: rename prefix_pathspec to init_pathspec_itemBrandon Williams, Dec 8, 2016
  67. 13/16 pathspec: create parse_element_magic helperBrandon Williams, Dec 8, 2016
  68. 15/16 pathspec: small readability changesBrandon Williams, Dec 8, 2016
  69. 14/16 pathspec: create strip submodule slash helpersBrandon Williams, Dec 8, 2016
  70. Junio C HamanoDec 9, 2016
  71. Duy NguyenDec 9, 2016
  72. 14/16 pathspec: create strip submodule slash helpersBrandon Williams, Dec 9, 2016
  73. Stefan BellerDec 9, 2016
  74. Brandon WilliamsDec 9, 2016
  75. 08/16 pathspec: always show mnemonic and name in unsupported_magicBrandon Williams, Dec 8, 2016
  76. 04/16 ls-tree: convert show_recursive to use the pathspec struct interfaceBrandon Williams, Dec 8, 2016
  77. 05/16 pathspec: remove the deprecated get_pathspec functionBrandon Williams, Dec 8, 2016
  78. 07/16 pathspec: remove unused variable from unsupported_magicBrandon Williams, Dec 8, 2016
  79. Junio C HamanoDec 9, 2016
  80. Brandon WilliamsDec 9, 2016
  81. 00/16 pathspec cleanupBrandon Williams, Dec 13, 2016
  82. 02/16 dir: remove struct path_simplifyBrandon Williams, Dec 13, 2016
  83. Stefan BellerDec 19, 2016
  84. Duy NguyenJan 3, 2017
  85. 04/16 ls-tree: convert show_recursive to use the pathspec struct interfaceBrandon Williams, Dec 13, 2016
  86. 03/16 dir: convert fill_directory to use the pathspec struct interfaceBrandon Williams, Dec 13, 2016
  87. 07/16 pathspec: remove unused variable from unsupported_magicBrandon Williams, Dec 13, 2016
  88. 08/16 pathspec: always show mnemonic and name in unsupported_magicBrandon Williams, Dec 13, 2016
  89. Duy NguyenJan 3, 2017
  90. Brandon WilliamsJan 3, 2017
  91. 06/16 pathspec: copy and free owned memoryBrandon Williams, Dec 13, 2016
  92. Duy NguyenJan 3, 2017
  93. 01/16 mv: remove use of deprecated 'get_pathspec()'Brandon Williams, Dec 13, 2016
  94. 09/16 pathspec: simpler logic to prefix original pathspec elementsBrandon Williams, Dec 13, 2016
  95. 05/16 pathspec: remove the deprecated get_pathspec functionBrandon Williams, Dec 13, 2016
  96. 13/16 pathspec: create parse_element_magic helperBrandon Williams, Dec 13, 2016
  97. 15/16 pathspec: small readability changesBrandon Williams, Dec 13, 2016
  98. 14/16 pathspec: create strip submodule slash helpersBrandon Williams, Dec 13, 2016
  99. 12/16 pathspec: create parse_long_magic functionBrandon Williams, Dec 13, 2016
  100. 16/16 pathspec: rename prefix_pathspec to init_pathspec_itemBrandon Williams, Dec 13, 2016
  101. 11/16 pathspec: create parse_short_magic functionBrandon Williams, Dec 13, 2016
  102. 10/16 pathspec: factor global magic into its own functionBrandon Williams, Dec 13, 2016
  103. 00/16 pathspec cleanupBrandon Williams, Jan 3, 2017
  104. 03/16 dir: convert fill_directory to use the pathspec struct interfaceBrandon Williams, Jan 3, 2017
  105. 10/16 pathspec: factor global magic into its own functionBrandon Williams, Jan 3, 2017
  106. 04/16 ls-tree: convert show_recursive to use the pathspec struct interfaceBrandon Williams, Jan 3, 2017
  107. 01/16 mv: remove use of deprecated 'get_pathspec()'Brandon Williams, Jan 3, 2017
  108. 09/16 pathspec: simpler logic to prefix original pathspec elementsBrandon Williams, Jan 3, 2017
  109. 14/16 pathspec: create strip submodule slash helpersBrandon Williams, Jan 3, 2017
  110. 08/16 pathspec: always show mnemonic and name in unsupported_magicBrandon Williams, Jan 3, 2017
  111. 07/16 pathspec: remove unused variable from unsupported_magicBrandon Williams, Jan 3, 2017
  112. 05/16 pathspec: remove the deprecated get_pathspec functionBrandon Williams, Jan 3, 2017
  113. 13/16 pathspec: create parse_element_magic helperBrandon Williams, Jan 3, 2017
  114. 11/16 pathspec: create parse_short_magic functionBrandon Williams, Jan 3, 2017
  115. 06/16 pathspec: copy and free owned memoryBrandon Williams, Jan 3, 2017
  116. 15/16 pathspec: small readability changesBrandon Williams, Jan 3, 2017
  117. 02/16 dir: remove struct path_simplifyBrandon Williams, Jan 3, 2017
  118. 12/16 pathspec: create parse_long_magic functionBrandon Williams, Jan 3, 2017
  119. 16/16 pathspec: rename prefix_pathspec to init_pathspec_itemBrandon Williams, Jan 3, 2017
  120. Duy NguyenJan 4, 2017
  121. Brandon WilliamsJan 4, 2017
  122. Brandon WilliamsJan 4, 2017
  123. 00/16 pathspec cleanupBrandon Williams, Jan 4, 2017
  124. 15/16 pathspec: small readability changesBrandon Williams, Jan 4, 2017
  125. 13/16 pathspec: create parse_element_magic helperBrandon Williams, Jan 4, 2017
  126. 12/16 pathspec: create parse_long_magic functionBrandon Williams, Jan 4, 2017
  127. 10/16 pathspec: factor global magic into its own functionBrandon Williams, Jan 4, 2017
  128. 08/16 pathspec: always show mnemonic and name in unsupported_magicBrandon Williams, Jan 4, 2017
  129. 09/16 pathspec: simpler logic to prefix original pathspec elementsBrandon Williams, Jan 4, 2017
  130. 16/16 pathspec: rename prefix_pathspec to init_pathspec_itemBrandon Williams, Jan 4, 2017
  131. 14/16 pathspec: create strip submodule slash helpersBrandon Williams, Jan 4, 2017
  132. 07/16 pathspec: remove unused variable from unsupported_magicBrandon Williams, Jan 4, 2017
  133. 11/16 pathspec: create parse_short_magic functionBrandon Williams, Jan 4, 2017
  134. 04/16 ls-tree: convert show_recursive to use the pathspec struct interfaceBrandon Williams, Jan 4, 2017
  135. 02/16 dir: remove struct path_simplifyBrandon Williams, Jan 4, 2017
  136. 03/16 dir: convert fill_directory to use the pathspec struct interfaceBrandon Williams, Jan 4, 2017
  137. 01/16 mv: remove use of deprecated 'get_pathspec()'Brandon Williams, Jan 4, 2017
  138. 05/16 pathspec: remove the deprecated get_pathspec functionBrandon Williams, Jan 4, 2017
  139. 06/16 pathspec: copy and free owned memoryBrandon Williams, Jan 4, 2017
  140. Duy NguyenJan 7, 2017
  141. Junio C HamanoJan 9, 2017
  142. Brandon WilliamsJan 9, 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.