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

Issue 88113002: Speed up GrResourceCache lookup by inlining GrBinHashKey comparisons (Closed)

Created:
7 years ago by Kimmo Kinnunen
Modified:
7 years ago
Reviewers:
bsalomon, mtklein
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

Speed up GrResourceCache lookup by inlining GrBinHashKey comparisons The GCC compilers for Android and Ubuntu do not seem to be able to inline the memcmp operations on GrBinHashKey data. Write the comparisons manually. Also shortcut GrBinHashKey::EQ to skip comparison when hashes do not match. Speeds up grresourcecache_find test on ARM and x86_64. Speeds up grresourcecache_add on x86_64. In order to test the change, moves ad hoc Gr unit tests from src/gr_unittest.cpp to tests/GrUnitTests to be consistent with other tests and enables GrUnitTests. Fixes a regression from r2863 with where re-setting GrBinHashKey data would not set the hash correctly. This should also improve the hash function itself. The regression caused many of the hash operations be no-ops. This is caught by the unit test. Renames the comparison functions that GrHashTable needs from EQ, LT to Equals, LessThan. Renames GrTBinHashKey to GrBinHashKey. The GrTBinHashKey used to forward comparison functions to an ENTRY template class, which would extract the key and call back to the GrTBinHashKey. This would save the user from writing one comparison function when comparison was done with int ENTRY::compare(). There's no real benefit in this now. Also this was used only for one class (GrTextureStripAtlas). The other use in GrResourceKey was not actually using the provided "shortcut". The new GrBinHashKey is not templated with the entry, rather just provides == and < functions. The users of GrTHashTable provide the needed functions now. Adds explicit documentation of functions that are actually needed GrTHashTable for the Key template. Adds SK_DEBUG guards according to the contract. Committed: http://code.google.com/p/skia/source/detail?r=12426

Patch Set 1 #

Total comments: 12

Patch Set 2 : address review comments #

Total comments: 8

Patch Set 3 : address review comments (capitalized statics) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+117 lines, -213 lines) Patch
M gyp/gpu.gypi View 1 chunk +0 lines, -1 line 0 comments Download
M gyp/tests.gyp View 1 chunk +1 line, -0 lines 0 comments Download
M src/gpu/GrBinHashKey.h View 1 2 3 chunks +33 lines, -41 lines 0 comments Download
M src/gpu/GrResourceCache.h View 1 2 4 chunks +25 lines, -42 lines 0 comments Download
M src/gpu/GrTHashTable.h View 1 2 6 chunks +13 lines, -11 lines 0 comments Download
M src/gpu/GrTextStrike_impl.h View 1 2 2 chunks +4 lines, -4 lines 0 comments Download
M src/gpu/effects/GrTextureStripAtlas.h View 1 2 2 chunks +15 lines, -2 lines 0 comments Download
D src/gpu/gr_unittests.cpp View 1 chunk +0 lines, -80 lines 0 comments Download
A + tests/GrUnitTests.cpp View 1 2 4 chunks +22 lines, -25 lines 0 comments Download
M tests/HashCacheTest.cpp View 1 2 1 chunk +4 lines, -7 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
Kimmo Kinnunen
7 years ago (2013-11-26 12:39:51 UTC) #1
mtklein
I have only structural comments. The thrust of this CL looks great to me. For ...
7 years ago (2013-11-26 14:20:43 UTC) #2
bsalomon
Not directly part of this change, but should the benchs be marked as non-rendering? Running ...
7 years ago (2013-11-26 15:24:14 UTC) #3
Kimmo Kinnunen
Thanks for the review. How about this? https://codereview.chromium.org/88113002/diff/1/src/gpu/GrBinHashKey.h File src/gpu/GrBinHashKey.h (right): https://codereview.chromium.org/88113002/diff/1/src/gpu/GrBinHashKey.h#newcode55 src/gpu/GrBinHashKey.h:55: On 2013/11/26 ...
7 years ago (2013-11-27 08:16:54 UTC) #4
Kimmo Kinnunen
On 2013/11/26 15:24:14, bsalomon wrote: > Not directly part of this change, but should the ...
7 years ago (2013-11-27 08:19:53 UTC) #5
mtklein
I'm fine with that reasoning. I suppose what we ought to do is look at ...
7 years ago (2013-11-27 14:36:54 UTC) #6
bsalomon
My comments are purely cosmetic. I'm happy with the change. https://codereview.chromium.org/88113002/diff/20001/src/gpu/GrBinHashKey.h File src/gpu/GrBinHashKey.h (right): https://codereview.chromium.org/88113002/diff/20001/src/gpu/GrBinHashKey.h#newcode94 ...
7 years ago (2013-11-27 14:46:01 UTC) #7
Kimmo Kinnunen
Thanks! https://codereview.chromium.org/88113002/diff/20001/src/gpu/GrBinHashKey.h File src/gpu/GrBinHashKey.h (right): https://codereview.chromium.org/88113002/diff/20001/src/gpu/GrBinHashKey.h#newcode94 src/gpu/GrBinHashKey.h:94: uint32_t fData[KEY_SIZE / 4]; // Buffer for key ...
7 years ago (2013-11-28 07:38:34 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/kkinnunen@nvidia.com/88113002/40001
7 years ago (2013-11-28 08:12:39 UTC) #9
commit-bot: I haz the power
7 years ago (2013-11-28 08:24:33 UTC) #10
Message was sent while issue was closed.
Change committed as 12426

Powered by Google App Engine
This is Rietveld 408576698