skia2/include/gpu
kkinnunen 54b8511189 Make GrResourceCache perf less sensitive to key length change
Make GrResourceCache performance less sensitive to key length change.
The memcmp in GrResourceKey is called when SkTDynamicHash jumps the
slots to find the hash by a index. Avoid most of the memcmps by
comparing the hash first.

This is important because small changes in key data length can cause
big performance regressions. The theory is that key length change causes
different hash values. These hash values might trigger memcmps that
originally weren't there, causing the regression.

Adds few specialized benches to grresourcecache_add to test different
key lengths. The tests are run only on release, because on debug the
SkTDynamicHash validation takes too long, and adding many such delays
to development test runs would be unproductive. On release the tests
are quite fast.

Effect of this patch to the added tests on amd64:
grresourcecache_find_10  738us ->  768us        1.04x
 grresourcecache_find_2  472us ->  476us        1.01x
grresourcecache_find_25  841us ->  845us        1x
 grresourcecache_find_4  565us ->  531us        0.94x
grresourcecache_find_54 1.18ms ->  1.1ms        0.93x
 grresourcecache_find_5  834us ->  749us        0.9x
 grresourcecache_find_3  620us ->  542us        0.87x
 grresourcecache_add_25 2.74ms -> 2.24ms        0.82x
 grresourcecache_add_56 3.23ms -> 2.56ms        0.79x
 grresourcecache_add_54 3.34ms -> 2.62ms        0.78x
  grresourcecache_add_5 2.68ms ->  2.1ms        0.78x
 grresourcecache_add_10  2.7ms -> 2.11ms        0.78x
  grresourcecache_add_2 1.85ms -> 1.41ms        0.76x
    grresourcecache_add 1.84ms ->  1.4ms        0.76x
  grresourcecache_add_4 1.99ms -> 1.49ms        0.75x
  grresourcecache_add_3 2.11ms -> 1.55ms        0.73x
 grresourcecache_add_55   39ms -> 13.9ms        0.36x
grresourcecache_find_55 23.2ms -> 6.21ms        0.27x

On arm64 the results are similar.

On arm_v7_neon, the results lack the discontinuity at 55:
    grresourcecache_add 4.06ms -> 4.26ms        1.05x
  grresourcecache_add_2 4.05ms -> 4.23ms        1.05x
   grresourcecache_find 1.28ms ->  1.3ms        1.02x
grresourcecache_find_56 3.35ms -> 3.32ms        0.99x
 grresourcecache_find_2 1.31ms -> 1.29ms        0.99x
grresourcecache_find_54 3.28ms -> 3.24ms        0.99x
  grresourcecache_add_5 6.38ms -> 6.26ms        0.98x
 grresourcecache_add_55 8.44ms -> 8.24ms        0.98x
 grresourcecache_add_25 7.03ms -> 6.86ms        0.98x
grresourcecache_find_25  2.7ms -> 2.59ms        0.96x
 grresourcecache_find_4 1.45ms -> 1.38ms        0.95x
grresourcecache_find_10 2.52ms -> 2.39ms        0.95x
grresourcecache_find_55 3.54ms -> 3.33ms        0.94x
 grresourcecache_find_5  2.5ms -> 2.32ms        0.93x
 grresourcecache_find_3 1.57ms -> 1.43ms        0.91x

The extremely slow case, 55, is postulated to be due to the index jump
collisions running the memcmp. This is not visible on arm_v7_neon probably due
to hash function producing different results for 32 bit architectures.

This change is needed for extending path cache key in Gr
NV_path_rendering codepath. Extending is needed in order to add dashed
paths to the path cache.

Review URL: https://codereview.chromium.org/1132723003
2015-05-18 22:47:33 -07:00
..
effects Remove canTweakAlphaForCoverage from XP's since batch reads flag. 2015-05-04 12:58:16 -07:00
gl Add tokens and entry points for KHR_blend_equation_advanced 2015-04-22 10:39:03 -07:00
GrClip.h Remove rect clip type from grclip. 2015-03-06 08:21:39 -08:00
GrColor.h Add device space skshader GM to test kDevice_GrCoordSet 2014-12-29 07:05:27 -08:00
GrConfig.h Add flag to force gpu trace markers to be used and printed out for debugging. 2015-03-05 12:19:17 -08:00
GrContext.h add option to supress prints on context 2015-05-12 12:03:50 -07:00
GrCoordTransform.h some utils for rect and matrix 2015-03-13 06:08:28 -07:00
GrFragmentProcessor.h Pull out shader-specific caps into GrShaderCaps and GrGLSLCaps 2015-04-29 11:18:05 -07:00
GrFragmentStage.h removing coord change matrices 2014-12-29 09:04:40 -08:00
GrGpuResource.h Add mechanism to proactively purge old resources in GrResourceCache. 2015-04-08 11:01:55 -07:00
GrGpuResourceRef.h Simplify SkInstCnt 2015-01-13 08:22:44 -08:00
GrInvariantOutput.h Add constant color GrFP. 2015-04-02 11:12:09 -07:00
GrPaint.h Use SkXfermode as public facing enum for GrPorterDuffXP 2015-02-17 07:34:43 -08:00
GrPathRendererChain.h Extract gpu line dashing to GrDashLinePathRenderer 2015-04-26 23:18:50 -07:00
GrProcessor.h Remove GP from drawstate, revision of invariant output for GP 2014-12-11 15:44:02 -08:00
GrProcessorUnitTest.h create GrTestUtils.h, move some common functions into it 2015-04-28 13:31:18 -07:00
GrProgramElement.h Simplify SkInstCnt 2015-01-13 08:22:44 -08:00
GrRect.h Begin atlasing 2014-06-30 08:26:50 -07:00
GrRenderTarget.h Rename GrStencilBuffer to GrStencilAttachment 2015-04-16 11:22:42 -07:00
GrResourceKey.h Make GrResourceCache perf less sensitive to key length change 2015-05-18 22:47:33 -07:00
GrShaderVar.h Refactor position computation to enable device space "nudge" 2015-01-18 08:14:14 -08:00
GrSurface.h Make uncached textures uncached from the get go. 2015-01-14 10:42:08 -08:00
GrTestUtils.h GLProgramsTest 3.0 2015-05-13 08:51:50 -07:00
GrTexture.h C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
GrTextureAccess.h Simplify SkInstCnt 2015-01-13 08:22:44 -08:00
GrTextureProvider.h Revert of Refactor GrBufferAllocPools to use resource cache (patchset #9 id:160001 of https://codereview.chromium.org/1139753002/) 2015-05-14 05:24:53 -07:00
GrTypes.h Add assignment op to enum bitfield ops 2015-05-11 11:21:23 -07:00
GrTypesPriv.h add option to supress prints on context 2015-05-12 12:03:50 -07:00
GrUserConfig.h Replace GrResourceCache with GrResourceCache2. 2014-11-14 12:10:15 -08:00
GrXferProcessor.h Add function for logging blend info on XP. 2015-05-11 11:21:14 -07:00
SkGr.h new image from backend desc 2015-05-07 15:36:18 -07:00
SkGrPixelRef.h C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SkGrTexturePixelRef.h Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00