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

Convert the RefSet primitive to a proper class and use a Set internally #11977

Merged
merged 1 commit into from
Jun 7, 2020

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented Jun 7, 2020

The RefSet primitive predates ES6, so that most likely explains why an object is used internally to track the entries. However, nowadays we can use built-in JavaScript sets for this purpose. Built-in types are often more efficient/optimized and using it makes the code a bit more clear since we don't have to assign true to keys anymore just to indicate their presence.

@timvandermeij
Copy link
Contributor Author

/botio test

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

Really sorry, but I'm not at all keen on these changes!

The RefSet abstraction is, as its name suggests, written specifically to operate only on Ref objects and I worry that simply using Sets directly in this manner makes the code more difficult to read/modify and that bugs are thus much easier to introduce.
Essentially, in the worker, it's generally preferable to avoid depending directly on the stringified version of a Ref object if possible.

Basically, unless there's test-cases where benchmarking shows clear improvements, then I'd ask that we please don't make these changes.

@timvandermeij timvandermeij changed the title Remove the RefSet primitive Convert the RefSet primitive to a proper class and use a Set internally Jun 7, 2020
…rnally

The `RefSet` primitive predates ES6, so that most likely explains why an
object is used internally to track the entries. However, nowadays we can
use built-in JavaScript sets for this purpose. Built-in types are often
more efficient/optimized and using it makes the code a bit more clear
since we don't have to assign `true` to keys anymore just to indicate
their presence.
@mozilla mozilla deleted a comment from pdfjsbot Jun 7, 2020
@mozilla mozilla deleted a comment from pdfjsbot Jun 7, 2020
@mozilla mozilla deleted a comment from pdfjsbot Jun 7, 2020
@mozilla mozilla deleted a comment from pdfjsbot Jun 7, 2020
@timvandermeij
Copy link
Contributor Author

I understand your concern here. I have updated the patch to keep RefSet, but instead refactor it to use a set internally instead of an object. Would that be better?

@timvandermeij
Copy link
Contributor Author

/botio unittest

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/4854668430355f4/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Windows)


Received

Command cmd_unittest from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/c20eaf2ff4ed819/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/4854668430355f4/output.txt

Total script time: 3.80 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/c20eaf2ff4ed819/output.txt

Total script time: 4.76 mins

  • Unit Tests: Passed

@Snuffleupagus
Copy link
Collaborator

I have updated the patch to keep RefSet, but instead refactor it to use a set internally instead of an object. Would that be better?

Yes, that seems completely fine by me; thank you for doing this!

(Also, possibly this could make RefSet.has() more efficient since I recall some older issues where avoiding in usage helped performance.)


Just for good measure, let's run all tests :-)

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/1979b1a308982ec/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/e02fe9cb07f91ff/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/1979b1a308982ec/output.txt

Total script time: 25.59 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/1979b1a308982ec/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Jun 7, 2020

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/e02fe9cb07f91ff/output.txt

Total script time: 27.78 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

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

@timvandermeij timvandermeij merged commit a4fa455 into mozilla:master Jun 7, 2020
@timvandermeij timvandermeij deleted the refset branch June 7, 2020 21:15
@Snuffleupagus
Copy link
Collaborator

An idea could be to try and do something similar, but obviously with a Map instead, for the RefSetCache; I'd happily review such a patch :-)

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