• Keine Ergebnisse gefunden

Taking a closer look at the data access of our XPath operations, three involved data regions can be identified:

• the context setCS,

• the set of all nodesNS, the axis step is performed over, combined with their postorder or level ranks.

• the result setRS of the operation.

TheNSdata region has to be further constrained, as many of the operations do not entirely scan the table, but start and stop the traversal depending on the first and last pruned context nodes. NScsthus denotes the context bounded part of the node set.

Besides the cardinalities, the sizes of single data itemsCS,NScs,RSalso vary, depending on the data types of the BATs. In the Monet database, the doc -leveltable of typehvoid,chri, being the node set of the child, parent, and sibling operations, comes with a record size of 1 byte, whereas the doc prepost relation for the major XPath axes requires 4 byte to store a single hvoid,oidientry.

4.2.1 Determining a Generic Access Pattern

All data regions are processed by thes trav(R) pattern. However, not all the data within the regions is actually touched. When considering skipping effects for the void-versions of the axis step operations, further interrupts occur in the traversal

ofNScs. As a skipped region possibly exceeds the cache line size Zi, skipping may significantly reduce the total number of accessed cache lines.

Correcting the model, we use a specialized version of the single sequential traver-sal, thes trav(R, u) pattern, whereudenotes the size of the used part of each record.

IfR−u < Zi, the gap between two adjacent accesses is smaller than a single cache line, all cache lines covered by Rhave to be loaded, and s trav(R, u) falls back to s trav(R). In the other case, for gaps larger than a single cache line, each item access requires loading ofdZuiecache lines. More precisely, due to cache alignment additional misses are caused, resulting in a total of:

Mi(s trav(R, u)) =|R| ∗ u

Zi

+(u−1)mod Zi

Zi

(4.3) (see [Man02] for detailed discussion of the presented formula).

Modeling skipping effects in the NScs traversal with the s trav(R, u) pattern needs further explanation. The basic idea in this case is to regard a scanned block together with the following skipped area as a record consisting of a needed and unused part, respectively. For distinct notation, we useNScs instead ofNScswhen thinking of a data partitioning in|NScs|records having the average size ofNScs, in contrast to the|NScs|nodes of size NScs. |NScs| is determined by the number of skipssin theNScs traversal. Furthermore, knowing the number of nodest, which are indeed touched during the scan, we can determineu as the average size of the skipped regions:

NScs = |NScs| ∗NScs

s , (4.4)

u = t∗NScs

s . (4.5)

Figure 4.1 shows the data regionNScsand its modeled derivationNScs. Notice that the usage of average sizes assumes a uniform distribution of the scanned data blocks and equal-sized gaps in between. In comparison, varying gap sizes of the real distribution slightly increase the probability of skipping entire cache lines. The effect revealed to have a considerable impact on estimation errors, however, without compact information on the real skip sizes available, we can only simulate the effect.

Partitioning ofNScs allows to consider varying skip sizes, one for each part. In order to keep the calculation easy, only three groups are modeled, each having the same used record sizeu and the same number of records 13∗ |NScs|, but differing with respect to the skip sizes. The first retains the average skip size, the second doubles it, whereas the third group is calculated without skipping. This simple adaptation suffices to capture the described effect rather accurately.

Unlike the void-skipping, which directly forwards the scanning cursor to the searched address, theoid-algorithms have to access each node withinNScs. Skip-ping in those cases only means a save on postorder comparisons, but does not allow direct positioning of the scanning cursor.

Concluding the examination of the axis step operations, we have to combine the basic access patterns. Since all data regions are processed concurrently, the compound pattern is described by:

RS←axisstep(CS, NS)≡s trav(CS)s trav(NScs, u)s trav(RS).

Like in the mentionedselect operation, the cache misses of the single traversals are simply added. Although three patterns are involved, the concurrent execution may only cause extra cache misses when two traversals require to load the same cache line. Cache associativity, however, often enables to resolve such conflicts.

PSfrag replacements

NScs

skipped block scanned block

NScs

Zi

Figure 4.1: Top: data regionNScs with its scanned and skipped parts, Bottom: the derived data region modelNScs.

A final remark concerns the stack access of the child-, parent, and sibling oper-ations. As the stack is bounded to height(TD), the considered data region remains very small. Normally, at most two cache lines are covered. Furthermore, if the relationship of the context nodes causes a considerable stack usage, the frequency of write and read accesses to the same cache line should be high enough to avoid its overwriting by the traversal patterns of other data regions. Hence, neglecting the stack access seems admissible.

4.2.2 Axis specific Parameters

To enable application of the described general access pattern, it remains to deter-mine |NScs|, the number of skipss, as well as the number of the actually touched items t within NScs, depending on the specific characteristics of the axis step op-erations. In the following cpr first and cpr last always refers to the first respectively last node of the pruned context set.

