Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the Glyph.matchesForCache method (PR 13494 follow-up) #15586

Merged
merged 2 commits into from
Oct 20, 2022

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Oct 18, 2022

This method, and its class, was originally added in PR #4453 to reduce memory usage when parsing text. Then PR #13494 extended the Glyph-representation slightly to also include the charCode, which made the matchesForCache method effectively redundant since most properties on a Glyph-instance indirectly depends on that one. The only exception is potentially isSpace in multi-byte strings.

Also, something that I noticed when testing this code: The matchesForCache method never worked correctly for Glyphs containing accent-data, since Objects are passed by reference in JavaScript. For affected fonts, of which there's only a handful of examples in our test-suite, we'd fail to find an already existing Glyph because of this.

@Snuffleupagus Snuffleupagus changed the title Remove thet Glyph.matchesForCache method (PR 13494 follow-up) Remove the Glyph.matchesForCache method (PR 13494 follow-up) Oct 18, 2022
@Snuffleupagus Snuffleupagus marked this pull request as draft October 18, 2022 14:58
@Snuffleupagus Snuffleupagus reopened this Oct 18, 2022
@mozilla mozilla deleted a comment from pdfjsbot Oct 18, 2022
@mozilla mozilla deleted a comment from pdfjsbot Oct 18, 2022
@mozilla mozilla deleted a comment from pdfjsbot Oct 18, 2022
@mozilla mozilla deleted a comment from pdfjsbot Oct 18, 2022
@Snuffleupagus Snuffleupagus force-pushed the rm-matchesForCache branch 3 times, most recently from f08442b to 3748c6e Compare October 18, 2022 15:14
@Snuffleupagus Snuffleupagus marked this pull request as ready for review October 18, 2022 17:19
This method, and its class, was originally added in PR 4453 to reduce memory usage when parsing text. Then PR 13494 extended the `Glyph`-representation slightly to also include the `charCode`, which made the `matchesForCache` method *effectively* redundant since most properties on a `Glyph`-instance indirectly depends on that one. The only exception is potentially `isSpace` in multi-byte strings.

Also, something that I noticed when testing this code: The `matchesForCache` method never worked correctly for `Glyph`s containing `accent`-data, since Objects are passed by reference in JavaScript. For affected fonts, of which there's only a handful of examples in our test-suite, we'd fail to find an already existing `Glyph` because of this.
With the changes in the previous patch we can move the glyph-cache lookup to the top of the method and thus avoid a bunch of, in *almost* every case, completely unnecessary re-parsing for every `charCode`.
@mozilla mozilla deleted a comment from pdfjsbot Oct 19, 2022
@mozilla mozilla deleted a comment from pdfjsbot Oct 19, 2022
@mozilla mozilla deleted a comment from pdfjsbot Oct 19, 2022
@mozilla mozilla deleted a comment from pdfjsbot Oct 19, 2022
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 1

Live output at: http://54.193.163.58:8877/d26682143e29a14/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/61d17a8ff4c9c07/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/61d17a8ff4c9c07/output.txt

Total script time: 24.83 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 10
  different first/second rendering: 2

Image differences available at: http://54.241.84.105:8877/61d17a8ff4c9c07/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/d26682143e29a14/output.txt

Total script time: 28.58 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.193.163.58:8877/d26682143e29a14/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator Author

Note that being able to skip re-parsing this data over and over for every single rendered glyph is a small performance improvement. Some very quick console.time/timeEnd benchmarking, with the default tracemonkey.pdf file, suggest that it's on average 1-2 ms faster per page, which obviously isn't a lot but still doesn't seem worthless.

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can observe the small perf improvement in the profiler too.
LGTM, thank you.

@Snuffleupagus Snuffleupagus merged commit 36967fc into mozilla:master Oct 20, 2022
@Snuffleupagus Snuffleupagus deleted the rm-matchesForCache branch October 20, 2022 08:35
@timvandermeij timvandermeij removed their request for review December 18, 2022 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants