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

Issue 761313004: Add a small LRU cache for the JBIG2 symbol dictionary. (Closed)

Created:
6 years ago by jab
Modified:
6 years ago
CC:
pdfium-reviews_googlegroups.com
Base URL:
https://pdfium.googlesource.com/pdfium.git@master
Visibility:
Public.

Description

Add a small LRU cache for the JBIG2 symbol dictionary. This reduces rendering time on my test document by over 10 seconds. It is super common for a JBIG2 dictionary to span multiple pages, so we don't want to decode the same dictionary over and over again. Original patch from Jeff Breidenbach (breidenbach@gmail.com) BUG=https://code.google.com/p/pdfium/issues/detail?id=85

Patch Set 1 : intial implementation #

Total comments: 16

Patch Set 2 : use list instead of vector #

Total comments: 2

Patch Set 3 : fix memory leak by calling destructor #

Patch Set 4 : indent with 4 spaces #

Total comments: 6

Patch Set 5 : use list of pairs #

Total comments: 4

Patch Set 6 : use typedef #

Total comments: 16

Patch Set 7 : style changes, tidy up comments #

Patch Set 8 : style changes, fix flaw with iterator #

Unified diffs Side-by-side diffs Delta from patch set Stats (+72 lines, -16 lines) Patch
M core/src/fxcodec/jbig2/JBig2_Context.cpp View 1 2 3 4 5 6 7 3 chunks +51 lines, -15 lines 0 comments Download
M core/src/fxcodec/jbig2/JBig2_SymbolDict.h View 1 chunk +1 line, -1 line 0 comments Download
M core/src/fxcodec/jbig2/JBig2_SymbolDict.cpp View 1 1 chunk +20 lines, -0 lines 0 comments Download

Messages

