Skip to content

Support flattening deeply nested keyword structures memory efficiently with --FlattenKeywords #1551

Closed

Description

@spooning

Originally submitted to Google Code by @pekkaklarck on 23 Oct 2013

Being able to create new keywords based on existing ones is one of the biggest strengths of Robot Framework. When these nested keyword structures grow very deep, logging information related to them (start and end times, etc.), and parsing that information starts to consume quite a bit of memory.

This is a problem especially when Rammbock library where protocols are defined using nested keywords. Same problem can obviously occur also with other libraries or when using for loops, Wait Until Keyword Succeeds, or some other similar structures.

An earlier solution to mitigate this problem is --RemoveKeywords option. It has two problems, though:

  1. Also messages logged by those keywords are removed. This is not always desirable.

  2. Removing keywords cannot generically be done when parsing output.xml, and thus the peak memory usage is not reduced.

We have decided to implement a new option --FlattenKeywords that will solve both of the above problems:

  1. This option will keep all messages, recursively, inside the flattened keyword. The flattened keyword will thus get all the messages its child keywords had. Those child keywords will be removed otherwise.

  2. Because flattening does not remove messages, it can always be done while parsing XML. This can significantly reduce memory consumption.

In the beginning --FlattenKeywords will support only removing keywords based on names. Because new flattening options may be added later, specifying the name must be done like --FlattenKeywords NAME:<pattern> similarly as when removing keywords based on names ( issue 1480 ).

Activity

  1. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @spooning on 24 Oct 2013

    This issue was updated by revision 2107d1d1f08f.

    Initial implementation based on a standalone script I wrote earlier.
    Integrating that functionality to the core turned out to be rather
    straightforward. Plenty of tasks still to do, though:

    1. Require patterns to be given as NAME:<pattern>. Currently given values are
      used as-is.

    2. Tests.

    3. --help documentation

    4. UG documentation.

  2. added this to the 2.8.2 milestone on Jun 30, 2014
  3. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @spooning on 5 Nov 2013

    This issue was updated by revision 2b7005f2ac93.

    Added atests and required NAME: prefix. Still need to handle invalid values
    and write docs.

  4. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @spooning on 5 Nov 2013

    This issue was updated by revision 17768b654c56.

    Error handling.

  5. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @spooning on 5 Nov 2013

    This issue was updated by revision 43f156558cf4.

    --help added

  6. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @spooning on 5 Nov 2013

    This issue was updated by revision 6ec3d53d3e33.

    User Guide documentation done. And so is this issue.

  7. spooning commented on Jun 30, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 17 Nov 2013

    This issue was updated by revision 973498ee961a.

    Fixed setting the message about flattening. elem.text should not be modified during the start event, only at the end!

    Interestingly this bug only failed our tests on IronPython. With other parsers the text apparently was always fully read already at the start. It could have failed also elsewhere so good that it was spotted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions