Howdju / howdju

Monorepo for the Howdju crowdsourced fact checking and summarization platform
https://www.howdju.com
GNU Affero General Public License v3.0
5 stars 2 forks source link

text-fragments-polyfill processTextFragmentDirective takes >60s to complete #506

Open carlgieringer opened 1 year ago

carlgieringer commented 1 year ago

I looked into using text-fragments-polyfill's processTextFragmentDirective with jsdom to translate a text fragment URL to a range (so that we can get a quotation from the range.) But it took over 60s to complete. So for now we are using extractQuotationFromTextFragment (dom-anchor-text-quote.)

See howdju-text-fragment's getRangesForCurrentFragment and extractQuotation.test.ts.

I didn't see anything obviously wrong with the implementation. I am not sure if it's a problem with the algorithm in text-fragments-polyfill or maybe an incompatibility with jsdom.

I took a breakpoint-based CPU profile which indicated that most the time was spent in jsdom's compareBoundaryPointsPosition:

Screenshot 2023-08-09 at 12 21 17 PM Screenshot 2023-08-09 at 12 20 58 PM
carlgieringer commented 1 year ago

~3m in GH actions. So I disabled the test.