<p></p>
<blockquote>
<p dir="auto">This is quite surprising, I would have expected the performance to be somewhere between a hand-written parser and a regex parser but it probably depends on the grammar and the lookahead it has to perform. Have you tried profiling the parser to see if there's not some unexpected bottleneck?</p>
</blockquote>
<p dir="auto">I did a lot of profiling on PackCC and it turns out it is not very efficient with memory allocations (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="807968617" data-permission-text="Title is private" data-url="https://github.com/universal-ctags/ctags/issues/2866" data-hovercard-type="pull_request" data-hovercard-url="/universal-ctags/ctags/pull/2866/hovercard?comment_id=780332841&comment_type=issue_comment" href="https://github.com/universal-ctags/ctags/pull/2866#issuecomment-780332841">universal-ctags/ctags#2866 (comment)</a>), the backtracking is constantly allocating and deallocating small chunks of memory. So, more rules leads to more backtracking, which leads to more allocations, which slows it down. I have even <a href="https://github.com/arithy/packcc/pull/48" data-hovercard-type="pull_request" data-hovercard-url="/arithy/packcc/pull/48/hovercard">proposed couple possible optimizations</a>, but I did not have from enough manpower to actually implement it (sadly, I am not very proficient in C).</p>
<p dir="auto">I might look into the grammar optimization in future, so the parser might become somewhat faster (especially, if it slows Geany down, that would annoy me a lot). Probably could beat the RegExp based ones (for comparable grammars). According to creator of ctags, the peg parser is about 15-30 times slower than handwritten parser (citation from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="807968617" data-permission-text="Title is private" data-url="https://github.com/universal-ctags/ctags/issues/2866" data-hovercard-type="pull_request" data-hovercard-url="/universal-ctags/ctags/pull/2866/hovercard?comment_id=778786809&comment_type=issue_comment" href="https://github.com/universal-ctags/ctags/pull/2866#issuecomment-778786809">universal-ctags/ctags#2866 (comment)</a>). Even with grammar optimizations, it would still probably be about an order of magnitude slower than let's say current C parser.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/3034#issuecomment-988176361">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ23VV2PVWOXSOTRXADUPZIKVANCNFSM5I7MRDJA">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AAIOWJ3ODMPK3XHT4CNNY5TUPZIKVA5CNFSM5I7MRDJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHLTF72I.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/pull/3034#issuecomment-988176361",
"url": "https://github.com/geany/geany/pull/3034#issuecomment-988176361",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>