issue-#72 speeding up the dump of large data structures
Posted: Tue Sep 29, 2015 1:25 pm
This issue is about an optimization in the generation of the post mortem dump of large data structures,
in particular for large arrays allocated on the stack. If such an array contains structured elements
(arrays or records) this involves a large number of StdFold.Flip operations, which in turn call the
TextModels.StdContext.Pos operation several times. The TextModels.StdContext.Pos operation
uses a linear search and the resulting runtime behavior is quadratic.
For the issue see http://redmine.blackboxframework.org/issues/72.
A proposal for a fix exists in CPC 1.7 rc5.
However, the proposal has several drawbacks.
It uses a separate stack for avoiding the Flip operation. This stack has a fixed size and thereby
is too large in most cases and too small in the extreme case of very deeply nested data structures.
The stack is also hard to understand but in principle it works.
Note that there is no need for such a stack because of the recursive
structure of the dump procedures. The stack can be maintained easily
inside the recursive dump procedures which is simpler to read and avoids a fixed
size auxiliary stack.
For the changes based on the pproposal in CPC 1.7 rc5 but without an explicit stack see http://redmine.blackboxframework.org/pr ... 3cd5beae40.
- Josef
in particular for large arrays allocated on the stack. If such an array contains structured elements
(arrays or records) this involves a large number of StdFold.Flip operations, which in turn call the
TextModels.StdContext.Pos operation several times. The TextModels.StdContext.Pos operation
uses a linear search and the resulting runtime behavior is quadratic.
For the issue see http://redmine.blackboxframework.org/issues/72.
A proposal for a fix exists in CPC 1.7 rc5.
However, the proposal has several drawbacks.
It uses a separate stack for avoiding the Flip operation. This stack has a fixed size and thereby
is too large in most cases and too small in the extreme case of very deeply nested data structures.
The stack is also hard to understand but in principle it works.
Note that there is no need for such a stack because of the recursive
structure of the dump procedures. The stack can be maintained easily
inside the recursive dump procedures which is simpler to read and avoids a fixed
size auxiliary stack.
For the changes based on the pproposal in CPC 1.7 rc5 but without an explicit stack see http://redmine.blackboxframework.org/pr ... 3cd5beae40.
- Josef