Closed
Bug 104999
Opened 23 years ago
Closed 23 years ago
Avoid keeping redundant image data in memory
Categories
(Core :: Graphics: ImageLib, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla0.9.9
People
(Reporter: cathleennscp, Assigned: pavlov)
References
Details
(Keywords: memory-footprint, perf)
Attachments
(3 files, 5 obsolete files)
20.44 KB,
patch
|
Details | Diff | Splinter Review | |
759 bytes,
patch
|
Details | Diff | Splinter Review | |
1.94 KB,
patch
|
dcone
:
review+
waterson
:
superreview+
|
Details | Diff | Splinter Review |
in our current drawing code, we should not keep 2 copies of images around, both DIB and raw RGB data. It is costing a lot of memory.
Comment 1•23 years ago
|
||
Can you repeat that in a way that us non-Unix and non-Windows weenies can understand? DIB?
We are keeping both device independent bitmaps (DIB) data and Red Green Blue
(RGB) code around for drawing. This is taking too much memory.
According to waterson's profiling:
>
> Images appear to account for about 40% of the memory used to load a recent
> version of www.cnn.com; about 1.2MB on that page (see
> <news://news.mozilla.org/3BC49184.4030708@netscape.com>). This could be
> especially sucky if we're keeping two copies of the image data around (e.g., on
> Windows: one copy as a DIB and one copy as our own RGB data; on Linux: one copy
> in the X server and one copy in our address space).
>
Pavlov is trying to figure out a way to make drawing code work, with just one
copy of the img data.
Comment 3•23 years ago
|
||
DIB may be the wrong term -- at the Intel meeting, the proposal was to put image data in the graphics card and keep the CPU from having to load and store to push pixels. Images in graphics cards sound like DDB to me, but what do I know? The savings here, just to clarify, are in better L2 cache hit rate, and in fewer cycles spent in the CPU messing with pixel data, as well as in RAM. /be
Assignee | ||
Comment 4•23 years ago
|
||
r=timeless w/ @param that isn't there removed [@@ -167,6 +161,19 @@] from comment. and assertion text [@@ -221,6 +227,10 @@] changed. I'm 99% sure that's backwards. I think this [@@ -209,6 +213,8 @@] is also backwards.
Comment 6•23 years ago
|
||
Ajust summary so I can understand the bug. Sorry pav.
Summary: make drawing code optimal → Avoid keeping redudant image data in memory
Assignee | ||
Comment 7•23 years ago
|
||
Assignee | ||
Comment 8•23 years ago
|
||
Comment on attachment 54045 [details] [diff] [review] first patch to clean up/add new method to gfxIImageFrame this patch has been checked in
Attachment #54045 -
Flags: superreview+
Attachment #54045 -
Flags: review+
Comment 9•23 years ago
|
||
In imgContainer.cpp: + nsCOMPtr<nsIInterfaceRequestor> ireq(do_QueryInterface(mCompositingFrame)); + if (ireq) { + nsCOMPtr<nsIImage> img(do_GetInterface(ireq)); + img->SetDecodedRect(0, 0, mSize.width, mSize.height); + } no need to QI mConpositingFrame to nsIInterfaceRequestor, do_GetInterface() does that for you. And how about null checking |img| after calling do_GetInterface()? sr=jst with that fixed.
Status: NEW → ASSIGNED
Comment 10•23 years ago
|
||
Never mind about the nsIInterfaceRequestor and do_GetInterface(), you need the QI for using do_GetInterface() due to a lame implementation of do_GetInterface().
Assignee | ||
Updated•23 years ago
|
Attachment #54178 -
Flags: superreview+
Comment 11•23 years ago
|
||
Comment on attachment 54178 [details] [diff] [review] another small patch >Index: decoders/jpeg/nsJPEGDecoder.cpp >=================================================================== >RCS file: /cvsroot/mozilla/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp,v >retrieving revision 1.36 >diff -u -r1.36 nsJPEGDecoder.cpp >--- nsJPEGDecoder.cpp 2001/10/12 06:43:41 1.36 >+++ nsJPEGDecoder.cpp 2001/10/19 03:11:37 >@@ -865,6 +865,7 @@ > src->decoder->mObserver->OnStopContainer(nsnull, nsnull, src->decoder->mImage); > src->decoder->mObserver->OnStopDecode(nsnull, nsnull, NS_OK, nsnull); > } >- >- /* No work necessary here */ >+ if (src->decoder->mFrame) { >+ src->decoder->mFrame->SetMutable(PR_FALSE); >+ } > } Don't need that null check. >Index: src/imgContainer.cpp >=================================================================== >RCS file: /cvsroot/mozilla/modules/libpr0n/src/imgContainer.cpp,v >retrieving revision 1.15 >diff -u -r1.15 imgContainer.cpp >--- imgContainer.cpp 2001/09/05 21:28:00 1.15 >+++ imgContainer.cpp 2001/10/19 03:11:38 >@@ -162,10 +165,14 @@ > (numFrames >= 1)) // Not sure if I want to create a composite frame for every anim. Could be smarter. > { > mCompositingFrame = do_CreateInstance("@mozilla.org/gfx/image/frame;2"); >- mCompositingFrame->Init(0, 0, mSize.width, mSize.height, gfxIFormats::RGB_A1); >- nsCOMPtr<nsIImage> img(do_GetInterface(mCompositingFrame)); >- img->SetDecodedRect(0, 0, mSize.width, mSize.height); >- >+ mCompositingFrame->Init(0, 0, mSize.width, mSize.height, gfxIFormats::RGB_A1); >+ >+ nsCOMPtr<nsIInterfaceRequestor> ireq(do_QueryInterface(mCompositingFrame)); Bwegh. I still say you should just null-check |img| (and we'll have to remove that assertion in |nsGetInterface::operator()|). But whatever, as long as I don't see this code here a month from now, r=jag.
Attachment #54178 -
Flags: superreview+ → review+
Comment 12•23 years ago
|
||
jst: the only thing lame about the implementation of do_GetInterface is the assertion.
Assignee | ||
Comment 13•23 years ago
|
||
Comment on attachment 54178 [details] [diff] [review] another small patch patch checked in
Attachment #54178 -
Flags: superreview+
Assignee | ||
Comment 14•23 years ago
|
||
Assignee | ||
Updated•23 years ago
|
Attachment #55037 -
Attachment is obsolete: true
Assignee | ||
Comment 15•23 years ago
|
||
Assignee | ||
Comment 16•23 years ago
|
||
OK. So here's what this patch does: It makes nsRenderingContextWin communicate with gfx2's gfxIImageFrame(Win) directly to draw images. I've checked in a new image impl (nsImageWin replacement) into gfx2/src/windows as not part of the build. This patch has a makefile change to get this stuff to be built. "What problems will this patch introduce" you might ask. 1) Tiling on Windows95 (only) will be broken since it only supports 8x8 patterns. I'll be working on this in the next day or so. 2) Printing... I hate printing... Not all printing is broken, but enough is. The basic problem with printing at this point is that since gfxImageFrameWin stores images (that it can) as DDBs and throws away the DIB data, there is no hope of restoring the original data. What this means is that printing needs to redecode the image. What this is going to require is some changes to the way images are cached, and could potentially result in somewhat of a slowdown, however I am unsure of how big of one at this point. The changes this contains are: - Have a 2 step cache. Step 1 would look for images on the screen. It would probably be a simple hashtable lookup. Step 2 would be to look in the actual memory cache for decoded image data, not as a stream, but as a chunk of data, to decode all at once, when needed. What this allows us to do is to get the original image, out of the memory cache, redecode and convert it to a DDB (or leave it as a DIB) depending on if the printer device supports this. --- The less correct (but much easier) way to solve this would be to just use GetDIBits on the DDB and convert it back to a DIB. This isn't as correct as there may be data loss between the DDB to DIB conversion, however, it may be "good enough" for now. I will look in to doing it this way first since it shouldn't take long.
Comment 17•23 years ago
|
||
Suggestion: can the images be dumped to the disk cache then loaded to memory on print? Which is where most of the images are stored anyway, right or no? maybe instead of creating a conversion routine? -dennis
Updated•23 years ago
|
Summary: Avoid keeping redudant image data in memory → Avoid keeping redundant image data in memory
Assignee | ||
Updated•23 years ago
|
Priority: -- → P1
Assignee | ||
Updated•23 years ago
|
Comment 18•23 years ago
|
||
I remember one of the concerns with this scheme and printing, is that DDBs contain just enough data to display the image on the screen as well as the screen is able. Since printers can have a higher resolution/colour depth, we need the DIB data to print the picture most accurately. How are you dealing with this?
Comment 19•23 years ago
|
||
Replying to the above concern, here is a possibility. When it first goes to a page and downloads the image data, Mozilla could store only one copy of each image, the smaller copy, in memory. Whenever a user prints a page, the images could be downloaded again to get the richer image data. It is reasonable to assume that images will continue to reside on servers, even though time passes between when the page is downloaded and when it is printed. I'm not sure, but I think Netscape 4.x did it this way. Apologies in advance if this is spam.
Assignee | ||
Comment 20•23 years ago
|
||
We can't get the data back from the server, but we can "reload" it from the cache (think dynamically generated images). I'm considering changing the way the image cache works to store the original image around in cases where there are no refs to the image anymore.. not entirely sure yet.
Assignee | ||
Updated•23 years ago
|
Target Milestone: mozilla0.9.7 → mozilla0.9.8
Assignee | ||
Comment 21•23 years ago
|
||
New rendering context code to take advantage of the gfx2 gfxImageFrameWin code.
Attachment #54045 -
Attachment is obsolete: true
Attachment #54178 -
Attachment is obsolete: true
Attachment #55039 -
Attachment is obsolete: true
Assignee | ||
Comment 22•23 years ago
|
||
Patch to gfx2 to make the new windows code be built. You will want to remove *gfx2* from components.
Assignee | ||
Comment 23•23 years ago
|
||
This patch makes the gfxImageFrame code call Optimize on the nsIImage
Assignee | ||
Updated•23 years ago
|
Target Milestone: mozilla0.9.8 → mozilla0.9.9
Comment 24•23 years ago
|
||
That patch did not post.
Assignee | ||
Comment 25•23 years ago
|
||
Attachment #65524 -
Attachment is obsolete: true
Comment 26•23 years ago
|
||
Comment on attachment 66329 [details] [diff] [review] Patch to call Optimize() r=dcone
Attachment #66329 -
Flags: review+
Comment 27•23 years ago
|
||
Comment on attachment 66329 [details] [diff] [review] Patch to call Optimize() sr=waterson
Attachment #66329 -
Flags: superreview+
Comment 28•23 years ago
|
||
Could we please get an update to the Optimize() comment in nsIImage.h? Something which explains the purpose of this method and what guarantees Optimize() makes, for example: 1. Should you delete the Mozilla-native image and alpha data? (newbie question) 2. Are subsequent calls to GetBits() and GetAlphaBits() permitted (return nsnull or assert)? 3. Should subsequent calls to ImageUpdated() assert?
Keywords: mozilla0.9.9
Reporter | ||
Comment 29•23 years ago
|
||
some test data on pav's patch... using in98, 64MB 200mHz page-load: trunk (1/29) 2646 2645 2647 --> avg 2646 ms w/ patch 2617 2633 2645 --> avg 2631 ms ----------------- diff 15 ms ( -0.5%) memory: trunk (1/29) Data KB 20,000 20,124 20,424 Code KB 9,596 9,596 9,596 w/patch Data KB 14,472 15,500 15,504 Code KB 9,596 9,596 9,596 (showing reduction in Data KB)
Comment 30•23 years ago
|
||
Sweet! Lets get this puppy checked in for 0.9.9! Great work, Pav!
Comment 31•23 years ago
|
||
Since this looks like a massive footpring win for Windows, any chance for this for Unix/X11 builds? It might even improve remote-X11 performance (less data transfer to redraw the screen).
Assignee | ||
Comment 32•23 years ago
|
||
I'm changing the platform of this bug to windows. marking it fixed. tor is currently working on a patch that would basically do the same thing on linux. I don't recall the bug number off the top of my head, but I will find it.
OS: All → Windows 2000
Hardware: All → PC
Assignee | ||
Comment 33•23 years ago
|
||
fixed
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Comment 34•23 years ago
|
||
Bug 121015 is the bug for the nsImageGTK work starting along this path.
Comment 35•23 years ago
|
||
Is this an issue on the Macintosh (Fizzilla for example) ?
Comment 36•23 years ago
|
||
No so much. We don't have much control over where the image bits go on Mac. There are some flags for NewGWorld, but we don't use GWorlds for images (because of their overhead).
Comment 37•23 years ago
|
||
Did the patch get pushed to the trunk? I can't find the bug number or the file to be modified, gfxImageFrame.cpp, in the recent checkins (2/6/02-2/20/02)
Assignee | ||
Comment 38•23 years ago
|
||
i checked it in earlier than 2/6/02 i believe.
Comment 39•23 years ago
|
||
http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=MozillaTinderboxAll&branch=HEAD&branchtype=match&dir=&file=gfxImageFrame.cpp&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=month&mindate=&maxdate=&cvsroot=%2Fcvsroot 01/30/2002 14:17
Comment 40•22 years ago
|
||
is it fixed? I saw no patch for other platform. IMO, some gfx code are platform depend, but some are platform independ. Now I only see patch for independ code and win specific code, no patch for other platform.
You need to log in
before you can comment on or make changes to this bug.
Description
•