Bug 100706

Summary: [TexMap] Remove unused textures in the texture pool.
Product: WebKit Reporter: Dongseong Hwang <dongseong.hwang>
Component: Layout and RenderingAssignee: Dongseong Hwang <dongseong.hwang>
Status: RESOLVED FIXED    
Severity: Normal CC: noam, ossy, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 101404    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Dongseong Hwang 2012-10-29 15:25:13 PDT
Previously, we did not remove entries in the texture pool of TextureMapper.
The texture pool is destroyed when TextureMapper is destroyed. It means the texture pool consumed texture memory until its destruction.
This patch removes entries on endPainting() if the entries were unused in this frame: between startPainting() and endPainting().
Comment 1 Dongseong Hwang 2012-10-29 15:30:35 PDT
Created attachment 171324 [details]
Patch
Comment 2 Dongseong Hwang 2012-10-29 15:34:08 PDT
I think removing BitmapTextures is well if they are not used in this single frame. However, I do not think it is the best approach. I need your opinion :)
Comment 3 Noam Rosenthal 2012-10-29 15:38:05 PDT
(In reply to comment #2)
> I think removing BitmapTextures is well if they are not used in this single frame. However, I do not think it is the best approach. I need your opinion :)

I don't think we need a full-blown LRU. How about having a timer that removes the texture after a few seconds if it wasn't used again? Something like what we do with UpdateAtlas...
Comment 4 Dongseong Hwang 2012-10-29 15:39:32 PDT
Created attachment 171326 [details]
Patch
Comment 5 Dongseong Hwang 2012-10-29 15:42:22 PDT
(In reply to comment #3)
> (In reply to comment #2)
> I don't think we need a full-blown LRU. How about having a timer that removes the texture after a few seconds if it wasn't used again? Something like what we do with UpdateAtlas...

Ok, good idea. I'll try :)

Do you think what time threshold is proper? The threshold of UpdateAtlas is 3 seconds.
const double inactiveSecondsTolerance = 3;
Comment 6 Noam Rosenthal 2012-10-29 15:49:03 PDT
(In reply to comment #5)
> (In reply to comment #3)
> > (In reply to comment #2)
> > I don't think we need a full-blown LRU. How about having a timer that removes the texture after a few seconds if it wasn't used again? Something like what we do with UpdateAtlas...
> 
> Ok, good idea. I'll try :)
> 
> Do you think what time threshold is proper? The threshold of UpdateAtlas is 3 seconds.
> const double inactiveSecondsTolerance = 3;

3 is fine.
Comment 7 Noam Rosenthal 2012-10-30 17:41:29 PDT
Comment on attachment 171326 [details]
Patch

See above comments.
Comment 8 Dongseong Hwang 2012-10-30 19:50:31 PDT
Created attachment 171570 [details]
Patch
Comment 9 Dongseong Hwang 2012-10-30 19:55:50 PDT
(In reply to comment #6)
> 3 is fine.

Yes, It's done.

When I read your review, I wanted to remove the code recording used time of BitmapTexture. However, I can not remove the code because all BitmapTextures have one ref conut when release timer fires. We need the recent used time of BitmapTexture to determine which one can be removed.

In addition, I move the constructor and destructor of TextureMapper to TextureMapper.cpp because both need concrete BitmapTexturePool definition.
Comment 10 Noam Rosenthal 2012-11-02 11:06:56 PDT
Comment on attachment 171570 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=171570&action=review

Nice! See comments.

> Source/WebCore/ChangeLog:14
> +        Changing cache policy is not testabled in layout tests.

testabled -> testable

> Source/WebCore/platform/graphics/texmap/TextureMapper.cpp:36
> +    inline void use() { m_usedTime = monotonicallyIncreasingTime(); }

use -> markUsed

> Source/WebCore/platform/graphics/texmap/TextureMapper.cpp:37
> +    inline static bool compareLRU(const BitmapTexturePoolEntry& a, const BitmapTexturePoolEntry& b)

inline doesn't help you when you use it as a predicate.
Also, this should be called compareTimeLastUsed

> Source/WebCore/platform/graphics/texmap/TextureMapper.cpp:43
> +    double m_usedTime;

m_timeLastUsed
Comment 11 Dongseong Hwang 2012-11-02 20:16:18 PDT
Created attachment 172199 [details]
Patch
Comment 12 Dongseong Hwang 2012-11-02 20:16:54 PDT
(In reply to comment #10)
> (From update of attachment 171570 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=171570&action=review
> 
> Nice! See comments.
> 

Thanks for review!

> testabled -> testable
> use -> markUsed
> m_timeLastUsed

All done.
Comment 13 WebKit Review Bot 2012-11-06 07:12:46 PST
Comment on attachment 172199 [details]
Patch

Clearing flags on attachment: 172199

Committed r133601: <http://trac.webkit.org/changeset/133601>
Comment 14 WebKit Review Bot 2012-11-06 07:12:50 PST
All reviewed patches have been landed.  Closing bug.
Comment 15 Csaba Osztrogonác 2012-11-06 08:22:32 PST
(In reply to comment #13)
> (From update of attachment 172199 [details])
> Clearing flags on attachment: 172199
> 
> Committed r133601: <http://trac.webkit.org/changeset/133601>

It broke the Qt Windows build:
C:\WebKitBuildSlave\szeged-windows-1\qt-windows-32bit-release\build\Source\WebCore\platform\graphics\texmap\TextureMapper.cpp(61) : error C2864: 'WebCore::BitmapTexturePool::s_releaseUnusedSecondsTolerance' : only static const integral data members can be initialized within a class
C:\WebKitBuildSlave\szeged-windows-1\qt-windows-32bit-release\build\Source\WebCore\platform\graphics\texmap\TextureMapper.cpp(62) : error C2864: 'WebCore::BitmapTexturePool::s_releaseUnusedTexturesTimerInterval' : only static const integral data members can be initialized within a class


Could you fix it, please?
Comment 16 Csaba Osztrogonác 2012-11-06 13:16:48 PST
ping?
Comment 17 Noam Rosenthal 2012-11-06 14:12:46 PST
I think it's still pretty early in Korea. If we can't wait for Dongsung, feel free to roll out.
Comment 18 Dongseong Hwang 2012-11-06 14:49:11 PST
(In reply to comment #17)
> I think it's still pretty early in Korea. If we can't wait for Dongsung, feel free to roll out.

Sorry.
I'm here, and I'll fix immediately!
Comment 19 Dongseong Hwang 2012-11-06 15:52:26 PST
(In reply to comment #18)
> I'm here, and I'll fix immediately!

I filed Bug 101404 and posted a patch.

Additionally, if you are in CA, your time - 8 is Korea time :)