Issue 21107 - more efficient GC usage ...
Summary: more efficient GC usage ...
Status: CLOSED FIXED
Alias: None
Product: gsl
Classification: Code
Component: code (show other issues)
Version: OOo 1.1 RC4
Hardware: PC Linux, all
: P3 Trivial (vote)
Target Milestone: OOo 1.1.2
Assignee: philipp.lohmann
QA Contact: issues@gsl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-13 09:33 UTC by mmeeks
Modified: 2004-01-27 10:31 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
vcl speedup (3.18 KB, patch)
2003-10-13 09:34 UTC, mmeeks
no flags Details | Diff
sample image (1.31 KB, image/gif)
2003-10-13 16:11 UTC, mmeeks
no flags Details
a different approach (3.63 KB, patch)
2003-10-14 14:26 UTC, mmeeks
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description mmeeks 2003-10-13 09:33:34 UTC
Currently we do a number of extraneous X server round-trips per bitmap rendered
which is unfortunate; there should be no need to have quite so much GC thrash; [
indeed possibly, we could have a DDB cache that would avoid needing to call
XCreatePixmap too often ] anyway; this gives a nice speedup:
Comment 1 mmeeks 2003-10-13 09:34:04 UTC
Created attachment 10251 [details]
vcl speedup
Comment 2 philipp.lohmann 2003-10-13 09:46:44 UTC
accepted
Comment 3 christof.pintaske 2003-10-13 09:52:20 UTC
just for curiosity, have you measured any speedup ? about four years
ago we had a "sophisticated" cache for GCs. I removed it completely. I
measured that there's no impact on performance, even on remote displays.

why do you consider this P2 ?
Comment 4 mmeeks 2003-10-13 13:38:24 UTC
Sure; the problem is that doing a separate AlphaMask render for each
icon shows that this path is taking siginificant time; doing an strace
shows there is a large amount of redundant X server round-trip
traffic; taking a handful of milliseconds per icon: for the ~50 or so
visible icons that's quite a hit.

Of course - really, we need X-render support, but getting this right
first would be nice I guess.

As for P2 - I've no idea how priorities work, but my experience is of
bugs festering unassigned for a long time ;-)
Comment 5 christof.pintaske 2003-10-13 13:56:00 UTC
> Sure; the problem is that doing a separate AlphaMask render for 
> each icon shows that this path is taking siginificant time; 
> doing an strace shows there is a large amount of redundant X 
> server round-trip traffic; taking a handful of milliseconds 
> per icon: for the ~50 or so visible icons that's quite a hit.

ok

> Of course - really, we need X-render support, but getting 
> this right first would be nice I guess.

sigh

> As for P2 - I've no idea how priorities work, but my 
> experience is of bugs festering unassigned for a long 
> time ;-)

unfortunately we have a severe scalability issue with this method :-)
Comment 6 mmeeks 2003-10-13 16:10:21 UTC
Urk - as I suspected, I know nothing about GCs - and this patch in
fact quite badly screws up some image rendering.

eg. the attached image inserted into a writer document renders
awefully; I suspect the problem is that we want .foreground=1,
.background=0 and not the strange set of other options that the CopyGC
/ MonoGC give us by default;

Bother.
Comment 7 mmeeks 2003-10-13 16:11:01 UTC
Created attachment 10268 [details]
sample image
Comment 8 mmeeks 2003-10-13 17:57:56 UTC
Here is my strace of the DrawAlphaMask method in action:

