-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Slightly simplify the lookup of data in Dict.{get, getAsync, has}
#11672
Slightly simplify the lookup of data in Dict.{get, getAsync, has}
#11672
Conversation
Note that `Dict.set` will only be called with values returned through `Parser.getObj`, and thus indirectly via `Lexer.getObj`. Since neither of those methods will ever return `undefined`, we can simply assert that that's the case when inserting data into the `Dict` and thus get rid of `in` checks when doing the data lookups. In this case, since `Dict.set` is fairly hot, the patch utilizes an *inline check* and when necessary a direct call to `unreachable` to not affect performance of `gulp server/test` too much (rather than always just calling `assert`). For very large and complex PDF files this will help performance *slightly*, since `Dict.{get, getAsync, has}` is called *a lot* during parsing in the worker. This patch was tested using the PDF file from issue 2618, i.e. http://bugzilla-attachments.gnome.org/attachment.cgi?id=226471, with the following manifest file: ``` [ { "id": "issue2618", "file": "../web/pdfs/issue2618.pdf", "md5": "", "rounds": 250, "type": "eq" } ] ``` which gave the following results when comparing this patch against the `master` branch: ``` -- Grouped By browser, stat -- browser | stat | Count | Baseline(ms) | Current(ms) | +/- | % | Result(P<.05) ------- | ------------ | ----- | ------------ | ----------- | --- | ----- | ------------- Firefox | Overall | 250 | 2838 | 2820 | -18 | -0.65 | faster Firefox | Page Request | 250 | 1 | 2 | 0 | 11.92 | slower Firefox | Rendering | 250 | 2837 | 2818 | -19 | -0.65 | faster ```
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/4bfa16f962f5530/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/e974483767d1592/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/e974483767d1592/output.txt Total script time: 19.31 mins
Image differences available at: http://54.67.70.0:8877/e974483767d1592/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/4bfa16f962f5530/output.txt Total script time: 24.54 mins
Image differences available at: http://54.215.176.217:8877/4bfa16f962f5530/reftest-analyzer.html#web=eq.log |
Looks like a good improvement to me. Thank you! |
Note that
Dict.set
will only be called with values returned throughParser.getObj
, and thus indirectly viaLexer.getObj
. Since neither of those methods will ever returnundefined
, we can simply assert that that's the case when inserting data into theDict
and thus get rid ofin
checks when doing the data lookups.In this case, since
Dict.set
is fairly hot, the patch utilizes an inline check and when necessary a direct call tounreachable
to not affect performance ofgulp server/test
too much (rather than always just callingassert
).For very large and complex PDF files this will help performance slightly, since
Dict.{get, getAsync, has}
is called a lot during parsing in the worker.This patch was tested using the PDF file from issue 2618, i.e. http://bugzilla-attachments.gnome.org/attachment.cgi?id=226471, with the following manifest file:
which gave the following results when comparing this patch against the
master
branch: