WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 86340
[CG] CGImageCreateWithImageInRect is too slow, but for now we still need to use it
https://bugs.webkit.org/show_bug.cgi?id=86340
Summary
[CG] CGImageCreateWithImageInRect is too slow, but for now we still need to u...
Darin Adler
Reported
2012-05-13 23:53:30 PDT
[CG] CGImageCreateImageWithRect is too slow, but for now we still need to use it
Attachments
First cut; needs performance testing
(6.49 KB, patch)
2012-05-13 23:57 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(7.58 KB, patch)
2012-05-14 20:20 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2012-05-13 23:57:12 PDT
Created
attachment 141653
[details]
First cut; needs performance testing
Darin Adler
Comment 2
2012-05-13 23:58:32 PDT
I suspect that calling TimerBase::start every time is too slow. Some other technique for clearing the cache when idle would probably be more efficient.
Tim Horton
Comment 3
2012-05-14 00:03:50 PDT
Hmm, is this using a cache size based on the number of subimages? I could see a pathological case where someone uses subimages which are nearly the entirety of a large image (or even comparatively small portions of a very large image), and suddenly their memory usage explodes. Can we base it on the total size of the cached subimages instead?
Darin Adler
Comment 4
2012-05-14 00:08:33 PDT
(In reply to
comment #3
)
> Hmm, is this using a cache size based on the number of subimages? I could see a pathological case where someone uses subimages which are nearly the entirety of a large image (or even comparatively small portions of a very large image), and suddenly their memory usage explodes. Can we base it on the total size of the cached subimages instead?
Subimages don’t copy the bits, so the sizes of the subimages are not relevant. The sizes of the base images might be relevant.
Tim Horton
Comment 5
2012-05-14 00:09:48 PDT
(In reply to
comment #4
)
> (In reply to
comment #3
) > > Hmm, is this using a cache size based on the number of subimages? I could see a pathological case where someone uses subimages which are nearly the entirety of a large image (or even comparatively small portions of a very large image), and suddenly their memory usage explodes. Can we base it on the total size of the cached subimages instead? > > Subimages don’t copy the bits, so the sizes of the subimages are not relevant. > > The sizes of the base images might be relevant.
Oh, that's comforting. I wonder why they're so slow to compute, then?
mitz
Comment 6
2012-05-14 00:14:12 PDT
Did you mean CGImageCreateWithImageInRect?
Darin Adler
Comment 7
2012-05-14 10:08:52 PDT
(In reply to
comment #5
)
> I wonder why they're so slow to compute, then?
I believe the issue is that they are made of multiple memory blocks and memory allocation and deallocation is costly even when the amounts of memory are small. But there may be other factors as well. Allocating and deallocating may be causing trouble with caching inside Core Graphics, for example.
Geoffrey Garen
Comment 8
2012-05-14 12:32:43 PDT
(In reply to
comment #2
)
> I suspect that calling TimerBase::start every time is too slow. Some other technique for clearing the cache when idle would probably be more efficient.
How about this: If timer is idle, start it for 1s, else: Set a flag saying "the next timer fire should just restart the timer instead of clearing the cache". This ensures only 1 timer start per second, which solves the cost of TimerBase::start. It has the negative side-effect of making the timer "sloppy". In the pathological case, if you create 1 subimage per second, you'll never clear the cache. This seems acceptable, since the pathological case is, in point of fact, getting value out of the cache, and the cache has an absolute bound at maxSubimageCacheSize.
Radar WebKit Bug Importer
Comment 9
2012-05-14 17:45:05 PDT
<
rdar://problem/11451243
>
Darin Adler
Comment 10
2012-05-14 20:20:56 PDT
Created
attachment 141846
[details]
Patch
Darin Adler
Comment 11
2012-05-14 20:21:41 PDT
We measured a significant speedup on the IE fish tank test; I think this is ready to land.
Geoffrey Garen
Comment 12
2012-05-15 00:31:10 PDT
Comment on
attachment 141846
[details]
Patch r=me
WebKit Review Bot
Comment 13
2012-05-15 09:22:10 PDT
Comment on
attachment 141846
[details]
Patch Clearing flags on attachment: 141846 Committed
r117083
: <
http://trac.webkit.org/changeset/117083
>
WebKit Review Bot
Comment 14
2012-05-15 09:22:15 PDT
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 15
2012-05-30 09:41:43 PDT
Later testing showed different results. I am no longer sure this is a speed-up and we may want to either turn it off or roll it out.
Simon Fraser (smfr)
Comment 16
2013-02-28 11:34:25 PST
I see subimage caching being expensive on
http://www.thewildernessdowntown.com
Darin Adler
Comment 17
2013-03-01 10:02:48 PST
Feel free to turn this off or roll this out as per my 2012-05-30 comment. Especially if we have test data indicating that’s the right thing to do.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug