Skip to content

Change WorkerTransport.{pageCache, pagePromises} from an Array to a Map #14355

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

Merged
merged 2 commits into from
Dec 11, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

  • Change WorkerTransport.pageCache from an Array to a Map

    Given that not all pages necessarily are being accessed, or that the pages may be accessed out of order, using a Map seems like a more appropriate data-structure here.
    For one thing, this simplifies iteration since we no longer have to worry about/check if pageCache-entries are undefined (which will happen for sparse Arrays).

    Of particular note is that we're no longer attempting to "null" the pageCache-entry from within the PDFPageProxy._destroy-method. Given that synchronous JavaScript will always run to completion[1] and that we're looping through all pages in WorkerTransport.destroy and immediately clear the cache afterwards, that code did/does not really make a lot of sense (as far as I can tell).

    Finally, also changes the pageCache to a private property since it's not supposed to be accessed from the "outside".


    [1] Unless there are errors, of course.

  • Change WorkerTransport.pagePromises from an Array to a Map

    Given that not all pages necessarily are being accessed, or that the pages may be accessed out of order, using a Map seems like a more appropriate data-structure here.

    Finally, also changes the pagePromises to a private property since it's not supposed to be accessed from the "outside".

Given that not all pages necessarily are being accessed, or that the pages may be accessed out of order, using a `Map` seems like a more appropriate data-structure here.
For one thing, this simplifies iteration since we no longer have to worry about/check if `pageCache`-entries are undefined (which will happen for *sparse* `Array`s).

Of particular note is that we're no longer attempting to "null" the `pageCache`-entry from within the `PDFPageProxy._destroy`-method. Given that *synchronous* JavaScript will always run to completion[1] and that we're looping through all pages in `WorkerTransport.destroy` and immediately clear the cache afterwards, that code did/does not really make a lot of sense (as far as I can tell).

Finally, also changes the `pageCache` to a *private* property since it's not supposed to be accessed from the "outside".

---
[1] Unless there are errors, of course.
Given that not all pages necessarily are being accessed, or that the pages may be accessed out of order, using a `Map` seems like a more appropriate data-structure here.

Finally, also changes the `pagePromises` to a *private* property since it's not supposed to be accessed from the "outside".
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2021

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/d265567a867b1e3/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2021

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/0fe5f0fdbf1ceaf/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/d265567a867b1e3/output.txt

Total script time: 21.80 mins

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

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

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2021

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/0fe5f0fdbf1ceaf/output.txt

Total script time: 41.68 mins

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

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

@timvandermeij timvandermeij merged commit 70809a8 into mozilla:master Dec 11, 2021
@timvandermeij
Copy link
Contributor

Looks good to me!

@Snuffleupagus Snuffleupagus deleted the api-page-caches-Map branch December 11, 2021 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants