none
Decreasing performance of content generation in Word 2010 RRS feed

  • Question

  • Hello!

    I'm developing a document level addin (template) for Word 2010, in which the user can add rich text content controls, which are automatically populated by a data source with tables, nested tables, HTML content, text and images. Each generated content is styled too (table styles, paragraph styles, custom background colors, etc.). The generated content can also be cleared.

    When the user clears and fills the content controls several times, the performance decreases each iteration by the factor 1.5. If the first content generation takes 1 min, the second one does 1.5 min, the third one 2.25 etc. The addin suffered from increasing memory consumption, which happened due to a growing undo stack. Fortunately, by clearing the undo stack, memory consumption stays almost the same (slight increase).

    Do you have any ideas why this is happening? I'm still not sure what type of generated content affects the performance reduction the most, but literally every operation gets slower each iteration.

    [edit]

    I finally managed to reproduce the performance reduction. The code can be found here: https://gist.github.com/dde9609fe324d71ea90b. A complete project can be downloaded from http://dl.dropbox.com/u/9917425/Word.PerformanceReduction.zip.

    [/edit]

    Regards,
    Oliver Hanappi



    • Edited by Oliver Hanappi Friday, March 2, 2012 7:10 AM Updated download link
    Wednesday, February 22, 2012 5:49 PM

All replies

  • Hi Oliver,

    Thank you for posting.

    How many content controls did you add? I think that it is normal if you add too many content controls. Can you show us your code so that we can analyze it and give you the suggestions?

    In addition, I want to give you some references about how to use some tools to analyze the performance of .Net code:

    http://msdn.microsoft.com/en-us/magazine/hh288073.aspx
    http://www.codeproject.com/Articles/18745/Profiling-the-Performance-of-a-NET-Application

    I hope this can give you some hint and just feel free to follow up after you have tried.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    Monday, February 27, 2012 6:57 AM
  • Hi!

    I finally reproduced the performance reduction. See the edit in the thread for details.

    Regards,
    Oliver Hanappi

    Monday, February 27, 2012 7:46 AM
  • Hi Oliver Hanappi,

    Thank you for posting.

    I found difficult to give the suggestions about the performance issue, I will help you involve others to help you. There might be some delay about the response. Appreciate your patience.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, March 1, 2012 9:51 AM
  • Hello Oliver,

    Your description of the issue sounds like no other Forum
    issue or support case for Word 2010. In an effort to see the  demonstration of the issue I tried to download that using the link to rapidshare. The link to the site containing the complete
    project zip did not work using Windows 7 and IE 9.0.

    A different approach to resolving the performance issue is to take advantage of
    the benefits of XML. The links below are to several sites that discuss using
    XML in Word 2010 documents. Please consider whether the concepts in the
    discussions will empower you to solve the performance issue.

    Building Document Generation Systems from Templates with
    Word 2010 and Word 2007
    http://msdn.microsoft.com/en-us/library/ff433638.aspx

    Using Open Office XML to Improve Automation Performance in
    Word 2010 for Large Amounts of Data
    http://msdn.microsoft.com/en-us/library/ff191178.aspx

    Using XML Mapping as Part of a Document Generation Solution
    in Word 2010
    http://msdn.microsoft.com/en-us/library/gg605188.aspx

    Regards,
    Chris Jensen
    Senior Technical Support Lead







    Chris Jensen

    Thursday, March 1, 2012 9:39 PM
    Moderator
  • Hi!

    I'm sorry for the broken link, I uploaded it now on Dropbox, which should work this time.

    I will definitely look into the XML binding capabilities for my further projects, but due to the current project status, I cannot make such a technology shift anymore.

    What's interesting about my issue is, that each run the performance decreases more. This is somehow strange, because after filling and then clearing the content controls, the state of the application should be exactly the same as before. So why is there a performance reduction?

    Regards,
    Oliver Hanappi

    Friday, March 2, 2012 7:20 AM
  • Hello Oliver,

    Searching for specific references to “Content Controls” and performance produced an earlier case where
    the Forum posting said the  customer
    discovered his undo stack grew so that the performance suffered, and clearing
    the undo stack resolved the issue.

    Word 2007 - Content Controls – Performance
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/a904c64b-cbae-4904-9a7f-b9c5bd5aa770/

    About undo
    UndoManager.UndoStackFlushed Event (Microsoft.VisualStudio ...

    http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.modeling.undomanager.undostackflushed.aspx


    More on undo is in this thread:
    Word Interop: Control undo of control insertion
    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/bbc1948b-d0fb-4de2-9e70-a0be611ef733/

    Your issue suggests that the heap is jamming performance and
    in addition to clearing the undo stack you may alleviate the problem by
    managing Garbage Collection.

    See the discussion of Heap management in the following article:
    Debugging Memory Problems - MSDN – Explore Windows, Web, Cloud ...
    http://msdn.microsoft.com/en-us/library/ee817660.aspx

    Please let us know if this information helps you find the
    solution and let us know which ones were relevant.

    Regards,
    Chris Jensen
    Senior Technical Support Lead


    Chris Jensen

    • Proposed as answer by Bruce Song Monday, March 5, 2012 1:21 AM
    • Unproposed as answer by Oliver Hanappi Monday, March 12, 2012 3:14 PM
    Friday, March 2, 2012 8:52 PM
    Moderator
  • Hi Chris,

    I investigated the heap and some other performance counters, but they seem to look fine.

    However, I traced back the problem to applying styles on rows of a table. Performance decreases when the table is within a content control, but not if the table is just placed in the document. See this example for details (you need to perform the styling up to 20 times to see the effect, in my real application there are many tables, therefore the effect occurs faster).

    Regards,
    Oliver Hanappi

    Monday, March 12, 2012 8:49 AM
  • Is there anything I can do in order to prevent the performance reduction?
    Tuesday, March 13, 2012 8:50 AM
  • Hello Oliver,

    Perhaps you might consider changing the design of your document. Do you need to position the tables in content controls?

    Regards,
    Chris Jensen
    Senior Technical Support Lead


    Chris Jensen

    Tuesday, March 13, 2012 8:50 PM
    Moderator