[pid 20025] 1066062908.345510 access("get bitmap", F_OK) = -1 ENOENT
(No such file or directory)
[pid 20025] 1066062908.345697 write(6,
"6\20\2\0\336\1\240\2;\3\5\0009\0\240\2\0\0\0\0\r\2\37\0"..., 1104) = 1104
[pid 20025] 1066062908.346471 read(6,
"\16\0\214-!\0\240\2\0\0>\0\351\1\0\0 \0\0\0\336\1\240\2"..., 32) = 32
[pid 20025] 1066062908.346668 read(6,
"\1\0\300-\3\0\0\0$\0\0\0\1\0\0\1\377\377\377\377\0\0\0"..., 32) = 32
[pid 20025] 1066062908.346764 read(6,
"\177\200\353\0\177\200\353\0\0\0\267\10", 12) = 12
[pid 20025] 1066062908.346844 read(6,
"\1\20\301-\0\0\0\0H\0\0\0\5\0\27\0S\4\233\3\0\0\0\0\310"..., 32) = 32
[pid 20025] 1066062908.347021 access("done get bitmap", F_OK) = -1
ENOENT (No such file or directory)
[pid 20025] 1066062908.347176 write(6,
"5\20\4\0\342\1\240\2!\0\240\2\30\0\30\0007\0\4\0\343\1"..., 88) = 88
[pid 20025] 1066062908.347704 read(6,
"\16r\304-\342\1\240\2\0\0>\10\320\1\0\0E\0\0\0\30\0\0\0"..., 32) = 32
[pid 20025] 1066062908.347852 read(6, "\1\20\306-
\1\0\0\0\0\0\0\320\214\203\10\25\0\0\0\270["..., 32) = 32
[pid 20025] 1066062908.347953 readv(6,
[{"\276\367\276\367\276\367\276\367\276\367\276\367\276\367"...,
1152}, {"", 0}], 2) = 1152
[pid 20025] 1066062908.348369 access("done composite", F_OK) = -1
ENOENT (No such file or directory)
[pid 20025] 1066062908.348633 write(6,
"6\20\2\0\342\1\240\2;\3\5\0P\0\240\2\0\0\0\0\0\0>\0S\4"..., 1272) = 1272
[pid 20025] 1066062908.349125 access("done draw", F_OK) = -1 ENOENT
(No such file or directory)

Looks like there's something very odd happening; it _looks_ like we
push all the image data to the server, then get it back again, then do
the composite, then push it back to the server;

The 'access' syscalls are added thus:

@@ -1498,7 +1501,9 @@ void OutputDevice::ImplDrawAlpha( const 
                {
                        GDIMetaFile*    pOldMetaFile = mpMetaFile;
mpMetaFile = NULL;
                        const BOOL              bOldMap = mbMap; mbMap
= FALSE;
+                       access( "get bitmap", 0 );
                        Bitmap                  aBmp( GetBitmap(
aDstRect.TopLeft(), aDstRect.GetSize() ) );
+                       access( "done get bitmap", 0 );
 
             // #109044# The generated bitmap need not necessarily be
             // of aDstRect dimensions, it's internally clipped to
@@ -1685,11 +1690,13 @@ void OutputDevice::ImplDrawAlpha( const 
                                                }
                                        }
                                }
-
                                ( (Bitmap&) rBmp ).ReleaseAccess( pP );
                                ( (AlphaMask&) rAlpha ).ReleaseAccess(
pA );
                                aBmp.ReleaseAccess( pB );
+                               access( "done composite", 0 );
+
                                DrawBitmap( aDstRect.TopLeft(), aBmp );
+                               access( "done draw", 0 );
                        }
 
                        delete[] pMapX;

Any ideas ? [ it seems we have to do the CreateGC's for the new X
resources we create unfortunately ]
Comment 9 philipp.lohmann 2003-10-14 09:34:13 UTC
I think we do not have to create new GCs every time. If the CopyGC and
MonoGC from SalDisplay do not suffice, another buffered GC on the
SalDisplay should do.

As for the getting/putting images, i'll have to have a look.
Comment 10 mmeeks 2003-10-14 14:25:33 UTC
Sigh; so - I'm not convinced this is really a problem whatsoever after
more careful inspection - at least, for my high-color display.

I've re-hashed the patch, this time to avoid the sequence: GetBitmap,
AcquireBuffer ... do composite ... -> DrawBitmap which was doing:

CreatePixmap, CopyPixmap [GetBitmap]
CreateImage, GetImage from Pixmap -> DIB [AcquireBuffer]
DIB -> drawable [DrawBitmap]

But with this patch - I believe does:
Create Image, GetImage from Drawable [GetBitmap]
<nothing> [ AcquireBuffer ]
DIB -> drawable [ DrawBitmap ]

Which sounds more efficent - but while (of course) perceptibly one
hopes it's improved, emperically the strace doesn't show anything too
amazing;

Anyhow; sorry for all this spam for such an ill-defined advantage.
Comment 11 mmeeks 2003-10-14 14:26:19 UTC
Created attachment 10306 [details]
a different approach
Comment 12 philipp.lohmann 2003-10-31 12:55:00 UTC
commited in CWS vcl7pp1r3
Comment 13 philipp.lohmann 2003-11-13 13:17:46 UTC
verified changes are in CWS vcl7pp1r3
Comment 14 philipp.lohmann 2004-01-27 10:31:39 UTC
merged in 645m25s1