source: docs/Balisage09/Bal2009came0601.xml @ 290

Last change on this file since 290 was 290, checked in by ksherdy, 10 years ago

Update ErrorFlag? content.

File size: 88.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!-- MODIFIED DTD LOCATION -->
3<!DOCTYPE article SYSTEM "balisage-1-1.dtd">
4<article xmlns="http://docbook.org/ns/docbook" version="5.0-subset Balisage-1.1"
5   xml:id="HR-23632987-8973">
6   <title>Parallel Bit Stream Technology as a Foundation for XML Parsing Performance</title>
7   <info>
8      <confgroup>
9         <conftitle>International Symposium on Processing XML Efficiently: Overcoming Limits on
10            Space, Time, or Bandwidth</conftitle>
11         <confdates>August 10 2009</confdates>
12      </confgroup>
13      <abstract>
14         <para>By first transforming the octets (bytes) of XML texts into eight parallel bit
15            streams, the SIMD features of commodity processors can be exploited for parallel
16            processing of blocks of 128 input bytes at a time. Established transcoding and parsing
17            techniques are reviewed followed by new techniques including parsing with bitstream
18            addition. Further opportunities are discussed in light of expected advances in CPU
19            architecture and compiler technology. Implications for various APIs and information
20            models are presented as well opportunities for collaborative open-source
21         development.</para>
22      </abstract>
23      <author>
24         <personname>
25            <firstname>Rob</firstname>
26            <surname>Cameron</surname>
27         </personname>
28         <personblurb>
29            <para>Dr. Rob Cameron is Professor and Director of Computing Science at Simon Fraser
30               University. With a broad spectrum of research interests related to programming
31               languages, software engineering and sociotechnical design of public computing
32               infrastructure, he has recently been focusing on high performance text processing
33               using parallel bit stream technology and its applications to XML. He is also a
34               patentleft evangelist, advocating university-based technology transfer models
35               dedicated to free use in open source. </para>
36
37         </personblurb>
38         <affiliation>
39            <jobtitle>Professor of Computing Science</jobtitle>
40            <orgname>Simon Fraser University</orgname>
41         </affiliation>
42         <email>cameron@cs.sfu.ca</email>
43      </author>
44      <author>
45         <personname>
46            <firstname>Ken</firstname>
47            <surname>Herdy</surname>
48         </personname>
49         <personblurb>
50            <para> Ken Herdy completed an Advanced Diploma of Technology in Geographical Information
51               Systems at the British Columbia Institute of Technology in 2003 and earned a Bachelor
52               of Science in Computing Science with a Certificate in Spatial Information Systems at
53               Simon Fraser University in 2005. </para>
54            <para> Ken is currently pursuing graduate studies in Computing Science at Simon Fraser
55               University with industrial scholarship support from the Natural Sciences and
56               Engineering Research Council of Canada, the Mathematics of Information Technology and
57               Complex Systems NCE, and the BC Innovation Council. His research focus is an analysis
58               of the principal techniques that may be used to improve XML processing performance in
59               the context of the Geography Markup Language (GML). </para>
60
61         </personblurb>
62         <affiliation>
63            <jobtitle>Graduate Student, School of Computing Science</jobtitle>
64            <orgname>Simon Fraser University </orgname>
65         </affiliation>
66         <email>ksherdy@cs.sfu.ca</email>
67      </author>
68      <author>
69         <personname>
70            <firstname>Ehsan</firstname>
71            <surname>Amiri</surname>
72         </personname>
73         <personblurb>
74            <para>Ehsan Amiri is a PhD student of Computer Science at Simon Fraser University.
75               Before that he studied at Sharif University of Technology, Tehran, Iran. While his
76               graduate research has been focused on theoretical problems like fingerprinting, Ehsan
77               has worked on some software projects like development of a multi-node firewall as
78               well. More recently he has been developing compiler technology for automatic
79               generation of bit stream processing code. </para>
80
81         </personblurb>
82         <affiliation>
83            <jobtitle>Graduate Student, School of Computing Science</jobtitle>
84            <orgname>Simon Fraser University</orgname>
85         </affiliation>
86         <email>eamiri@cs.sfu.ca</email>
87      </author>
88      <legalnotice>
89         <para>Copyright &#x000A9; 2009 Robert D. Cameron, Kenneth S. Herdy and Ehsan Amiri.
90            This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative
91            Works 2.5 Canada License.</para>
92      </legalnotice>
93      <keywordset role="author">
94         <keyword/>
95         <keyword/>
96         <keyword/>
97      </keywordset>
98   </info>
99   <section>
100      <title>Introduction</title>
101      <para> While particular XML applications may benefit from special-purpose hardware such as XML
102         chips [<xref linkend="XMLChip09"/>] or appliances [<xref linkend="Datapower09"/>], the bulk
103         of the world's XML processing workload will continue to be handled by XML software stacks
104         on commodity processors. Exploiting the SIMD capabilities of such processors such as the
105         SSE instructions of x86 chips, parallel bit stream technology offers the potential of
106         dramatic improvement over byte-at-a-time processing for a variety of XML processing tasks.
107         Character set issues such as Unicode validation and transcoding [<xref linkend="PPoPP08"
108         />], normalization of line breaks and white space and XML character validation can be
109         handled fully in parallel using this representation. Lexical item streams, such as the bit
110         stream marking the positions of opening angle brackets, can also be formed in parallel.
111         Bit-scan instructions of commodity processors may then be used on lexical item streams to
112         implement rapid single-instruction scanning across variable-length multi-byte text blocks
113         as in the Parabix XML parser [<xref linkend="CASCON08"/>]. Overall, these techniques may be
114         combined to yield end-to-end performance that may be 1.5X to 15X faster than alternatives
115            [<xref linkend="SVGOpen08"/>].</para>
116      <para>Continued research in parallel bit stream techniques as well as more conventional
117         application of SIMD techniques in XML processing offers further prospects for improvement
118         of core XML components as well as for tackling performance-critical tasks further up the
119         stack. A newly prototyped technique for parallel tag parsing using bitstream addition is
120         expected to improve parsing performance even beyond that achieved using sequential bit
121         scans. Several techniques for improved symbol table performance are being investigated,
122         including parallel hash value calculation and length-based sorting using the cheap length
123         determination afforded by bit scans. To deliver the benefits of parallel bit stream
124         technology to the Java world, we are developing Array Set Model (ASM) representations of
125         XML Infoset and other XML information models for efficient transmission across the JNI
126         boundary.</para>
127
128      <para>Amplifying these software advances, continuing hardware advances in commodity processors
129         increase the relative advantage of parallel bit stream techniques over traditional
130         byte-at-a-time processors. For example, the Intel Core architecture improved SSE processing
131         to give superscalar execution of bitwise logic operations (3 instructions per cycle vs. 1
132         in Pentium 4). Upcoming 256-bit AVX technology extends the register set and replaces
133         destructive two-operand instructions with a nondestructive three-operand form. General
134         purpose programming on graphic processing units (GPGPU) such as the upcoming 512-bit
135         Larrabee processor may also be useful for XML applications using parallel bit streams. New
136         instruction set architectures may also offer dramatic improvements in core algorithms.
137         Using the relatively simple extensions to support the principle of inductive doubling, a 3X
138         improvement in several core parallel bit stream algorithms may be achieved [<xref
139            linkend="ASPLOS09"/>]. Other possibilities include direct implementation of parallel
140         extract and parallel deposit (pex/pdep) instructions [<xref linkend="Pex06"/>], and
141         bit-level interleave operations as in Larrabee, each of which would have important
142         application to parallel bit stream processing.</para>
143
144      <para>Further prospects for XML performance improvement arise from leveraging the
145         intraregister parallelism of parallel bit stream technology to exploit the interchip
146         parallelism of multicore computing. Parallel bit stream techniques can support multicore
147         parallelism in both data partitioning and task partitioning models. For example, the
148         datasection partitioning approach of Wu, Zhang, Yu and Li may be used to partition blocks
149         for speculative parallel parsing on separate cores followed by a postprocessing step to
150         join partial S-trees [<xref linkend="Wu08"/>].</para>
151
152      <para>In our view, the established and expected performance advantages of parallel bit stream
153         technology over traditional byte-at-a-time processing are so compelling that parallel bit
154         stream technology should ultimately form the foundation of every high-performance XML
155         software stack. We envision a common high-performance XML kernel that may be customized to
156         a variety of processor architectures and that supports a wide range of existing and new XML
157         APIs. Widespread deployment of this technology should greatly benefit the XML community in
158         addressing both the deserved and undeserved criticism of XML on performance grounds. A
159         further benefit of improved performance is a substantial greening of XML technologies.</para>
160
161      <para>To complement our research program investigating fundamental algorithms and issues in
162         high-performance XML processing, our work also involves development of open source software
163         implementing these algorithms, with a goal of full conformance to relevant specifications.
164         From the research perspective, this approach is valuable in ensuring that the full
165         complexity of required XML processing is addressed in reporting and assessing processing
166         results. However, our goal is also to use this open source software as a basis of
167         technology transfer. A Simon Fraser University spin-off company, called International
168         Characters, Inc., has been created to commercialize the results of this work using a
169         patent-based open source model.</para>
170
171      <para>To date, we have not yet been successful in establishing a broader community of
172         participation with our open source code base. Within open-source communities, there is
173         often a general antipathy towards software patents; this may limit engagement with our
174         technology, even though it has been dedicated for free use in open source. </para>
175
176      <para>A further complication is the inherent difficulty of SIMD programming in general, and
177         parallel bit stream programming in particular. Considerable work is required with each new
178         algorithmic technique being investigated as well as in retargetting our techniques for each
179         new development in SIMD and multicore processor technologies. To address these concerns, we
180         have increasingly shifted the emphasis of our research program towards compiler technology
181         capable of generating parallel bit stream code from higher-level specifications.</para>
182   </section>
183
184   <section>
185      <title>A Catalog of Parallel Bit Streams for XML</title>
186      <section>
187         <title>Introduction</title>
188         <para>In this section, we introduce the fundamental concepts of parallel bit stream
189            technology and present a comprehensive catalog of parallel bit streams for use in XML
190            processing. In presenting this catalog, the focus is on the specification of the bit
191            streams as data streams in one-to-one correspondence with the character code units of an
192            input XML stream. The goal is to define these bit streams in the abstract without
193            initially considering memory layouts, register widths or other issues related to
194            particular target architectures. In cataloging these techniques, we also hope to convey
195            a sense of the breadth of applications of parallel bit stream technology to XML
196            processing tasks. </para>
197      </section>
198
199      <section>
200         <title>Basis Bit Streams</title>
201         <para>Given a byte-oriented text stream represented in UTF-8, for example, we define a
202            transform representation of this text consisting of a set of eight parallel bit streams
203            for the individual bits of each byte. Thus, the <code>Bit0</code> stream is the stream
204            of bits consisting of bit 0 of each byte in the input byte stream, <code>Bit1</code> is
205            the bit stream consisting of bit 1 of each byte in the input stream and so on. The set
206            of streams <code>Bit0</code> through <code>Bit7</code> are known as the <emphasis>basis
207               streams</emphasis> of the parallel bit stream representation. The following table
208            shows an example XML character stream together with its representation as a set of 8
209            basis streams. <table>
210               <caption>
211                  <para>XML Character Stream Transposition.</para>
212               </caption>
213               <colgroup>
214                  <col align="left" valign="top"/>
215                  <col align="left" valign="top"/>
216                  <col align="left" valign="top"/>
217                  <col align="left" valign="top"/>
218                  <col align="left" valign="top"/>
219                  <col align="left" valign="top"/>
220               </colgroup>
221               <tbody>
222                  <tr valign="top">
223                     <td>Input Data</td>
224                     <td>
225                        <code>&lt;</code>
226                     </td>
227                     <td>
228                        <code>t</code>
229                     </td>
230                     <td>
231                        <code>a</code>
232                     </td>
233                     <td>
234                        <code>g</code>
235                     </td>
236                     <td>
237                        <code>/</code>
238                     </td>
239                     <td>
240                        <code>&gt;</code>
241                     </td>
242                  </tr>
243                  <tr valign="top">
244                     <td>ASCII</td>
245                     <td>
246                        <code>00111100</code>
247                     </td>
248                     <td>
249                        <code>01110100</code>
250                     </td>
251                     <td>
252                        <code>01100001</code>
253                     </td>
254                     <td>
255                        <code>01100111</code>
256                     </td>
257                     <td>
258                        <code>00101111</code>
259                     </td>
260                     <td>
261                        <code>00111110</code>
262                     </td>
263                  </tr>
264                  <tr valign="top">
265                     <td>Bit0</td>
266                     <td>
267                        <code>0</code>
268                     </td>
269                     <td>
270                        <code>0</code>
271                     </td>
272                     <td>
273                        <code>0</code>
274                     </td>
275                     <td>
276                        <code>0</code>
277                     </td>
278                     <td>
279                        <code>0</code>
280                     </td>
281                     <td>
282                        <code>0</code>
283                     </td>
284                  </tr>
285                  <tr valign="top">
286                     <td>Bit1</td>
287                     <td>
288                        <code>0</code>
289                     </td>
290                     <td>
291                        <code>1</code>
292                     </td>
293                     <td>
294                        <code>1</code>
295                     </td>
296                     <td>
297                        <code>1</code>
298                     </td>
299                     <td>
300                        <code>0</code>
301                     </td>
302                     <td>
303                        <code>0</code>
304                     </td>
305                  </tr>
306                  <tr valign="top">
307                     <td>Bit2</td>
308                     <td>
309                        <code>1</code>
310                     </td>
311                     <td>
312                        <code>1</code>
313                     </td>
314                     <td>
315                        <code>1</code>
316                     </td>
317                     <td>
318                        <code>1</code>
319                     </td>
320                     <td>
321                        <code>1</code>
322                     </td>
323                     <td>
324                        <code>1</code>
325                     </td>
326                  </tr>
327                  <tr valign="top">
328                     <td>Bit3</td>
329                     <td>
330                        <code>1</code>
331                     </td>
332                     <td>
333                        <code>1</code>
334                     </td>
335                     <td>
336                        <code>0</code>
337                     </td>
338                     <td>
339                        <code>0</code>
340                     </td>
341                     <td>
342                        <code>0</code>
343                     </td>
344                     <td>
345                        <code>1</code>
346                     </td>
347                  </tr>
348                  <tr valign="top">
349                     <td>Bit4</td>
350                     <td>
351                        <code>1</code>
352                     </td>
353                     <td>
354                        <code>0</code>
355                     </td>
356                     <td>
357                        <code>0</code>
358                     </td>
359                     <td>
360                        <code>0</code>
361                     </td>
362                     <td>
363                        <code>1</code>
364                     </td>
365                     <td>
366                        <code>1</code>
367                     </td>
368                  </tr>
369                  <tr valign="top">
370                     <td>Bit5</td>
371                     <td>
372                        <code>1</code>
373                     </td>
374                     <td>
375                        <code>1</code>
376                     </td>
377                     <td>
378                        <code>0</code>
379                     </td>
380                     <td>
381                        <code>1</code>
382                     </td>
383                     <td>
384                        <code>1</code>
385                     </td>
386                     <td>
387                        <code>1</code>
388                     </td>
389                  </tr>
390                  <tr valign="top">
391                     <td>Bit6</td>
392                     <td>
393                        <code>0</code>
394                     </td>
395                     <td>
396                        <code>0</code>
397                     </td>
398                     <td>
399                        <code>0</code>
400                     </td>
401                     <td>
402                        <code>1</code>
403                     </td>
404                     <td>
405                        <code>1</code>
406                     </td>
407                     <td>
408                        <code>1</code>
409                     </td>
410                  </tr>
411                  <tr valign="top">
412                     <td>Bit7</td>
413                     <td>
414                        <code>0</code>
415                     </td>
416                     <td>
417                        <code>0</code>
418                     </td>
419                     <td>
420                        <code>1</code>
421                     </td>
422                     <td>
423                        <code>1</code>
424                     </td>
425                     <td>
426                        <code>1</code>
427                     </td>
428                     <td>
429                        <code>0</code>
430                     </td>
431                  </tr>
432               </tbody>
433            </table>
434         </para>
435         <para> Depending on the features of a particular processor architecture, there are a number
436            of algorithms for transposition to parallel bit stream form. Several of these algorithms
437            employ a three-stage structure. In the first stage, the input byte stream is divided
438            into a pair of half-length streams consisting of four bits for each byte, for example,
439            one stream for the high nybble of each byte and another for the low nybble of each byte.
440            In the second stage, these streams of four bits per byte are each divided into streams
441            consisting of two bits per original byte, for example streams for the
442            <code>Bit0/Bit1</code>, <code>Bit2/Bit3</code>, <code>Bit4/Bit5</code>, and
443               <code>Bit6/Bit7</code> pairs. In the final stage, the streams are further subdivided
444            in the individual bit streams. </para>
445         <para> Using SIMD capabilities, this process is quite efficient, with an amortized cost of
446            1.1 CPU cycles per input byte on Intel Core 2 with SSE, or 0.6 CPU cycles per input byte
447            on Power PC G4 with Altivec. With future advances in processor technology, this
448            transposition overhead is expected to reduce, possibly taking advantage of upcoming
449            parallel extract (pex) instructions on Intel technology. In the ideal, only 24
450            instructions are needed to transform a block of 128 input bytes using 128-bit SSE
451            registers using the inductive doubling instruction set architecture, representing an
452            overhead of less than 0.2 instructions per input byte. </para>
453      </section>
454
455      <section>
456         <title>General Streams</title>
457         <para>This section describes bit streams which support basic processing operations.</para>
458
459         <section>
460            <title>Deletion Mask Streams</title>
461            <para>DelMask (deletion mask) streams marks character code unit positions for deletion.
462               Since the deletion operation is dependency free across many stages of XML processing,
463               it is possible to simply mark and record deletion positions as deletion mask streams for future processing. A single
464               invocation of a SIMD based parallel deletion algorithm can then perform the deletion of
465               positions accumulated across a number of stages through a bitwise ORing of deletion
466               masks. For example, deletion arises in the replacement of predefined entities with a
467               single character, such as in the replacement of the &amp;amp; entity, with the
468               &amp; character. Deletion also arises in XML
469               end-of-line handling, and CDATA section delimeter processing. Several algorithms to
470               delete bits at positions marked by DelMask are possible [<xref linkend="u8u16"/>]. </para>
471            <para>The following table provides an example of generating a DelMask in the context of
472               bit stream based parsing of well-formed character references and predefined entities.
473               The result is the generation of a DelMask stream. <table>
474                  <caption>
475                     <para>DelMask Stream Generation</para>
476                  </caption>
477                  <colgroup>
478                     <col align="left" valign="top"/>
479                     <col align="left" valign="top"/>
480                  </colgroup>
481                  <tbody>
482                     <tr valign="top">
483                        <td>Input Data</td>
484                        <td>
485                           <code>&amp;gt; &amp;#13; &amp;#x0a;</code>
486                        </td>
487                     </tr>
488                     <tr valign="top">
489                        <td>GenRefs</td>
490                        <td>
491                           <code>_11______________</code>
492                        </td>
493                     </tr>
494
495                     <tr valign="top">
496                        <td>DecRefs</td>
497                        <td>
498                           <code>_______11________</code>
499                        </td>
500                     </tr>
501                     <tr valign="top">
502                        <td>HexRefs</td>
503                        <td>
504                           <code>______________11_</code>
505                        </td>
506                     </tr>
507                     <tr valign="top">
508                        <td>DelMask</td>
509                        <td>
510                           <code>111__1111__11111_</code>
511                        </td>
512                     </tr>
513                     <tr valign="top">
514                        <td>ErrorFlag</td>
515                        <td>
516                           <code>_________________</code>
517                        </td>
518                     </tr>
519                  </tbody>
520               </table>
521            </para>
522         </section>
523
524         <section>
525            <title>Error Flag Streams </title>
526            <para>Error flag streams indicates the character code unit positions of syntactical
527               errors. XML processing examples which benefit from the marking of error positions
528               include UTF-8 character sequence validation and XML parsing [<xref linkend="u8u16"
529               />].</para>
530            <para>The following table provides an example of using bit streams to parse character
531               references and predefined entities which fail to meet the XML 1.0 well-formedness
532               constraints. The result is the generation of an error flag stream that marks the
533               positions of mal-formed decimal and hexical character references respectively. <table>
534                  <caption>
535                     <para>Error Flag Stream Generation</para>
536                  </caption>
537                  <colgroup>
538                     <col align="left" valign="top"/>
539                     <col align="left" valign="top"/>
540                  </colgroup>
541                  <tbody>
542                     <tr valign="top">
543                        <td>Input Data</td>
544                        <td>
545                           <code>&amp;gt; &amp;#, &amp;#x; </code>
546                        </td>
547                     </tr>
548                     <tr valign="top">
549                        <td>GenRefs</td>
550                        <td>
551                           <code>_11___________</code>
552                        </td>
553                     </tr>
554                     <tr valign="top">
555                        <td>DecRefs</td>
556                        <td>
557                           <code>______________</code>
558                        </td>
559                     </tr>
560                     <tr valign="top">
561                        <td>HexRefs</td>
562                        <td>
563                           <code>______________</code>
564                        </td>
565                     </tr>
566                     <tr valign="top">
567                        <td>DelMask</td>
568                        <td>
569                           <code>111__11__111__</code>
570                        </td>
571                     </tr>
572                     <tr valign="top">
573                        <td>ErrorFlag</td>
574                        <td>
575                           <code>_______1____1_</code>
576                        </td>
577                     </tr>
578                  </tbody>
579               </table>
580            </para>
581         </section>
582
583      </section>
584
585      <section>
586         <title>Lexical Item Streams</title>
587         <para>Lexical item streams differ from traditional streams of tokens in that they are bit
588            streams that mark the positions of tokens, whitespace or delimiters. Additional bit
589            streams, such as the reference streams and callout streams, are subsequently constructed
590            based on the information held within the set of lexical items streams. Differentiation
591            between the actual tokens that may occur at a particular point (e.g., the different XML
592            tokens that begin “&lt;”) may be performed using multicharacter recognizers on the
593            bytestream representation [<xref linkend="CASCON08"/>].</para>
594         <para>A key role of lexical item streams in XML parsing is to facilitate fast scanning
595            operations. For example, a left angle bracket lexical item stream may be formed to
596            identify those character code unit positions at which a “&lt;” character occurs.
597            Hardware register bit scan operations may then be used by the XML parser on the left
598            angle bracket stream to efficiently identify the position of the next “&lt;”. Based
599            on the capabilities of current commodity processors, a single register bit scan
600            operation may effectively scan up to 64 byte positions with a single instruction.</para>
601         <para>Overall, the construction of the full set of lexical item stream computations
602            requires approximately 1.0 CPU cycles per byte when implemented for 128 positions at a
603            time using 128-bit SSE registers on Intel Core2 processors [<xref linkend="CASCON08"/>].
604            The following table defines the core lexical item streams defined by the Parabix XML
605            parser.</para>
606         <para>
607            <table>
608               <caption>
609                  <para>Lexical item stream descriptions.</para>
610               </caption>
611               <tbody>
612                  <tr>
613                     <td align="left"> LAngle </td>
614                     <td align="left"> Marks the position of any left angle bracket character.</td>
615                  </tr>
616                  <tr>
617                     <td align="left"> RAngle </td>
618                     <td align="left"> Marks the position of any right angle bracket character.</td>
619                  </tr>
620                  <tr>
621                     <td align="left"> LBracket </td>
622                     <td align="left"> Marks the position of any left square bracker character.</td>
623                  </tr>
624                  <tr>
625                     <td align="left"> RBracket </td>
626                     <td align="left"> Marks the position of any right square bracket
627                     character.</td>
628                  </tr>
629                  <tr>
630                     <td align="left"> Exclam </td>
631                     <td align="left"> Marks the position of any exclamation mark character.</td>
632                  </tr>
633                  <tr>
634                     <td align="left"> QMark </td>
635                     <td align="left"> Marks the position of any question mark character.</td>
636                  </tr>
637                  <tr>
638                     <td align="left"> Hyphen </td>
639                     <td align="left"> Marks the position of any hyphen character.</td>
640                  </tr>
641                  <tr>
642                     <td align="left"> Equals </td>
643                     <td align="left"> Marks the position of any equal sign character.</td>
644                  </tr>
645                  <tr>
646                     <td align="left"> SQuote </td>
647                     <td align="left"> Marks the position of any single quote character.</td>
648                  </tr>
649                  <tr>
650                     <td align="left"> DQuote </td>
651                     <td align="left"> Marks the position of any double quote character.</td>
652                  </tr>
653                  <tr>
654                     <td align="left"> Slash </td>
655                     <td align="left"> Marks the position of any forward slash character</td>
656                  </tr>
657                  <tr>
658                     <td align="left"> NameScan </td>
659                     <td align="left"> Marks the position of any XML name character.</td>
660                  </tr>
661                  <tr>
662                     <td align="left"> WS </td>
663                     <td align="left"> Marks the position of any XML 1.0 whitespace character.</td>
664                  </tr>
665                  <tr>
666                     <td align="left"> PI_start </td>
667                     <td align="left"> Marks the position of the start of any processing instruction
668                        at the '?' character position.</td>
669                  </tr>
670                  <tr>
671                     <td align="left"> PI_end </td>
672                     <td align="left"> Marks the position of any end of any processing instruction
673                        at the '>' character position.</td>
674                  </tr>
675                  <tr>
676                     <td align="left"> CtCD_start </td>
677                     <td align="left"> Marks the position of the start of any comment or CDATA
678                        section at the '!' character position.</td>
679                  </tr>
680                  <tr>
681                     <td align="left"> EndTag_start </td>
682                     <td align="left"> Marks the position of any end tag at the '/' character
683                        position.</td>
684                  </tr>
685                  <tr>
686                     <td align="left"> CD_end </td>
687                     <td align="left"> Marks the position of the end of any CDATA section at the '>'
688                        character position. </td>
689                  </tr>
690                  <tr>
691                     <td align="left"> DoubleHyphen </td>
692                     <td align="left"> Marks the position of any double hyphen character.</td>
693                  </tr>
694                  <tr>
695                     <td align="left"> RefStart </td>
696                     <td align="left"> Marks the position of any ampersand character.</td>
697                  </tr>
698                  <tr>
699                     <td align="left"> Hash </td>
700                     <td align="left"> Marks the position of any hash character.</td>
701                  </tr>
702                  <tr>
703                     <td align="left"> x </td>
704                     <td align="left"> Marks the position of any 'x' character.</td>
705                  </tr>
706                  <tr>
707                     <td align="left"> Digit </td>
708                     <td align="left"> Marks the position of any digit.</td>
709                  </tr>
710                  <tr>
711                     <td align="left"> Hex </td>
712                     <td align="left"> Marks the position of any hexidecimal character.</td>
713                  </tr>
714                  <tr>
715                     <td align="left"> Semicolon </td>
716                     <td align="left"> Marks the position of any semicolon character.</td>
717                  </tr>
718               </tbody>
719            </table>
720         </para>
721         <para> The following illustrates a number of the lexical item streams. </para>
722         <para>
723            <table>
724               <caption>
725                  <para>Lexical Item Streams</para>
726               </caption>
727               <colgroup>
728                  <col align="left" valign="top"/>
729                  <col align="left" valign="top"/>
730               </colgroup>
731               <tbody>
732                  <tr valign="top">
733                     <td>Input Data</td>
734                     <td>
735                        <code>&lt;tag&gt;&lt;tag&gt; text &amp;lt;
736                           &amp;#x3e; &lt;/tag&gt;&lt;/tag&gt;</code>
737                     </td>
738                  </tr>
739
740                  <tr valign="top">
741                     <td>LAngle</td>
742                     <td>
743                        <code>1____1______________________1_____1_____</code>
744                     </td>
745                  </tr>
746                  <tr valign="top">
747                     <td>RAngle</td>
748                     <td>
749                        <code>____1____1_______________________1_____1</code>
750                     </td>
751                  </tr>
752                  <tr valign="top">
753                     <td>WS</td>
754                     <td>
755                        <code>__________1____1____1______1____________</code>
756                     </td>
757                  </tr>
758                  <tr valign="top">
759                     <td>RefStart</td>
760                     <td>
761                        <code>________________1____1__________________</code>
762                     </td>
763                  </tr>
764                  <tr valign="top">
765                     <td>Hex</td>
766                     <td>
767                        <code>__1____1____1___________11_____1_____1__</code>
768                     </td>
769                  </tr>
770
771                  <tr valign="top">
772                     <td>Semicolon</td>
773                     <td>
774                        <code>___________________1______1_____________</code>
775                     </td>
776                  </tr>
777                  <tr valign="top">
778                     <td>Slash</td>
779                     <td>
780                        <code>_____________________________1_____1____</code>
781                     </td>
782                  </tr>
783               </tbody>
784            </table>
785         </para>
786
787      </section>
788
789      <section>
790         <title>UTF-8 Byte Classification, Scope and Validation Streams</title>
791         <para> An XML parser must accept the UTF-8 encoding of Unicode [<xref linkend="XML10"/>].
792            It is a fatal error if an XML document determined to be in UTF-8 contains byte sequences
793            that are not legal in that encoding. UTF-8 byte classification, scope, XML character
794            validation and error flag bit streams are defined to validate UTF-8 byte sequences and
795            support transcoding to UTF-16.</para>
796
797         <section>
798            <title>UTF-8 Byte Classification Streams</title>
799            <para>UTF-8 byte classification bit streams classify UTF-8 bytes based on their role in
800               forming single and multibyte sequences. The u8Prefix and u8Suffix bit streams
801               identify bytes that represent, respectively, prefix or suffix bytes of multibyte
802               UTF-8 sequences. The u8UniByte bit stream identifies those bytes that may be
803               considered single-byte sequences. The u8Prefix2, u8Prefix3, and u8Prefix4 refine the
804               u8Prefix respectively indicating prefixes of two, three or four byte
805            sequences respectively.</para>
806         </section>
807
808         <section>
809            <title>UTF-8 Scope Streams</title>
810            <para> Scope streams represent expectations established by UTF-8 prefix bytes. For
811               example, the u8Scope22 bit stream represents the positions at which the second byte of a
812               two-byte sequence is expected based on the occurrence of a two-byte prefix in the
813               immediately preceding position. The u8scope32, u8Scope33, u8Scope42, u8scope43, and
814               u8Scope44 complete the set of UTF-8 scope streams.</para>
815            <para> The following example demonstrates the UTF-8 character encoding validation
816               process using parallel bit stream techniques. The result of this validation process
817               is an error flag stream identifying the positions at which errors occur.</para>
818            <para>
819               <table>
820                  <caption>
821                     <para>UTF-8 Scope Streams</para>
822                  </caption>
823                  <colgroup>
824                     <col align="left" valign="top"/>
825                     <col align="left" valign="top"/>
826                  </colgroup>
827                  <tbody>
828                     <tr valign="top">
829                        <td>Input Data</td>
830                        <td>
831                           <code>A Text in Farsi: ى س ر ا ف ن ت م ك ى </code>
832                        </td>
833                     </tr>
834                     <tr valign="top">
835                        <td>High Nybbles</td>
836                        <td>
837                           <code>42567726624677632D8DBDBDAD82D8DAD82D8D8</code>
838                        </td>
839                     </tr>
840                     <tr valign="top">
841                        <td>Low Nybbles</td>
842                        <td>
843                           <code>10458409E061239A099838187910968A9509399</code>
844                        </td>
845                     </tr>
846                     <tr valign="top">
847                        <td>u8Unibyte</td>
848                        <td>
849                           <code>11111111111111111__________1______1____</code>
850                        </td>
851                     </tr>
852                     <tr valign="top">
853                        <td>u8Prefix</td>
854                        <td>
855                           <code>_________________1_1_1_1_1__1_1_1__1_1_</code>
856                        </td>
857                     </tr>
858                     <tr valign="top">
859                        <td>u8Suffix</td>
860                        <td>
861                           <code>__________________1_1_1_1_1__1_1_1__1_1</code>
862                        </td>
863                     </tr>
864                     <tr valign="top">
865                        <td>u8Prefix2</td>
866                        <td>
867                           <code>_________________1_1_1_1_1__1_1_1__1_1_</code>
868                        </td>
869                     </tr>
870                     <tr valign="top">
871                        <td>u8Scope22</td>
872                        <td>
873                           <code>__________________1_1_1_1_1__1_1_1__1_1</code>
874                        </td>
875                     </tr>
876                     <tr valign="top">
877                        <td>ErrorFlag</td>
878                        <td>
879                           <code>_______________________________________</code>
880                        </td>
881                     </tr>
882                  </tbody>
883               </table>
884
885
886            </para>
887         </section>
888
889         <section>
890            <title>UTF-8 Validation Streams</title>
891            <para> Proper formation of UTF-8 byte sequences requires that the correct number of
892               suffix bytes always follow a UTF-8 prefix byte, and that certain illegal byte
893               combinations are ruled out. For example, sequences beginning with the prefix bytes
894               0xF5 through 0xFF are illegal as they would represent code point values above 10FFFF.
895               In addition, there are constraints on the first suffix byte following certain special
896               prefixes, namely that a suffix following the prefix 0xE0 must fall in the range
897               0xA0–0xBF, a suffix following the prefix 0xED must fall in the range 0x80–0x9F, a
898               suffix following the prefix 0xF0 must fall in the range 0x90–0xBF and a suffix
899               following the prefix 0xF4 must fall in the range 0x80–0x8F. The task of ensuring that
900               each of these constraints hold is known as UTF-8 validation. The bit streams xE0,
901               xED, xF0, xF4, xA0_xBF, x80_x9F, x90_xBF, and x80_x8F are constructed to flag the
902               aforementioned UTF-8 validation errors. The result of UTF-8 validation is a UTF-8
903               error flag bit stream contructed as the ORing of a series of UTF-8 validation tests.
904            </para>
905         </section>
906
907         <section>
908            <title>XML Character Validation Streams</title>
909            <para>The UTF-8 character sequences <emphasis>0xEF 0xBF 0xBF</emphasis> and
910                  <emphasis>0xEF 0xBF 0xBE</emphasis> correspond to the Unicode code points 0xFFFE
911               and 0xFFFF respectively. In XML 1.0, 0xFFFE and 0xFFFF represent characters outside
912               the legal XML character ranges. As such, bit streams which mark 0xEF, 0xBF, and 0xBE
913               character are constructed to flag illegal UTF-8 character sequences. </para>
914         </section>
915
916         <section>
917            <title>UTF-8 to UTF-16 Transcoding</title>
918            <para>UTF-8 is often preferred for storage and data exchange, it is suitable for
919               processing, but it is significantly more complex to process than UTF-16 [<xref
920                  linkend="Unicode"/>]. As such, XML documents are typically encoded in UTF-8 for
921               serialization and transport, and subsequently transcoded to UTF-16 for processing
922               with programming languages such as Java and C#. Following the parallel bit stream
923               methods developed for the u8u16 transcoder, a high-performance standalone UTF-8 to
924               UTF-16 transcoder [<xref linkend="u8u16"/>], transcoding to UTF-16 may be achieved by
925               computing a series of 16 bit streams. One stream for each of the individual bits of a
926               UTF-16 code unit. </para>
927            <para>The bit streams for UTF-16 are conveniently divided into groups: the eight streams
928               u16Hi0, u16Hi1, ..., u16Hi7 for the high byte of each UTF-16 code unit and the eight
929               streams u16Lo1, ..., u16Lo7 for the low byte. Upon conversion of the parallel bit
930               stream data back to byte streams, eight sequential byte streams U16h0, U16h1, ...,
931               U16Hi7 are used for the high byte of each UTF-16 code unit, while U16Lo0, U16Lo1,...,
932               U16Lo7 are used for the corresponding low byte. Interleaving these streams then
933               produces the full UTF-16 doublebyte stream.</para>
934         </section>
935
936         <section>
937            <title>UTF-8 Indexed UTF-16 Streams</title>
938            <para>UTF-16 bit streams are initially defined in UTF-8 indexed form. That is, with sets
939               of bits in one-to-one correspondence with UTF-8 bytes. However, only one set of
940               UTF-16 bits is required for encoding two or three-byte UTF-8 sequences and only two
941               sets are required for surrogate pairs corresponding to four-byte UTF-8 sequences. The
942               u8LastByte (u8UniByte , u8Scope22 , u8Scope33 , and u8Scope44 ) and u8Scope42 streams
943               mark the positions at which the correct UTF-16 bits are computed. The bit sets at
944               other positions must be deleted to compress the streams to the UTF-16 indexed form.
945            </para>
946         </section>
947      </section>
948
949      <section>
950         <title>Control Character Streams</title>
951         <para>The control character bit streams marks ASCII control characters in the range
952            0x00-0x1F. Additional control character bit streams mark the tab, carriage return, line
953            feed, and space character. In addition, a bit stream to mark carriage return line
954            combinations is also constructed. Presently, control character bit streams support the
955            operations of XML 1.0 character validation and XML end-of-line handling.</para>
956
957         <section>
958            <title>XML Character Validation</title>
959            <para>Legal characters in XML are the tab, carriage return, and line feed characters,
960               together with all Unicode characters and excluding the surrogate blocks, as well as hexadecimal OxFFFE and
961               OxFFFF [<xref linkend="XML10"/>]. The x00_x1F bit stream is constructed and used in
962               combination with the additional control character bit streams to flags the positions
963               of illegal control characters.</para>
964         </section>
965
966         <section>
967            <title>XML 1.0 End-of-line Handling</title>
968            <para>In XML 1.0 the two-character sequence CR LF (carriage return, line feed) as well as
969               any CR character not followed by a LF character must be converted to a single LF
970               character [<xref linkend="XML10"/>].</para>
971            <para>By defining carriage return, line feed, and carriage return line feed bit streams,
972               dentoted CR, LF and CRLF respectively, end-of-line normalization processing can be
973               performed in parallel using only a small number of logical and shift operations.</para>
974            <para/>
975            <para>The following example demonstrates the generation of the CRLF deletion mask. In
976               this example, the position of all CR characters followed by LF characters are marked
977               for deletion. Isolated carriage returns are then replaced with LF characters.
978               Completion of this process satisfies the XML 1.0 end-of-line handling requirements.
979               For clarity, this example encodes input data carriage returns as
980               <emphasis>C</emphasis> characters, whereas line feed characters are shown as
981                  <emphasis>L</emphasis> characters.</para>
982            <para>
983               <table>
984                  <caption>
985                     <para>XML 1.0 End-of-line Handling</para>
986                  </caption>
987                  <colgroup>
988                     <col align="left" valign="top"/>
989                  </colgroup>
990                  <tbody>
991                     <tr valign="top">
992                        <td>Input Data</td>
993                        <td>
994                           <code>first line C second line CL third line L one more C nothing
995                           left</code>
996                        </td>
997                     </tr>
998                     <tr valign="top">
999                        <td>CR</td>
1000                        <td>
1001                           <code>-----------1-------------1------------------------1-------------</code>
1002                        </td>
1003                     </tr>
1004                     <tr valign="top">
1005                        <td>LF</td>
1006                        <td>
1007                           <code>--------------------------1------------1------------------------</code>
1008                        </td>
1009                     </tr>
1010                     <tr valign="top">
1011                        <td>DelMask</td>
1012                        <td>
1013                           <code>--------------------------1-------------------------------------</code>
1014                        </td>
1015                     </tr>
1016                  </tbody>
1017               </table>
1018
1019            </para>
1020         </section>
1021
1022      </section>
1023
1024      <section>
1025         <title>Call Out Streams</title>
1026         <para> Call out bit streams mark the extents of XML markup structures such as comments,
1027            processing instruction and CDATA sections as well as physical structures such as character and
1028            entity references and general references.  Call out streams are also formed for logical markup structures such
1029            start tags, end tags and empty element tags. </para>
1030         <section>
1031            <title>Comment, Processing Instruction and CDATA Section Call Out Streams</title>
1032            <para>Comments, processing instructions and CDATA sections call out streams, Ct_Span,
1033               PI_Span and CD_Span respectively, define sections of an XML document which
1034               contain markup that is not interpreted by an XML processor. As such, the union of
1035               Ct_Span, PI_Span and CD_Span streams defines the regions of non-interpreteable markup.
1036               The stream formed by this union is termed the CtCDPI_Mask.</para>
1037            <para>The following tables provides an example of constructing the CtCDPI_Mask. </para>
1038            <table>
1039
1040               <caption>
1041                  <para>CtCDPI Mask Generation</para>
1042               </caption>
1043               <colgroup>
1044                  <col align="left" valign="top"/>
1045                  <col align="left" valign="top"/>
1046               </colgroup>
1047               <tbody>
1048                  <tr valign="top">
1049                     <td>input data</td>
1050                     <td>
1051                        <code> &lt;?php?&gt; &lt;!-- example --&gt; &lt;![CDATA[
1052                           shift: a&lt;&lt;1 ]]&gt; </code>
1053                     </td>
1054                  </tr>
1055
1056                  <tr valign="top">
1057                     <td>CD_Span</td>
1058                     <td>
1059                        <code>______________________________11111111111111111111111__</code>
1060                     </td>
1061                  </tr>
1062                  <tr valign="top">
1063                     <td>Ct_Span</td>
1064                     <td>
1065                        <code>_____________111111111111______________________________</code>
1066                     </td>
1067                  </tr>
1068                  <tr valign="top">
1069                     <td>PI_Span</td>
1070                     <td>
1071                        <code>__11111________________________________________________</code>
1072                     </td>
1073                  </tr>
1074                  <tr valign="top">
1075                     <td>CtCDPI_Mask</td>
1076                     <td>
1077                        <code>__111111___111111111111111___1111111111111111111111111_</code>
1078                     </td>
1079                  </tr>
1080                  <tr valign="top">
1081                     <td>ErrorFlag</td>
1082                     <td>
1083                        <code>_______________________________________________________</code>
1084                     </td>
1085                  </tr>
1086
1087               </tbody>
1088            </table>
1089            <para> With the removal of all non-interpreteable markup, several phases of parallel bit
1090               stream based SIMD operations may follow operating on up to 128 byte positions on
1091               current commondity processors and assured of XML markup relevancy. For
1092               example, with the extents identification of comments, processing instructions and
1093               CDATA secions, XML names may be identified and length sorted for efficient symbol
1094               table construction. </para>
1095            <para> As an aside, comments and CDATA sections must first be validated to ensure
1096               that comments do not contain "--" sequences and that CDATA sections do not contain illegal
1097               "]]&gt;" sequences prior to ignorable markup stream generation.</para>
1098         </section>
1099
1100         <section>
1101            <title>Reference Call Out Streams</title>
1102            <para>The reference call out streams are the GenRefs, DecRefs, and HexRefs streams. This
1103               subset of the call out streams marks the extents of all but the closing semicolon of
1104               general and character references.</para>
1105            <para>Predefined character
1106               (<![CDATA[&lt;,&gt;,&amp;,&apos;,&quot;]]>) and numeric character
1107               references (&amp;#nnnn;, &amp;#xhhhh;) must be replaced by a single character
1108                  [<xref linkend="XML10"/>]. As previously shown, this subset of call out streams enables the construction of a DelMask for
1109               references.</para>
1110         </section>
1111
1112         <section>
1113            <title>Tag Call Out Streams</title>
1114            <para>Whereas sequential bit scans over lexical item streams form the basis of XML
1115               parsing, in the current Parabix parser a new method of parallel parsing has been
1116               developed and prototyped using the concept of bitstream addition. Fundamental to this
1117               method is the concept of a <emphasis>cursor</emphasis> stream, a bit stream marking
1118               the positions of multiple parallel parses currently in process. </para>
1119            <para>The results of parallel parsing using the bit stream addition technique produces a
1120               set of tag call out bit streams. These streams mark the extents of each start tag,
1121               end tag and empty element tag. Within tags, additional streams mark start
1122               and end positions for tag names, as well as attribute names and values. An error flag
1123               stream marks the positions of any syntactic errors encountered during parsing.</para>
1124            <para> The set of tag call out streams consists of the ElemNames, AttNames, AttVals, Tags,
1125               EmptyTagEnds and EndTags bit streams. The following example demonstrates the bit
1126               stream output produced which from parallel parsing using bit stream addition. </para>
1127            <table>
1128               <caption>
1129                  <para>Tag Call Out Streams</para>
1130               </caption>
1131               <colgroup>
1132                  <col align="left" valign="top"/>
1133                  <col align="left" valign="top"/>
1134               </colgroup>
1135               <tbody>
1136                  <tr valign="top">
1137                     <td>Input Data</td>
1138                     <td>
1139                        <code>&lt;root&gt;&lt;t1&gt;text&lt;/t1&gt;&lt;t2
1140                           a1=&apos;foo&apos; a2 =
1141                           &apos;fie&apos;&gt;more&lt;/t2&gt;&lt;tag3
1142                           att3=&apos;b&apos;/&gt;&lt;/root&gt;</code>
1143                     </td>
1144                  </tr>
1145
1146                  <tr valign="top">
1147                     <td>ElemNames</td>
1148                     <td>
1149                        <code>_1111__11___________11_______________________________1111__________________</code>
1150                     </td>
1151                  </tr>
1152                  <tr valign="top">
1153                     <td>AttNames</td>
1154                     <td>
1155                        <code>_______________________11_______11________________________1111_____________</code>
1156                     </td>
1157                  </tr>
1158                  <tr valign="top">
1159                     <td>AttrVals</td>
1160                     <td>
1161                        <code>__________________________11111______11111_____________________111_________</code>
1162                     </td>
1163                  </tr>
1164                  <tr valign="top">
1165                     <td>EmptyTagEnds</td>
1166                     <td>
1167                        <code>___________________________________________________________________1_______</code>
1168                     </td>
1169                  </tr>
1170                  <tr valign="top">
1171                     <td>EndTags</td>
1172                     <td>
1173                        <code>_______________111______________________________111__________________11111_</code>
1174                     </td>
1175                  </tr>
1176
1177                  <tr valign="top">
1178                     <td>Start/EmptyTags</td>
1179                     <td>
1180                        <code>_1111__11___________1111111111111111111111___________11111111111111________</code>
1181                     </td>
1182                  </tr>
1183                  <tr valign="top">
1184                     <td>ErrorFlag</td>
1185                     <td>
1186                        <code>___________________________________________________________________________</code>
1187                     </td>
1188                  </tr>
1189               </tbody>
1190            </table>
1191
1192         </section>
1193      </section>
1194   </section>
1195   <section>
1196      <title>SIMD Beyond Bitstreams: Names and Numbers</title>
1197
1198      <para>Whereas the fundamental innovation of our work is the use of SIMD technology in
1199         implementing parallel bit streams for XML, there are also important ways in which more
1200         traditional byte-oriented SIMD operations can be useful in accelerating other aspects of
1201         XML processing.</para>
1202
1203      <section>
1204         <title>Name Lookup</title>
1205         <para>Efficient symbol table mechanisms for looking up element and attribute names is
1206            important for almost all XML processing applications. It is also an important technique
1207            merely for assessing well-formedness of an XML document; rather than validating the
1208            character-by-character composition of each occurrence of an XML name as it is
1209            encountered, it is more efficient to validate all but the first occurrence by first
1210            determining whether the name already exists in a table of prevalidated names.</para>
1211
1212         <para>The first symbol table mechanism deployed in the Parabix parser simply used the
1213            hashmaps of the C++ standard template library, without deploying any SIMD technology.
1214            However, with the overhead of character validation, transcoding and parsing dramatically
1215            reduced by parallel bit stream technology, we found that symbol lookups then accounted
1216            for about half of the remaining execution time in a statistics gathering application
1217               [<xref linkend="CASCON08"/>]. Thus, symbol table processing was identified as a major
1218            target for further performance improvement. </para>
1219         <para> Our first effort to improve symbol table performance was to employ the splash tables
1220            with cuckoo hashing as described by Ross [<xref linkend="Ross06"/>], using SIMD
1221            technology for parallel bucket processing. Although this technique did turn out to have
1222            the advantage of virtually constant-time performance even for very large vocabularies,
1223            it was not particularly helpful for the relatively small vocabularies typically found in
1224            XML document processing. </para>
1225         <para> However, a second approach has been found to be quite useful, taking advantage of
1226            parallel bit streams for cheap determination of symbol length. In essence, the length of
1227            a name can be determined very cheaply using a single bit scan operation. This then makes
1228            it possible to use length-sorted symbol table processing, as follows. First, the
1229            occurrences of all names are stored in arrays indexed by length. Then the length-sorted
1230            arrays may each be inserted into the symbol table in turn. The advantage of this is that
1231            a separate loop may be written for each length. Length sorting makes for very efficient
1232            name processing. For example hash value computations and name comparisons can be made by
1233            loading multibyte values and performing appropriate shifting and masking operations,
1234            without the need for a byte-at-a-time loop. In initial experiments, this length-sorting
1235            approach was found to reduce symbol lookup cost by a factor of two. </para>
1236         <para> Current research includes the application of SIMD technology to further enhance the
1237            performance of length-sorted lookup. We have identified a promising technique for
1238            parallel processing of multiple name occurrences using a parallel trie lookup technique.
1239            Given an array of occurrences of names of a particular length, the first one, two or
1240            four bytes of each name are gathered and stored in a linear array. SIMD techniques are
1241            then used to compare these prefixes with the possible prefixes for the current position
1242            within the trie. In general, a very small number of possibilities exist for each trie
1243            node, allowing for fast linear search through all possibilities. Typically, the
1244            parallelism is expected to exceed the number of possibilities to search through at each
1245            node. With length-sorting to separate the top-level trie into many small subtries, we
1246            expect only a single step of symbol lookup to be needed in most practical instances. </para>
1247
1248         <para>The gather step of this algorithm is actually a common technique in SIMD processing.
1249            Instruction set support for gather operations is a likely future direction for SIMD
1250            technology.</para>
1251      </section>
1252
1253      <section>
1254         <title>Numeric Processing</title>
1255         <para> Many XML applications involve numeric data fields as attribute values or element
1256            content. Although most current XML APIs uniformly return information to applications in
1257            the form of character strings, it is reasonable to consider direct API support for
1258            numeric conversions within a high-performance XML engine. With string to numeric
1259            conversion such a common need, why leave it to application programmers? </para>
1260         <para> High-performance string to numeric conversion using SIMD operations also can
1261            considerably outperform the byte-at-a-time loops that most application programmers or
1262            libraries might employ. A first step is reduction of ASCII bytes to corresponding
1263            decimal nybbles using a SIMD packing operation. Then an inductive doubling algorithm
1264            using SIMD operations may be employed. First, 16 sets of adjacent nybble values in the
1265            range 0-9 can be combined in just a few SIMD operations to 16 byte values in the range
1266            0-99. Then 8 sets of byte values may similarly be combined with further SIMD processing
1267            to produce doublebyte values in the range 0-9999. Further combination of doublebyte
1268            values into 32-bit integers and so on can also be performed using SIMD operations. </para>
1269         <para> Using appropriate gather operations to bring numeric strings into appropriate array
1270            structures, an XML engine could offer high-performance numeric conversion services to
1271            XML application programmers. We expect this to be an important direction for our future
1272            work, particularly in support of APIs that focus on direct conversion of XML data into
1273            business objects. </para>
1274
1275      </section>
1276   </section>
1277
1278   <section>
1279      <title>APIs and Parallel Bit Streams</title>
1280
1281      <section>
1282         <title>The ILAX Streaming API</title>
1283         <para>The In-Line API for XML (ILAX) is the base API provided with the Parabix parser. It
1284            is intended for low-level extensions compiled right into the engine, with minimum
1285            possible overhead. It is similar to streaming event-based APIs such as SAX, but
1286            implemented by inline substitution rather than using callbacks. In essence, an extension
1287            programmer provides method bodies for event-processing methods declared internal to the
1288            Parabix parsing engine, compiling the event processing code directly with the core code
1289            of the engine. </para>
1290         <para> Although ILAX can be used directly for application programming, its primary use is
1291            for implementing engine extensions that support higher-level APIs. For example, the
1292            implementation of C or C++ based streaming APIs based on the Expat [<xref
1293               linkend="Expat"/>] or general SAX models can be quite directly implemented. C/C++ DOM
1294            or other tree-based APIs can also be fairly directly implemented. However, delivering
1295            Parabix performance to Java-based XML applications is challenging due to the
1296            considerable overhead of crossing the Java Native Interface (JNI) boundary. This issue
1297            is addressed with the Array Set Model (ASM) concept discussed in the following section. </para>
1298         <para> With the recent development of parallel parsing using bitstream addition, it is
1299            likely that the underlying ILAX interface of Parabix will change. In essence, ILAX
1300            suffers the drawback of all event-based interfaces: they are fundamentally sequential in
1301            number. As research continues, we expect efficient parallel methods building on parallel
1302            bit stream foundations to move up the stack of XML processing requirements. Artificially
1303            imposing sequential processing is thus expected to constrain further advances in XML
1304            performance. </para>
1305      </section>
1306
1307      <section>
1308         <title>Efficient XML in Java Using Array Set Models</title>
1309         <para> In our GML-to-SVG case study, we identified the lack of high-performance XML
1310            processing solutions for Java to be of particular interest. Java byte code does not
1311            provide access to the SIMD capabilities of the underlying machine architecture. Java
1312            just-in-time compilers might be capable of using some SIMD facilities, but there is no
1313            real prospect of conventional compiler technology translating byte-at-a-time algorithms
1314            into parallel bit stream code. So the primary vehicle for delivering high-performance
1315            XML processing is to call native parallel bit stream code written in C through JNI
1316            capabilities. </para>
1317         <para>However, each JNI call is expensive, so it is desirable to minimize the number of
1318            calls and get as much work done during each call as possible. This mitigates against
1319            direct implementation of streaming APIs in Java through one-to-one mappings to an
1320            underlying streaming API in C. Instead, we have concentrated on gathering information on
1321            the C side into data structures that can then be passed to the Java side. However, using
1322            either C pointer-based structures or C++ objects is problematic because these are
1323            difficult to interpret on the Java side and are not amenable to Java's automatic storage
1324            management system. Similarly, Java objects cannot be conveniently created on the C side.
1325            However, it is possible to transfer arrays of simple data values (bytes or integers)
1326            between C and Java, so that makes a reasonable focus for bulk data communication between
1327            C and Java. </para>
1328         <para><emphasis>Array Set Models</emphasis> are array-based representations of information
1329            representing an XML document in accord with XML InfoSet [<xref linkend="InfoSet"/>] or
1330            other XML data models relevant to particular APIs. As well as providing a mechanism for
1331            efficient bulk data communication across the JNI boundary, ASMs potentially have a
1332            number of other benefits in high-performance XML processing. <itemizedlist>
1333               <listitem>
1334                  <para>Prefetching. Commodity processors commonly support hardware and/or software
1335                     prefetching to ensure that data is available in a processor cache when it is
1336                     needed. In general, prefetching is most effective in conjunction with the
1337                     continuous sequential memory access patterns associated with array
1338                  processing.</para>
1339               </listitem>
1340               <listitem>
1341                  <para>DMA. Some processing environments provide Direct Memory Access (DMA)
1342                     controllers for block data movement in parallel with computation. For example,
1343                     the Cell Broadband Engine uses DMA controllers to move the data to and from the
1344                     local stores of the synergistic processing units. Arrays of contiguous data
1345                     elements are well suited to bulk data movement using DMA.</para>
1346               </listitem>
1347               <listitem>
1348                  <para>SIMD. Single Instruction Multiple Data (SIMD) capabilities of modern
1349                     processor instruction sets allow simultaneous application of particular
1350                     instructions to sets of elements from parallel arrays. For effective use of
1351                     SIMD capabilities, an SoA (Structure of Arrays) model is preferrable to an AoS
1352                     (Array of Structures) model. </para>
1353               </listitem>
1354               <listitem>
1355                  <para>Multicore processors. Array-oriented processing can enable the effective
1356                     distribution of work to the individual cores of a multicore system in two
1357                     distinct ways. First, provided that sequential dependencies can be minimized or
1358                     eliminated, large arrays can be divided into separate segments to be processed
1359                     in parallel on each core. Second, pipeline parallelism can be used to implement
1360                     efficient multipass processing with each pass consisting of a processing kernel
1361                     with array-based input and array-based output. </para>
1362               </listitem>
1363               <listitem>
1364                  <para>Streaming buffers for large XML documents. In the event that an XML document
1365                     is larger than can be reasonably represented entirely within processor memory,
1366                     a buffer-based streaming model can be applied to work through a document using
1367                     sliding windows over arrays of elements stored in document order. </para>
1368               </listitem>
1369
1370            </itemizedlist>
1371         </para>
1372
1373         <section>
1374            <title>Saxon-B TinyTree Example</title>
1375            <para>As a first example of the ASM concept, current work includes a proof-of-concept to
1376               deliver a high-performance replacement for building the TinyTree data structure used
1377               in Saxon-B 6.5.5, an open-source XSLT 2.0 processor written in Java [<xref
1378                  linkend="Saxon"/>]. Although XSLT stylesheets may be cached for performance, the
1379               caching of source XML documents is typically not possible. A new TinyTree object to
1380               represent the XML source document is thus commonly constructed with each new query so
1381               that the overall performance of simple queries on large source XML documents is
1382               highly dependent on TinyTree build time. Indeed, in a study of Saxon-SA, the
1383               commercial version of Saxon, query time was shown to be dominated by TinyTree build
1384               time [<xref linkend="Kay08"/>]. Similar performance results are demonstrable for the
1385               Saxon-B XSLT processor as well. </para>
1386            <para> The Saxon-B processor studied is a pure Java solution, converting a SAX (Simple
1387               API for XML) event stream into the TinyTree Java object using the efficient Aelfred
1388               XML parser [<xref linkend="AElfred"/>]. The TinyTree structure is itself an
1389               array-based structure mapping well suited to the ASM concept. It consists of six
1390               parallel arrays of integers indexed on node number and containing one entry for each
1391               node in the source document, with the exception of attribute and namespace nodes
1392                  [<xref linkend="Saxon"/>]. Four of the arrays respectively provide node kind, name
1393               code, depth, and next sibling information for each node, while the two others are
1394               overloaded for different purposes based on node kind value. For example, in the
1395               context of a text node , one of the overloaded arrays holds the text buffer offset
1396               value whereas the other holds the text buffer length value. Attributes and namespaces
1397               are represented using similiar parallel array of values. The stored TinyTree values
1398               are primarily primitive Java types, however, object types such as Java Strings and
1399               Java StringBuffers are also used to hold attribute values and comment values
1400               respectively. </para>
1401            <para> In addition to the TinyTree object, Saxon-B maintains a NamePool object which
1402               represents a collection of XML name triplets. Each triplet is composed of a Namespace
1403               URI, a Namespace prefix and a local name and encoded as an integer value known as a
1404               namecode. Namecodes permit efficient name search and look-up using integer
1405               comparison. Namecodes may also be subsequently decoded to recover namespace and local
1406               name information. </para>
1407            <para> Using the Parabix ILAX interface, a high-performance reimplementation of TinyTree
1408               and NamePool data structures was built to compare with the Saxon-B implementation. In
1409               fact, two functionally equivalent versions of the ASM java class were constructed. An
1410               initial version was constructed based on a set of primitive Java arrays constructed
1411               and allocated in the Java heap space via JNI New&lt;PrimitiveType&gt;Array
1412               method call. In this version, the JVM garbage collector is aware of all memory
1413               allocated in the native code. However, in this approach, large array copy operations
1414               limited overall performance to approximately a 2X gain over the Saxon-B build time. </para>
1415            <para>To further address the performance penalty imposed by copying large array values,
1416               a second version of the ASM Java object was constructed based on natively backed
1417               Direct Memory Byte Buffers [<xref linkend="JNI"/>]. In this version the JVM garbage
1418               collector is unaware any native memory resources backing the Direct Memory Byte
1419               Buffers. Large JNI-based copy operations are avoided; however, system memory must be
1420               explicitly deallocated via a Java native method call. Using this approach, our
1421               preliminary results show an approximate total 2.5X gain over Saxon-B build time.
1422            </para>
1423         </section>
1424      </section>
1425   </section>
1426
1427
1428   <section>
1429      <title>Compiler Technology</title>
1430
1431      <para> An important focus of our recent work is on the development of compiler technology to
1432         automatically generate the low-level SIMD code necessary to implement bit stream processing
1433         given suitable high-level specifications. This has several potential benefits. First, it
1434         can eliminate the tedious and error-prone programming of bit stream operations in terms of
1435         register-at-a-time SIMD operations. Second, compilation technology can automatically employ
1436         a variety of performance improvement techniques that are difficult to apply manually. These
1437         include algorithms for instruction scheduling and register allocation as well as
1438         optimization techniques for common subexpression expression elimination and register
1439         rematerialization among others. Third, compiler technology makes it easier to make changes
1440         to the low-level code for reasons of perfective or adaptive maintenance.</para>
1441
1442      <para>Beyond these reasons, compiler technology also offers the opportunity for retargetting
1443         the generation of code to accommodate different processor architectures and API
1444         requirements. Strategies for efficient parallel bit stream code can vary considerably
1445         depending on processor resources such as the number of registers available, the particular
1446         instruction set architecture supported, the size of L1 and L2 data caches, the number of
1447         available cores and so on. Separate implementation of custom code for each processor
1448         architecture would thus be likely to be prohibitively expensive, prone to errors and
1449         inconsistencies and difficult to maintain. Using compilation technology, however, the idea
1450         would be to implement a variety of processor-specific back-ends all using a common front
1451         end based on parallel bit streams. </para>
1452
1453      <section>
1454         <title>Character Class Compiler</title>
1455
1456         <para>The first compiler component that we have implemented is a character class compiler,
1457            capable of generation all the bit stream logic necessary to produce a set of lexical
1458            item streams each corresponding to some particular set of characters to be recognized.
1459            By taking advantage of common patterns between characters within classes, and special
1460            optimization logic for recognizing character-class ranges, our existing compiler is able
1461            to generate well-optimized code for complex sets of character classes involving numbers
1462            of special characters as well as characters within specific sets of ranges. </para>
1463
1464      </section>
1465      <section>
1466         <title>Regular Expression Compilation</title>
1467
1468         <para>Based on the character class compiler, we are currently investigating the
1469            construction of a regular expression compiler that can implement bit-stream based
1470            parallel regular-expression matching similar to that describe previously for parallel
1471            parsing by bistream addition. This compiler works with the assumption that bitstream
1472            regular-expression definitions are deterministic; no backtracking is permitted with the
1473            parallel bit stream representation. In XML applications, this compiler is primarily
1474            intended to enforce regular-expression constraints on string datatype specifications
1475            found in XML schema. </para>
1476
1477      </section>
1478
1479      <section>
1480         <title>Unbounded Bit Stream Compilation</title>
1481
1482         <para>The Catalog of XML Bit Streams presented earlier consist of a set of abstract,
1483            unbounded bit streams, each in one-to-one correspondence with input bytes of a text
1484            file. Determining how these bit streams are implemented using fixed-width SIMD
1485            registers, and possibly processed in fixed-length buffers that represent some multiple
1486            of the register width is a source of considerable programming complexity. The general
1487            goal of our compilation strategy in this case is to allow operations to be programmed in
1488            terms of unbounded bit streams and then automatically reduced to efficient low-level
1489            code with the application of a systematic code generation strategy for handling block
1490            and buffer boundary crossing. This is work currently in progress. </para>
1491
1492      </section>
1493   </section>
1494
1495   <section>
1496      <title>Conclusion</title>
1497      <para>Parallel bit stream technology offers the opportunity to dramatically speed up the core
1498         XML processing components used to implement virtually any XML API. Character validation and
1499         transcoding, whitespace processing, and parsing up to including the full validation of tag
1500         syntax can be handled fully in parallel using bit stream methods. Bit streams to mark the
1501         positions of all element names, attribute names and attribute values can also be produced,
1502         followed by fast bit scan operations to generate position and length values. Beyond bit
1503         streams, byte-oriented SIMD processing of names and numerals can also accelerate
1504         performance beyond sequential byte-at-a-time methods. </para>
1505      <para>Advances in processor architecture are likely to further amplify the performance of
1506         parallel bit stream technology over traditional byte-at-a-time processing over the next
1507         decade. Improvements to SIMD register width, register complement and operation format can
1508         all result in further gains. New SIMD instruction set features such as inductive doubling
1509         support, parallel extract and deposit instructions, bit interleaving and scatter/gather
1510         capabilities should also result in significant speed-ups. Leveraging the intraregister
1511         parallelism of parallel bit stream technology within SIMD registers to take of intrachip
1512         parallelism on multicore processors should accelerate processing further. </para>
1513      <para>Technology transfer using a patent-based open-source business model is a further goal of
1514         our work with a view to widespread deployment of parallel bit stream technology in XML
1515         processing stacks implementing a variety of APIs. The feasibility of substantial
1516         performance improvement in replacement of technology implementing existing APIs has been
1517         demonstrated even in complex software architectures involving delivery of performance
1518         benefits across the JNI boundary. We are seeking to accelerate these deployment efforts
1519         both through the development of compiler technology to reliably apply these methods to a
1520         variety of architectures as well as to identify interested collaborators using open-source
1521         or commercial models. </para>
1522   </section>
1523
1524   <section>
1525      <title>Acknowledgments</title>
1526      <para>This work is supported in part by research grants and scholarships from the Natural
1527         Sciences and Engineering Research Council of Canada, the Mathematics of Information
1528         Technology and Complex Systems Network and the British Columbia Innovation Council. </para>
1529      <para>We thank our colleague Dan Lin (Linda) for her work in high-performance symbol table
1530         processing. </para>
1531   </section>
1532
1533   <bibliography>
1534      <title>Bibliography</title>
1535      <bibliomixed xml:id="XMLChip09" xreflabel="Leventhal and Lemoine 2009">Leventhal, Michael and
1536         Eric Lemoine 2009. The XML chip at 6 years. Proceedings of International Symposium on
1537         Processing XML Efficiently 2009, Montréal.</bibliomixed>
1538      <bibliomixed xml:id="Datapower09" xreflabel="Salz, Achilles and Maze 2009">Salz, Richard,
1539         Heather Achilles, and David Maze. 2009. Hardware and software trade-offs in the IBM
1540         DataPower XML XG4 processor card. Proceedings of International Symposium on Processing XML
1541         Efficiently 2009, Montréal.</bibliomixed>
1542      <bibliomixed xml:id="PPoPP08" xreflabel="Cameron 2007">Cameron, Robert D. 2007. A Case Study
1543         in SIMD Text Processing with Parallel Bit Streams UTF-8 to UTF-16 Transcoding. Proceedings
1544         of 13th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming 2008, Salt
1545         Lake City, Utah. On the Web at <link>http://research.ihost.com/ppopp08/</link>.</bibliomixed>
1546      <bibliomixed xml:id="CASCON08" xreflabel="Cameron, Herdy and Lin 2008">Cameron, Robert D.,
1547         Kenneth S Herdy, and Dan Lin. 2008. High Performance XML Parsing Using Parallel Bit Stream
1548         Technology. Proceedings of CASCON 2008. 13th ACM SIGPLAN Symposium on Principles and
1549         Practice of Parallel Programming 2008, Toronto.</bibliomixed>
1550      <bibliomixed xml:id="SVGOpen08" xreflabel="Herdy, Burggraf and Cameron 2008">Herdy, Kenneth
1551         S., Robert D. Cameron and David S. Burggraf. 2008. High Performance GML to SVG
1552         Transformation for the Visual Presentation of Geographic Data in Web-Based Mapping Systems.
1553         Proceedings of SVG Open 6th International Conference on Scalable Vector Graphics,
1554         Nuremburg. On the Web at
1555            <link>http://www.svgopen.org/2008/papers/74-HighPerformance_GML_to_SVG_Transformation_for_the_Visual_Presentation_of_Geographic_Data_in_WebBased_Mapping_Systems/</link>.</bibliomixed>
1556      <bibliomixed xml:id="Ross06" xreflabel="Ross 2006">Ross, Kenneth A. 2006. Efficient hash
1557         probes on modern processors. Proceedings of ICDE, 2006. ICDE 2006, Atlanta. On the Web at
1558            <link>www.cs.columbia.edu/~kar/pubsk/icde2007.pdf</link>.</bibliomixed>
1559      <bibliomixed xml:id="ASPLOS09" xreflabel="Cameron and Lin 2009">Cameron, Robert D. and Dan
1560         Lin. 2009. Architectural Support for SWAR Text Processing with Parallel Bit Streams: The
1561         Inductive Doubling Principle. Proceedings of ASPLOS 2009, Washington, DC.</bibliomixed>
1562      <bibliomixed xml:id="Wu08" xreflabel="Wu et al. 2008">Wu, Yu, Qi Zhang, Zhiqiang Yu and
1563         Jianhui Li. 2008. A Hybrid Parallel Processing for XML Parsing and Schema Validation.
1564         Proceedings of Balisage 2008, Montréal. On the Web at
1565            <link>http://www.balisage.net/Proceedings/vol1/html/Wu01/BalisageVol1-Wu01.html</link>.</bibliomixed>
1566      <bibliomixed xml:id="u8u16" xreflabel="Cameron 2008">u8u16 - A High-Speed UTF-8 to UTF-16
1567         Transcoder Using Parallel Bit Streams Technical Report 2007-18. 2007. School of Computing
1568         Science Simon Fraser University, June 21 2007.</bibliomixed>
1569      <bibliomixed xml:id="XML10" xreflabel="XML 1.0">Extensible Markup Language (XML) 1.0 (Fifth
1570         Edition) W3C Recommendation 26 November 2008. On the Web at
1571            <link>http://www.w3.org/TR/REC-xml/</link>.</bibliomixed>
1572      <bibliomixed xml:id="Unicode" xreflabel="Unicode">The Unicode Consortium. 2009. On the Web at
1573            <link>http://unicode.org/</link>.</bibliomixed>
1574      <bibliomixed xml:id="Pex06" xreflabel="Hilewitz and Lee 2006"> Hilewitz, Y. and Ruby B. Lee.
1575         2006. Fast Bit Compression and Expansion with Parallel Extract and Parallel Deposit
1576         Instructions. Proceedings of the IEEE 17th International Conference on Application-Specific
1577         Systems, Architectures and Processors (ASAP), pp. 65-72, September 11-13, 2006.</bibliomixed>
1578      <bibliomixed xml:id="InfoSet" xreflabel="XML Infoset">XML Information Set (Second Edition) W3C
1579         Recommendation 4 February 2004. On the Web at
1580         <link>http://www.w3.org/TR/xml-infoset/</link>.</bibliomixed>
1581      <bibliomixed xml:id="Saxon" xreflabel="Saxon">SAXON The XSLT and XQuery Processor. On the Web
1582         at <link>http://saxon.sourceforge.net/</link>.</bibliomixed>
1583      <bibliomixed xml:id="Kay08" xreflabel="Kay 2008"> Kay, Michael Y. 2008. Ten Reasons Why Saxon
1584         XQuery is Fast, IEEE Data Engineering Bulletin, December 2008.</bibliomixed>
1585      <bibliomixed xml:id="AElfred" xreflabel="Ælfred"> The Ælfred XML Parser. On the Web at
1586            <link>http://saxon.sourceforge.net/aelfred.html</link>.</bibliomixed>
1587      <bibliomixed xml:id="JNI" xreflabel="Hitchens 2002">Hitchens, Ron. Java NIO. O'Reilly, 2002.</bibliomixed>
1588      <bibliomixed xml:id="Expat" xreflabel="Expat">The Expat XML Parser.
1589            <link>http://expat.sourceforge.net/</link>.</bibliomixed>
1590   </bibliography>
1591
1592</article>
Note: See TracBrowser for help on using the repository browser.