Descendant Theoid-operation is only bounded by the last pruned context node.

The NS traversal stops at the first following node ofcprlast. In thevoid-case the scanned block can be further constrained to start directly at the first context node.

Furthermore, every pruned context node causes two skips, first, for copying without test all nodes within the lower bound of the descendant region, and second, to jump over the block of the following nodes to the next context node (Fig. 4.2):

s= 2∗ |CSprdesc|.

Since the destination of the first skip is determined by a lower bound calculation, it causes on average touching of lev subsequent nodes, lev denoting the medium level of a node in the document tree, until the first following node is reached. In contrast, the second skip positions the scanning cursor directly at the next context node, without having to touch further nodes. Therefore, we call the first type inexact and the second one exact skipping.

The described skipping pattern touches in every partition [pre(cpr i), pre(cpr i+1)[

of the node set lev+ 2 nodes, thus totally t=s+s∗lev.

Ancestor/Preceding Like in the descendant case, the oid-operations traverse the node set completely until the last context node is reached. However, they do not include its descendants. The void-versions scan the same region, but allow

PSfrag replacements

Figure 4.2: Access pattern on the partition [pre(cpr i), pre(cpr i+1)[.

Top: descendant(void), Bottom: child. f1denotescpr i/following[1].

inexact skipping of all descendants of preceding nodes. It is unfortunately impos-sible to precisely determine the number of skips. If we assume exact skipping, the access pattern would touch only the ancestor nodes, their preceding-siblings, and the preceding-siblings of the context nodes themselves (Fig. 4.3), for abbreviation denoted CS/ancestor-or-self/preceding-sibling-or-self. Without the pos-sibility to perform exact skipping, sincreases, but includes a high number of very short skips, which do not exceed cache line size.

In case of the preceding axis the context set is reduced to its last node.

Following Once the beginning of the following region is determined, the applied slice-operation does not need to touch any further node inNS. Using the void-algorithm requires one inexact skip over the descendant region of context node with the smallest postorder rank. For an efficient implementation of theoid-algorithm, the same inexact skipping is performed via binary search, resulting in an additional amount oflog2(|NS|) touched data items. Although the binary search breaks with the sequential scanning pattern, the number of caused random accesses is highly limited.

Child The child axis algorithm touches exactly all descendants of the context nodes. If we focus on a single partition, constrained by any two adjacent nodes of the descendant-pruned context set [pre(cpr i), pre(cpr i+1)[, first,cpri’s level is deter-mined, then the scanning cursor starts reading atpre(cpr i) + 1 and touches all the nodes withincpr i’s descendant region until, finally, its first following node is reached marking the end of this region. The subsequently performed exact skip forwards the cursor to the beginning of the next partition starting atcpr i+1 (Fig. 4.2). The number of skips is thus equal to|CSpr|and for each partition the two nodes framing the scanned descendant region are accessed as well.

Figure 4.3: The preceding/ancestor algorithm originated in context node skips the gray marked descendant regions.

Axis |NScs|

descendant(oid) |{n∈NS|pre(n)< post(cpr last) +lev}|

descendant(void) post(cpr last) +lev−pre(cf irst) ancestor/

preceding(oid) |{n∈NS|pre(n)< pre(clast)}|

ancestor/

preceding(void) pre(clast) following(oid) lev+log2(|NS|) following(void) lev

child/

following-sibling post(cpr last) +lev−pre(cf irst) parent/

preceding-sibling pre(cprlast)−pre(cf irst)

Table 4.1: Overview of the context-dependent node set constraintsNScs. Following-Sibling Since the following-sibling algorithm is similar to the child-step with the difference of searching on the above level, its access pattern also shows equivalences. Whereas the child step operation scans only the descendant region of the context nodes, the sibling algorithm also touches the following-siblings and their descendants. Thus, the number of skips decreases while t rises.

If we define context set pruning for the following-sibling operation as

CSprf s=CS[self != CS/following-sibling-or-self/descendant-or-self]

sandt can be described equivalently to the child axis:

s = |CSprf s|,

t = 2s+|CS/following-sibling-or-self/descendant-or-self|. Parent/Preceding-Sibling Both parent and preceding-sibling algorithms have the same access pattern, mirroring the following-sibling operation in reverse direc-tion. Therefore, the traversal starts atclastand ends at the parent of the first pruned context node. Unlike the following-sibling pattern, the context nodes’ descendants remain untouched. Context set pruning in this case is redefined to

CSprpar/ps=CS[self != CS/preceding-sibling/descendant-or-self].

To summarize the discussion on axis dependent parameters for modeling the op-erations‘ access patterns, Table 4.1, 4.2, and 4.3 present an overview of the obtained values.