Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Issue 2251333002: Use a map for app::m_Timers (Closed)

Created:
4 years, 4 months ago by dsinclair
Modified:
4 years, 4 months ago
Reviewers:
Tom Sepez, Lei Zhang
CC:
pdfium-reviews_googlegroups.com, npm
Base URL:
https://pdfium.googlesource.com/pdfium.git@master
Target Ref:
refs/heads/master
Project:
pdfium
Visibility:
Public.

Description

Use a map for app::m_Timers Currently the timers is a vector. When we cancel a timer we have an O(n) operation to remove the timer. If there are a lot of timers (which this test has > 16k) this can take a long time. The impact is a lot lower in Release, but the test is very slow in Debug. From Linux on waterfall: [ RUN ] FPDFFormFillEmbeddertest.BUG_634716 [ OK ] FPDFFormFillEmbeddertest.BUG_634716 (7855 ms) From Linux try bot: [ RUN ] FPDFFormFillEmbeddertest.BUG_634716 [ OK ] FPDFFormFillEmbeddertest.BUG_634716 (431 ms) From Linux XFA Rel GYP on waterfall: [ RUN ] FPDFFormFillEmbeddertest.BUG_634716 [ OK ] FPDFFormFillEmbeddertest.BUG_634716 (185 ms) From Linux XFA Rel GYP try bot: [ RUN ] FPDFFormFillEmbeddertest.BUG_634716 [ OK ] FPDFFormFillEmbeddertest.BUG_634716 (72 ms) Committed: https://pdfium.googlesource.com/pdfium/+/2eb7c7dd6392488d858989da8d57d618f58f04ca

Patch Set 1 #

Total comments: 6

Patch Set 2 : Review feedback #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+15 lines, -14 lines) Patch
M fpdfsdk/javascript/app.h View 1 2 chunks +2 lines, -1 line 0 comments Download
M fpdfsdk/javascript/app.cpp View 1 4 chunks +13 lines, -13 lines 2 comments Download

Messages

Total messages: 21 (12 generated)
dsinclair
PTAL. This is probably not a huge issue in the wild as I'd be surprised ...
4 years, 4 months ago (2016-08-18 03:29:04 UTC) #5
Lei Zhang
Nice find. https://codereview.chromium.org/2251333002/diff/1/fpdfsdk/javascript/app.cpp File fpdfsdk/javascript/app.cpp (right): https://codereview.chromium.org/2251333002/diff/1/fpdfsdk/javascript/app.cpp#newcode553 fpdfsdk/javascript/app.cpp:553: m_Timers[timerRef] = std::move(timer); Can this be a ...
4 years, 4 months ago (2016-08-18 06:16:19 UTC) #8
dsinclair
https://codereview.chromium.org/2251333002/diff/1/fpdfsdk/javascript/app.cpp File fpdfsdk/javascript/app.cpp (right): https://codereview.chromium.org/2251333002/diff/1/fpdfsdk/javascript/app.cpp#newcode553 fpdfsdk/javascript/app.cpp:553: m_Timers[timerRef] = std::move(timer); On 2016/08/18 06:16:19, Lei Zhang wrote: ...
4 years, 4 months ago (2016-08-18 13:30:55 UTC) #11
Lei Zhang
lgtm
4 years, 4 months ago (2016-08-18 16:55:00 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2251333002/20001
4 years, 4 months ago (2016-08-18 16:58:04 UTC) #16
commit-bot: I haz the power
Committed patchset #2 (id:20001) as https://pdfium.googlesource.com/pdfium/+/2eb7c7dd6392488d858989da8d57d618f58f04ca
4 years, 4 months ago (2016-08-18 16:58:24 UTC) #18
Tom Sepez
https://codereview.chromium.org/2251333002/diff/20001/fpdfsdk/javascript/app.cpp File fpdfsdk/javascript/app.cpp (right): https://codereview.chromium.org/2251333002/diff/20001/fpdfsdk/javascript/app.cpp#newcode553 fpdfsdk/javascript/app.cpp:553: m_Timers[timerRef] = std::move(timer); This feels strange, mapping a pointer ...
4 years, 4 months ago (2016-08-18 17:17:43 UTC) #19
Lei Zhang
On 2016/08/18 17:17:43, Tom Sepez wrote: > https://codereview.chromium.org/2251333002/diff/20001/fpdfsdk/javascript/app.cpp > File fpdfsdk/javascript/app.cpp (right): > > https://codereview.chromium.org/2251333002/diff/20001/fpdfsdk/javascript/app.cpp#newcode553 ...
4 years, 4 months ago (2016-08-18 17:18:56 UTC) #20
dsinclair
4 years, 4 months ago (2016-08-18 17:20:21 UTC) #21
Message was sent while issue was closed.
https://codereview.chromium.org/2251333002/diff/20001/fpdfsdk/javascript/app.cpp
File fpdfsdk/javascript/app.cpp (right):

https://codereview.chromium.org/2251333002/diff/20001/fpdfsdk/javascript/app....
fpdfsdk/javascript/app.cpp:553: m_Timers[timerRef] = std::move(timer);
On 2016/08/18 17:17:43, Tom Sepez wrote:
> This feels strange, mapping a pointer to itself, Why isn't this just
> std::set<std::unique_ptr<GlobalTimer> > ???


If this was a set I'd have the same issue as before in that it would be a linear
search to find the GlobalTimer* in the remove method. I need the key to be the
pointer, but we want the unique_ptr for the memory cleanup happy-ness.

Powered by Google App Engine
This is Rietveld 408576698