You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "Peter B. West" <pb...@tpg.com.au> on 2004/10/14 23:28:00 UTC

[Fwd: Re: Performance improvement in property consumption.]

Don't mind the delay.  Too many email addresses in a futile attempt to 
keep one spam-clean.  Apologies to Christian.

-------- Original Message --------
Subject: Re: Performance improvement in property consumption.
Date: Thu, 14 Oct 2004 08:29:24 +1000
From: Peter B. West <pb...@pbw.id.au>
To: fop-dev@xml.apache.org
References: <20...@web60104.mail.yahoo.com>

Glen,

The principles were applied in alt-design nearly two years ago now.  It
is at least good to see that someone has applied them to HEAD.

Glen Mazza wrote:
> --- Finn Bock <bc...@worldonline.dk> wrote:
> 
>>>So if we did this at the FO level, in effect, we'd
>>>have to (1) store an instance variable of every
>>
>>valid
>>
>>>property for each FO, given that we wouldn't know
>>>whether the FOEventHandler's needs it beforehand,
>>
>>and
>>
>>Yes. Which is massively more efficient than storing
>>the exact same 
>>properties in a PropertyList.
>>
> 
> 
> Why is it more efficient (I know it is, given your
> metrics, but want to know why)--aren't you just moving
> the values already stored in the PropertyList into
> separate fields in the FO objects?  Yes, you're
> releasing the PropertyList's memory, but the elements
> that the PropertyList previously stored are now stored
> in the FObj.  
> 
> So if PropertyList can be thought of as a C-like
> struct holding the values of its FObj's properties,
> what you're doing appears to be just taking that
> struct's member variables and moving them to the FObj.
> 
> But, obviously, given the performance/memory boost
> you're noting, PropertyList *can't* be regarded as a
> C-like struct.  Why?  Could PropertyList be made more
> efficient instead of this change--make it more like a
> C-like struct?
> 

It's a mixed bag, by the look of it.  From the patch, applying to FOText:

+    // The value of properties relevant for character.
+    private CommonFont commonFont;
+    private CommonHyphenation commonHyphenation;
+    private ColorType color;
+    private Property letterSpacing;
+    private SpaceProperty lineHeight;
+    private int whiteSpaceCollapse;
+    private int textTransform;
+    private Property wordSpacing;
+    private int wrapOption;
+
+    // End of property values
+

+    public FOText(char[] chars, int start, int end, FONode parent) {
          super(parent);
          endIndex = end - start;
          this.ca = new char[endIndex];
          System.arraycopy(chars, start, ca, 0, endIndex);
  //      System.out.println("->" + new String(ca) + "<-");
-        textInfo = ti;
+    }
+

+    public void bind(PropertyList pList) {
+        commonFont = pList.getFontProps();
+        commonHyphenation = pList.getHyphenationProps();
+
+        color = pList.get(Constants.PR_COLOR).getColorType();
+        lineHeight = pList.get(Constants.PR_LINE_HEIGHT).getSpace();
+        letterSpacing = pList.get(Constants.PR_LETTER_SPACING);
+        whiteSpaceCollapse =
pList.get(Constants.PR_WHITE_SPACE_COLLAPSE).getEnum();
+        textTransform = pList.get(Constants.PR_TEXT_TRANSFORM).getEnum();
+        wordSpacing = pList.get(Constants.PR_WORD_SPACING);
+        wrapOption = pList.get(Constants.PR_WRAP_OPTION).getEnum();
+    }
+

Note the combination of simple fields for whiteSpaceCollapse and more
complex structures like CommonFont.

Alt-design just uses a sparse array, constructed at END_ELEMENT.  Space
savings are progressively realized as the depth of the FO Tree reduces.
  Maximum consumption occurs at the points of greatest depth of the
tree, minima at the end of each page-sequence.

Finn has gone a step further, and collapsed the property structures into
local variables, which is good for both memory consumption and speed, at
the cost of some more code.  IIUC.

Peter
-- 
Peter B. West <http://cv.pbw.id.au/>


Re: [Fwd: Re: Performance improvement in property consumption.]

Posted by Chris Bowditch <bo...@hotmail.com>.
Clay Leeds wrote:

<snip/>

> When I look at the FOP Compliance page, I see a couple of items which 
> are implemented (I assume this page is in reference to the 
> 0_20_2-maintain CVS branch--I am I correct in this assumption?).

Hi Clay - yes compliance page does refer to 0.20.5 functionality.

<snip/>

Chris


Re: [Fwd: Re: Performance improvement in property consumption.]

Posted by Clay Leeds <cl...@medata.com>.
On Oct 15, 2004, at 1:02 PM, Finn Bock wrote:
> [Clay]
>
>> Which of the alignment-* property is the one you're referring to that 
>> has been implemented?
>
> I was just looking at them from the point of view of the property 
> subsystem, where only "baseline-shift" has been implemented. I didn't 
> mean to imply that it actually work all the way through layout.
>
> regards,
> finn

That's fine... I saw that, and wondered which. Thanks for letting me 
know!

