summaryrefslogtreecommitdiff
path: root/doc/recentchanges/change_d6ff694ff7a6a4700ccbbd5819907eac73cf065a._change
blob: 235b8a5928623e2679cb21db1441a684a5cb77d8 (plain)
  1. [[!meta author="""smcv"""]]
  2. [[!meta authorurl="""http://ikiwiki.info/ikiwiki.cgi?page=users%2Fsmcv&do=goto"""]]
  3. [[!meta title="""change to todo/Improving_the_efficiency_of_match__95__glob on ikiwiki"""]]
  4. [[!meta permalink="http://ikiwiki.info/recentchanges/#change-d6ff694ff7a6a4700ccbbd5819907eac73cf065a"]]
  5. <div id="change-d6ff694ff7a6a4700ccbbd5819907eac73cf065a" class="metadata">
  6. <span class="desc"><br />Changed pages:</span>
  7. <span class="pagelinks">
  8. <a href="http://git.ikiwiki.info/?p=ikiwiki;a=blobdiff;f=doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn;h=de3cf48d3aae963943dfeb3aaffb2edd6f472ef8;hp=0fc059ad7d169c2e35f3ea869bdc2f69be649857;hb=d6ff694ff7a6a4700ccbbd5819907eac73cf065a;hpb=a4cb86d73327e7850eeb524ef387b17ac5e1614d" title="diff" rel="nofollow">[[diff|wikiicons/diff.png]]</a><a href="http://ikiwiki.info/ikiwiki.cgi?page=todo%2FImproving_the_efficiency_of_match__95__glob&amp;do=goto" rel="nofollow">todo/Improving the efficiency of match&#95;glob</a>
  9. </span>
  10. <span class="desc"><br />Changed by:</span>
  11. <span class="committer">
  12. <a href="http://ikiwiki.info/ikiwiki.cgi?page=users%2Fsmcv&amp;do=goto" rel="nofollow">smcv</a>
  13. </span>
  14. <span class="desc"><br />Commit type:</span>
  15. <span class="committype">git</span>
  16. <span class="desc"><br />Date:</span>
  17. <span class="changedate"><span class="relativedate" title="Sat, 20 Nov 2010 00:22:56 +0000">00:22:56 11/20/10</span></span>
  18. <span class="desc"><br /></span>
  19. </div>
  20. <span class="revert">
  21. <a href="http://ikiwiki.info/ikiwiki.cgi?rev=d6ff694ff7a6a4700ccbbd5819907eac73cf065a&amp;do=revert" title="revert" rel="nofollow">[[revert|wikiicons/revert.png]]</a>
  22. </span>
  23. <div class="changelog">
  24. branch ready for merge, I think<br />
  25. </div>
  26. <div class="diff">
  27. <pre>
  28. diff --git a/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn b/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn
  29. index 0fc059a..de3cf48 100644
  30. --- a/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn
  31. +++ b/doc/todo/Improving_the_efficiency_of_match__95__glob.mdwn
  32. @@ -1,3 +1,7 @@
  33. +&#91;&#91;!template id=gitbranch branch=smcv/ready/glob-cache
  34. + author=&quot;&#91;&#91;KathrynAndersen&#93;&#93;, &#91;&#91;smcv&#93;&#93;&quot;&#93;&#93;
  35. +&#91;&#91;!tag patch&#93;&#93;
  36. +
  37. I&#39;ve been profiling my IkiWiki to try to improve speed (with many pages makes speed even more important) and I&#39;ve written a patch to improve the speed of match_glob. This matcher is a good one to improve the speed of, because it gets called so many times.
  38. Here&#39;s my patch - please consider it! -- &#91;&#91;KathrynAndersen&#93;&#93;
  39. @@ -39,7 +43,92 @@ Here&#39;s my patch - please consider it! -- &#91;&#91;KathrynAndersen&#93;&#93;
  40. &gt;&gt;&gt;&gt;&gt;&gt; `/^/i` regexp that can be used without further modifiction in most
  41. &gt;&gt;&gt;&gt;&gt;&gt; cases. --&#91;&#91;Joey&#93;&#93;
  42. +&gt;&gt;&gt;&gt;&gt;&gt;&gt; Done, see `smcv/ready/glob-cache`.
  43. +&gt;&gt;&gt;&gt;&gt;&gt;&gt; Kathryn&#39;s patch is a significant improvement; my first patch on top of
  44. +&gt;&gt;&gt;&gt;&gt;&gt;&gt; that is a trivial cleanup that speeds it up a little, and the other two
  45. +&gt;&gt;&gt;&gt;&gt;&gt;&gt; patches (using precompiled regexes) have surprisingly little effect
  46. +&gt;&gt;&gt;&gt;&gt;&gt;&gt; (they don&#39;t slow it down either though, so either omit them or merge
  47. +&gt;&gt;&gt;&gt;&gt;&gt;&gt; them, whichever). Detailed benchmark results --&#91;&#91;smcv&#93;&#93;
  48. +
  49. --------------------------------------------------------------
  50. +
  51. +&#91;&#91;!toggle id=&quot;smcv-benchmark&quot; text=&quot;current benchmarks&quot;&#93;&#93;
  52. +
  53. +&#91;&#91;!toggleable id=&quot;smcv-benchmark&quot; text=&quot;&quot;&quot;
  54. +master at time of branch:
  55. +
  56. + time elapsed (wall): 29.6348
  57. + time running program: 24.9212 (84.09%)
  58. + time profiling (est.): 4.7136 (15.91%)
  59. + number of calls: 1360181
  60. + number of exceptions: 13
  61. +
  62. + %Time Sec. #calls sec/call F name
  63. + 13.24 3.2986 3408 0.000968 Text::Balanced::_match_tagged
  64. + 10.94 2.7253 79514 0.000034 IkiWiki::PageSpec::match_glob
  65. + 3.19 0.7952 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  66. +
  67. +`Improve the speed of match_glob`:
  68. +
  69. + time elapsed (wall): 27.9755
  70. + time running program: 23.5293 (84.11%)
  71. + time profiling (est.): 4.4461 (15.89%)
  72. + number of calls: 1280875
  73. + number of exceptions: 13
  74. +
  75. + %Time Sec. #calls sec/call F name
  76. + 14.56 3.4257 3408 0.001005 Text::Balanced::_match_tagged
  77. + 7.82 1.8403 79514 0.000023 IkiWiki::PageSpec::match_glob
  78. + 3.27 0.7698 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  79. +
  80. +`match_glob: streamline glob cache slightly`:
  81. +
  82. + time elapsed (wall): 27.5753
  83. + time running program: 23.1714 (84.03%)
  84. + time profiling (est.): 4.4039 (15.97%)
  85. + number of calls: 1280875
  86. + number of exceptions: 13
  87. +
  88. + %Time Sec. #calls sec/call F name
  89. + 14.09 3.2637 3408 0.000958 Text::Balanced::_match_tagged
  90. + 7.74 1.7926 79514 0.000023 IkiWiki::PageSpec::match_glob
  91. + 3.30 0.7646 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  92. +
  93. +`glob2re: return a precompiled, anchored case-insensitiv...`:
  94. +
  95. + time elapsed (wall): 27.5656
  96. + time running program: 23.1464 (83.97%)
  97. + time profiling (est.): 4.4192 (16.03%)
  98. + number of calls: 1282189
  99. + number of exceptions: 13
  100. +
  101. + %Time Sec. #calls sec/call F name
  102. + 14.21 3.2891 3408 0.000965 Text::Balanced::_match_tagged
  103. + 7.72 1.7872 79514 0.000022 IkiWiki::PageSpec::match_glob
  104. + 3.32 0.7678 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  105. +
  106. +`make use of precompiled regex objects`:
  107. +
  108. + time elapsed (wall): 27.5357
  109. + time running program: 23.1289 (84.00%)
  110. + time profiling (est.): 4.4068 (16.00%)
  111. + number of calls: 1281981
  112. + number of exceptions: 13
  113. +
  114. + %Time Sec. #calls sec/call F name
  115. + 14.17 3.2776 3408 0.000962 Text::Balanced::_match_tagged
  116. + 7.70 1.7814 79514 0.000022 IkiWiki::PageSpec::match_glob
  117. + 3.35 0.7756 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  118. +
  119. +&quot;&quot;&quot;&#93;&#93;
  120. +
  121. +--&#91;&#91;smcv&#93;&#93;
  122. +
  123. +--------------------------------------------------------------
  124. +
  125. +&#91;&#91;!toggle id=&quot;ka-benchmarks&quot; text=&quot;Kathryn&#39;s benchmarks&quot;&#93;&#93;
  126. +
  127. +&#91;&#91;!toggleable id=&quot;ka-benchmarks&quot; text=&quot;&quot;&quot;
  128. Benchmarks done with Devel::Profile on the same testbed IkiWiki setup. I&#39;m just showing the start of the profile output, since that&#39;s what&#39;s relevant.
  129. Before:
  130. @@ -73,73 +162,13 @@ number of exceptions: 65
  131. Note that the seconds per call for match_glob in the &quot;after&quot; case has gone down by about a third.
  132. K.A.
  133. +&quot;&quot;&quot;&#93;&#93;
  134. --------------------------------------------------------------
  135. -A second set of benchmarks, done by rebuilding the docwiki at commit f942c2db05e4
  136. -like so:
  137. -
  138. - perl -Iblib/lib -d:Profile ikiwiki.in -setup docwiki.setup --no-verbose
  139. -
  140. -The docwiki appears to use fewer glob matches than Kathryn&#39;s wiki.
  141. -
  142. -With master:
  143. -
  144. - time elapsed (wall): 29.6970
  145. - time running program: 24.6930 (83.15%)
  146. - time profiling (est.): 5.0041 (16.85%)
  147. - number of calls: 1359180
  148. - number of exceptions: 13
  149. -
  150. - %Time Sec. #calls sec/call F name
  151. - 13.62 3.3629 3406 0.000987 Text::Balanced::_match_tagged
  152. - 10.84 2.6773 79442 0.000034 IkiWiki::PageSpec::match_glob
  153. - 3.08 0.7598 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  154. - 3.07 0.7593 29830 0.000025 IkiWiki::bestlink
  155. - 2.99 0.7378 10231 0.000072 IkiWiki::PageSpec::match_link
  156. -
  157. -With my `smcv/memoize-glob2re` branch:
  158. -
  159. - time elapsed (wall): 30.4931
  160. - time running program: 25.1248 (82.39%)
  161. - time profiling (est.): 5.3683 (17.61%)
  162. - number of calls: 1439943
  163. - number of exceptions: 13
  164. -
  165. - %Time Sec. #calls sec/call F name
  166. - 13.19 3.3146 3406 0.000973 Text::Balanced::_match_tagged
  167. - 8.41 2.1123 79442 0.000027 IkiWiki::PageSpec::match_glob
  168. - 3.97 0.9979 86905 0.000011 Memoize::_memoizer
  169. - 3.05 0.7654 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  170. - 3.02 0.7576 29830 0.000025 IkiWiki::bestlink
  171. -
  172. -and in a repeated run:
  173. -
  174. - 8.40 2.0905 79442 0.000026 IkiWiki::PageSpec::match_glob
  175. -
  176. -With Kathryn&#39;s patch as seen in my `smcv/ka-glob-cache` branch:
  177. -
  178. - time elapsed (wall): 27.7567
  179. - time running program: 22.9941 (82.84%)
  180. - time profiling (est.): 4.7627 (17.16%)
  181. - number of calls: 1279946
  182. - number of exceptions: 13
  183. -
  184. - %Time Sec. #calls sec/call F name
  185. - 14.29 3.2867 3406 0.000965 Text::Balanced::_match_tagged
  186. - 7.89 1.8136 79442 0.000023 IkiWiki::PageSpec::match_glob
  187. - 3.30 0.7577 59454 0.000013 &lt;anon&gt;:IkiWiki/Plugin/inline.pm:223
  188. - 3.24 0.7461 29830 0.000025 IkiWiki::bestlink
  189. - 3.19 0.7332 143 0.005127 ? IkiWiki::pagespec_match_list
  190. -
  191. -and in a repeated run:
  192. -
  193. - 7.84 1.8253 79442 0.000023 IkiWiki::PageSpec::match_glob
  194. -
  195. ---&#91;&#91;smcv&#93;&#93;
  196. -
  197. ---------------------------------------------------------------
  198. +&#91;&#91;!toggle id=&quot;ka-patch&quot; text=&quot;Kathryn&#39;s original patch&quot;&#93;&#93;
  199. +&#91;&#91;!toggleable id=&quot;ka-patch&quot; text=&quot;&quot;&quot;
  200. &lt;pre&gt;
  201. diff --git a/IkiWiki.pm b/IkiWiki.pm
  202. @@ -174,4 +203,5 @@ index 08a3d78..c187b98 100644
  203. return IkiWiki::SuccessReason-&gt;new(&quot;$glob matches $page&quot;);
  204. }
  205. &lt;/pre&gt;
  206. +&quot;&quot;&quot;&#93;&#93;
  207. --------------------------------------------------------------
  208. </pre>
  209. </div>
  210. <!-- d6ff694ff7a6a4700ccbbd5819907eac73cf065a -->