Refactor LazyDOMQueryResultIterator 09/93409/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 26 Oct 2020 18:29:11 +0000 (19:29 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 27 Oct 2020 00:39:47 +0000 (01:39 +0100)
commitb3cdddfccdc045d0ba9c0bd8bd3c6d6a58ca57b5
tree5c6fe8c6227550e902a03c999d0cc6116eaf7f83
parent3f76010e3f3aa66c3b295549d0be25cd431fa108
Refactor LazyDOMQueryResultIterator

Rework the logic to keep minimum stack allocations. Whereas we used
stack for keeping the decision state and traverse all entries, here
we keep an explicit stack with state.

We mutate the state using a "simple" sstateful dispatch, where we
are are carefully peeling the various possibilities. This logic is
one large method due to 'current' being manipulated and non-local
returns.

This improves test case performance by more than a factor-of-two,
easily beating linear search by a wide margin.

For clarity we have two classes of Frames, one dealing with MapNode's
children and the other one taking care of all the other nodes. While
this might cause bimorphic invocation of Frame.hasNext(), the overall
effect on clarity is immense.

We also change match() a bit, to take predicates, as it is all that
it should be interested in.

JIRA: MDSAL-610
Change-Id: I7136c6297cc66832539d1bb3d9f653968eb7bdb1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9cea2c0be2e893075c4ad99142e6b5d7ca511527)
binding/mdsal-binding-dom-adapter/src/test/java/org/opendaylight/mdsal/binding/dom/adapter/query/QueryPerformanceTest.java
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/query/DOMQueryEvaluator.java
dom/mdsal-dom-spi/src/main/java/org/opendaylight/mdsal/dom/spi/query/LazyDOMQueryResultIterator.java