Web Maestro Clay
-- 
Clay Leeds - <cl...@medata.com>
Webmaster/Developer - Medata, Inc. - <http://www.medata.com/>
PGP Public Key: <https://mail.medata.com/pgp/cleeds.asc>


Re: [Fwd: Re: Performance improvement in property consumption.]

Posted by Finn Bock <bc...@worldonline.dk>.
[Clay]

> Which of the alignment-* property is the one you're referring to that 
> has been implemented?

I was just looking at them from the point of view of the property 
subsystem, where only "baseline-shift" has been implemented. I didn't 
mean to imply that it actually work all the way through layout.

regards,
finn

Re: [Fwd: Re: Performance improvement in property consumption.]

Posted by Clay Leeds <cl...@medata.com>.
On Oct 15, 2004, at 12:05 AM, Finn Bock wrote:
<snip>
> In the rest of the elements, the set of fields matches the spec. The 
> only exception is a bug where the some of the inline LayoutManagers 
> uses "vertical-align" which is a shorthand. The layoutmanagers should 
> instead use the properties that the shorthand sets: 
> alignment-baseline, alignment-adjust, baseline-shift and 
> dominant-baseline. But since only one of these properties has been 
> implemented yet, I choose to keep the use of "vertical-align" for now.

When I look at the FOP Compliance page, I see a couple of items which 
are implemented (I assume this page is in reference to the 
0_20_2-maintain CVS branch--I am I correct in this assumption?).

alignment-adjust - no

alignment-baseline - no

baseline-shift - partial (see * below)
* Only values "super" and "sub" have been implemented.

display-align - yes - (partial extended conformance--see ** below)
** Implemented only for table-cell and block-container.
** For table-cell, the "height" attribute must be set for the parent 
table-row; setting the height of the table or the table-cell results in 
vertical centering having no effect.

dominant-baseline - no

relative-align - yes - no

Which of the alignment-* property is the one you're referring to that 
has been implemented?

Web Maestro Clay
-- 
Clay Leeds - <cl...@medata.com>
Webmaster/Developer - Medata, Inc. - <http://www.medata.com/>
PGP Public Key: <https://mail.medata.com/pgp/cleeds.asc>


Re: [Fwd: Re: Performance improvement in property consumption.]

Posted by Finn Bock <bc...@worldonline.dk>.
>> Why is it more efficient (I know it is, given your
>> metrics, but want to know why)--aren't you just moving
>> the values already stored in the PropertyList into
>> separate fields in the FO objects?  Yes, you're
>> releasing the PropertyList's memory, but the elements
>> that the PropertyList previously stored are now stored
>> in the FObj. 
>> So if PropertyList can be thought of as a C-like
>> struct holding the values of its FObj's properties,
>> what you're doing appears to be just taking that
>> struct's member variables and moving them to the FObj.
>>
>> But, obviously, given the performance/memory boost
>> you're noting, PropertyList *can't* be regarded as a
>> C-like struct.  Why?  Could PropertyList be made more
>> efficient instead of this change--make it more like a
>> C-like struct?

[Peter]

> It's a mixed bag, by the look of it.  From the patch, applying to FOText:
> 
> +    // The value of properties relevant for character.
> +    private CommonFont commonFont;
> +    private CommonHyphenation commonHyphenation;
> +    private ColorType color;
> +    private Property letterSpacing;
> +    private SpaceProperty lineHeight;
> +    private int whiteSpaceCollapse;
> +    private int textTransform;
> +    private Property wordSpacing;
> +    private int wrapOption;
> +
> +    // End of property values
> 
> Note the combination of simple fields for whiteSpaceCollapse and more
> complex structures like CommonFont.

I really like the combination of CommonXXX structures and simple fields, 
since it litterally matches the spec. Except that the spec doesn't have 
a FOText element so it is a bad example for me to use. The fields in 
FOText was taken from TextInfo and I suspect that eventually more fields 
will be needed in FOText.

In the rest of the elements, the set of fields matches the spec. The 
only exception is a bug where the some of the inline LayoutManagers uses 
"vertical-align" which is a shorthand. The layoutmanagers should instead 
use the properties that the shorthand sets: alignment-baseline, 
alignment-adjust, baseline-shift and dominant-baseline. But since only 
one of these properties has been implemented yet, I choose to keep the 
use of "vertical-align" for now.

> Alt-design just uses a sparse array, constructed at END_ELEMENT.  Space
> savings are progressively realized as the depth of the FO Tree reduces.
>  Maximum consumption occurs at the points of greatest depth of the
> tree, minima at the end of each page-sequence.

IIRC your sparse array does not just contain the relevant properties for 
an element (those listed in the spec under each fo:element), but the 
joined set of all properties relevant for all the allowed children. If 
this is correct, the sparse arrays stores more properties and uses more 
memory than my proposal does.

> Finn has gone a step further, and collapsed the property structures into
> local variables, which is good for both memory consumption and speed, at
> the cost of some more code.  IIUC.

Correct. In addition I also get a certain level of typesafeness for the 
properties.

regards,
finn