stevedlawrence commented on a change in pull request #419:
URL: https://github.com/apache/incubator-daffodil/pull/419#discussion_r488072309
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/InfosetWalker.scala
##########
@@ -201,26 +229,60 @@ class InfosetWalker private (
* possible.
*
* It is an error to call walk() if isFinished returns true
+ *
+ * For performance reasons, sometimes a call to walk will intentionally not
+ * try to take any steps even if it is possible. This lets us essentially
+ * batch infoset events and improve performance. If this is the last time
+ * walk() will be called, the lastWalk parameter should be set to true, which
+ * will cause walk() to not skip any steps.
*/
- def walk(): Unit = {
+ def walk(lastWalk: Boolean = false): Unit = {
Assert.usage(!finished)
- var maybeNextStep: Maybe[InfosetWalkerStep] = Nope
- while ({
- maybeNextStep = getNextStep()
- maybeNextStep.isDefined
- }) {
- maybeNextStep.get.step()
+ if (walkSkipRemaining > 0 && !lastWalk) {
Review comment:
That's correct. The purpose of this is to avoid performing walks() when
progress wont' be made.
This algorithm is essentially donig "call only after some large N elements
are created" since we now only call walk after elements are created. It's a
little smarter since it increases N if we fail to make progress, and then
decreases once progress is made. Currently that N starts out at 32 and we
double each time progress isn't made up to a max of 2048.
We could also check it there are PoU's, but maybeDoStep essentially does
that, but also takes into account other kinds of blocks. This also allows us
to increase how many calls to walk we skip when this does detect that there's
somethign blocking from walking.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]