Total messages: 45 (4 generated)
Lei Zhang
6 years ago (2014-12-06 01:47:00 UTC) #2
Bo Xu
https://codereview.chromium.org/761313004/diff/1/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/1/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode815 core/src/fxcodec/jbig2/JBig2_Context.cpp:815: cache_keys.erase(cache_keys.begin()); Should line 815 be: "cache_keys.erase(it);" ? I guess ...
6 years ago (2014-12-06 05:59:44 UTC) #3
Bo Xu
In the tile and description of the issue, can you add a new line after ...
6 years ago (2014-12-07 19:22:50 UTC) #4
jab
Need help on freeing memory (see one of the comments). I also want to know ...
6 years ago (2014-12-08 21:00:03 UTC) #5
Bo Xu
Just wonder what is the performance increase by changing the cache size, like using 3, ...
6 years ago (2014-12-08 23:00:17 UTC) #6
jab
On 2014/12/08 23:00:17, Bo Xu wrote: > Just wonder what is the performance increase by ...
6 years ago (2014-12-08 23:19:00 UTC) #7
jab
https://codereview.chromium.org/761313004/diff/1/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/1/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode839 core/src/fxcodec/jbig2/JBig2_Context.cpp:839: CJBig2_SymbolDict *value = pSegment->m_Result.sd->DeepCopy(); I made an explicit call ...
6 years ago (2014-12-08 23:21:05 UTC) #8
Bo Xu
https://codereview.chromium.org/761313004/diff/1/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/1/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode839 core/src/fxcodec/jbig2/JBig2_Context.cpp:839: CJBig2_SymbolDict *value = pSegment->m_Result.sd->DeepCopy(); On 2014/12/08 23:21:04, breidenbach wrote: ...
6 years ago (2014-12-08 23:29:55 UTC) #9
jab
> I am thinking moving the static variables into CJBig2_Context, would that be > sufficient ...
6 years ago (2014-12-08 23:50:25 UTC) #10
Bo Xu
On 2014/12/08 23:50:25, jab wrote: > > I am thinking moving the static variables into ...
6 years ago (2014-12-09 00:23:05 UTC) #11
Bo Xu
On 2014/12/09 00:23:05, Bo Xu wrote: > On 2014/12/08 23:50:25, jab wrote: > > > ...
6 years ago (2014-12-09 00:24:49 UTC) #12
jab
> One more thing. Can you change the "Description" part too? Add new line after ...
6 years ago (2014-12-09 01:02:03 UTC) #13
Bo Xu
On 2014/12/09 01:02:03, jab wrote: > > One more thing. Can you change the "Description" ...
6 years ago (2014-12-09 01:06:54 UTC) #14
commit-bot: I haz the power
Commit queue rejected this change because it did not recognize the base URL. Please commit ...
6 years ago (2014-12-09 18:36:00 UTC) #17
Bo Xu
On 2014/12/09 18:36:00, I haz the power (commit-bot) wrote: > Commit queue rejected this change ...
6 years ago (2014-12-09 18:39:31 UTC) #18
jab
$ git cl land Invalid user name or password. Please generate a new password at: ...
6 years ago (2014-12-09 20:08:17 UTC) #19
Bo Xu
Oh, seems you still need permission. @Tom, can you advise?
6 years ago (2014-12-09 20:10:55 UTC) #21
jab
I'm totally cool with someone else submitting this change, if that makes life easier.
6 years ago (2014-12-09 20:15:18 UTC) #22
Bo Xu
On 2014/12/09 20:15:18, jab wrote: > I'm totally cool with someone else submitting this change, ...
6 years ago (2014-12-09 20:19:40 UTC) #23
jab
done
6 years ago (2014-12-09 20:41:30 UTC) #24
Tom Sepez
Jeff, have you signed a chromium contributors agreement?
6 years ago (2014-12-09 22:50:55 UTC) #25
Tom Sepez
https://codereview.chromium.org/761313004/diff/60001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/60001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode18 core/src/fxcodec/jbig2/JBig2_Context.cpp:18: const int kMaxCacheSize = 2; nit: Let's rename this ...
6 years ago (2014-12-10 00:14:46 UTC) #26
Tom Sepez
On 2014/12/09 22:50:55, Tom Sepez wrote: > Jeff, have you signed a chromium contributors agreement? ...
6 years ago (2014-12-10 00:17:12 UTC) #27
jab
All other changes will be made tomorrow as per reviewer request. https://codereview.chromium.org/761313004/diff/60001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): ...
6 years ago (2014-12-10 07:16:17 UTC) #28
Tom Sepez
On 2014/12/10 07:16:17, jab wrote: > All other changes will be made tomorrow as per ...
6 years ago (2014-12-10 18:00:17 UTC) #29
jab
https://codereview.chromium.org/761313004/diff/60001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/60001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode18 core/src/fxcodec/jbig2/JBig2_Context.cpp:18: const int kMaxCacheSize = 2; On 2014/12/10 00:14:46, Tom ...
6 years ago (2014-12-11 04:40:46 UTC) #30
Lei Zhang
https://codereview.chromium.org/761313004/diff/80001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/80001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode19 core/src/fxcodec/jbig2/JBig2_Context.cpp:19: static list<pair<FX_BYTE*, CJBig2_SymbolDict*> > symbol_dict_cache; You need std:: https://codereview.chromium.org/761313004/diff/80001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode19 ...
6 years ago (2014-12-12 00:01:21 UTC) #31
jab
https://codereview.chromium.org/761313004/diff/80001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/80001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode19 core/src/fxcodec/jbig2/JBig2_Context.cpp:19: static list<pair<FX_BYTE*, CJBig2_SymbolDict*> > symbol_dict_cache; On 2014/12/12 00:01:20, Lei ...
6 years ago (2014-12-13 01:46:41 UTC) #32
jab
Tracking bug filed against use of static memory for cache. https://code.google.com/p/pdfium/issues/detail?id=93
6 years ago (2014-12-13 01:50:28 UTC) #33
jab
If reviewers are happy, could someone either 1) "land" this changelist for me OR 2) ...
6 years ago (2014-12-15 17:22:24 UTC) #34
Bo Xu
On 2014/12/15 17:22:24, jab wrote: > If reviewers are happy, could someone either > > ...
6 years ago (2014-12-15 17:50:24 UTC) #35
Lei Zhang
https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode15 core/src/fxcodec/jbig2/JBig2_Context.cpp:15: // list keeps track of the freshness of enties, ...
6 years ago (2014-12-15 19:28:09 UTC) #36
Tom Sepez
Only nits, https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode12 core/src/fxcodec/jbig2/JBig2_Context.cpp:12: // common for a JBIG2 dictionary to ...
6 years ago (2014-12-15 19:58:14 UTC) #37
jab
https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode12 core/src/fxcodec/jbig2/JBig2_Context.cpp:12: // common for a JBIG2 dictionary to span multiple ...
6 years ago (2014-12-15 21:00:08 UTC) #38
jab
https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode810 core/src/fxcodec/jbig2/JBig2_Context.cpp:810: for(std::list<cache_pair>::iterator it = please let me know if there ...
6 years ago (2014-12-16 07:30:57 UTC) #39
Lei Zhang
https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp File core/src/fxcodec/jbig2/JBig2_Context.cpp (right): https://codereview.chromium.org/761313004/diff/100001/core/src/fxcodec/jbig2/JBig2_Context.cpp#newcode814 core/src/fxcodec/jbig2/JBig2_Context.cpp:814: symbol_dict_cache.erase(it); On 2014/12/15 21:00:08, jab wrote: > On 2014/12/15 ...
6 years ago (2014-12-16 08:19:32 UTC) #40
jab
Thank you for the very detailed explanation. >Oh, and you haven't actually swapped the two ...
6 years ago (2014-12-16 17:56:53 UTC) #41
Lei Zhang
lgtm
6 years ago (2014-12-16 19:38:57 UTC) #42
jab
Bo, now that there is an LGTM, could you please land this changelist?
6 years ago (2014-12-17 21:55:42 UTC) #43
Bo Xu
On 2014/12/17 21:55:42, jab wrote: > Bo, now that there is an LGTM, could you ...
6 years ago (2014-12-18 01:55:17 UTC) #44
Bo Xu
6 years ago (2014-12-18 03:17:39 UTC) #45
Message was sent while issue was closed.
On 2014/12/18 01:55:17, Bo Xu wrote:
> On 2014/12/17 21:55:42, jab wrote:
> > Bo, now that there is an LGTM, could you please land this changelist?
> 
> Thanks Jeff. I have committed and you can close this issue manually. 
> 
> Seems an empty line is needed before the "one line commit title" in the
> description, otherwise everything is shown in the log. Good to know for next
> time.

committed at:
https://pdfium.googlesource.com/pdfium/+/bf42dfea544a8ea3269b139e940f3f8eb38f...

Powered by Google App Engine
This is Rietveld 408576698