source: docs/Balisage13/Bal2013came0601/Bal2013came0601.html @ 3395

Last change on this file since 3395 was 3395, checked in by cameron, 6 years ago

Various revisions to handle referee comments

File size: 104.2 KB
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
2<html lang="en">
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5<title>icXML:  Accelerating a Commercial XML
6     Parser Using SIMD and Multicore Technologies</title>
7<link rel="stylesheet" href="balisage-proceedings.css" type="text/css">
8<meta name="keywords" content="">
11<div id="balisage-header"><h1 style="text-align: right; font-family: serif; margin:0.25em">
12<i>Balisage:</i> <small>The Markup Conference</small>
14<html lang="en">
16<title>icXML:  Accelerating a Commercial XML
17     Parser Using SIMD and Multicore Technologies</title>
18<link rel="stylesheet" href="balisage-proceedings.css" type="text/css">
19<meta name="generator" content="Balisage Conference Proceedings XSLT (v1.2)">
20<script type="text/javascript">
21    function toggle(folderID) {
22      folder = document.getElementById("folder-"+folderID);
23      icon = document.getElementById("icon-"+folderID)
24      // need to:
25      //   switch between 'none' and 'block'
26      //   switch between collapse and expand icons
27      if ( != "block") {
28 = "block";
29        icon.src = "minus.png" ;
30        icon.alt = "collapse" ;
31      }
32      else {
33 = "none";
34        icon.src = "plus.png" ;
35        icon.alt = "expand" ;
36      };
37      return;
38    }
40   function hidecite(citeID) {
41     cite = document.getElementById(citeID);
42 = "none";
43     return;
44   }
46   function showcite(citeID,anchorID) {
47     cite = document.getElementById(citeID);
49     citeLeft =;
50     citeTop =;
52     if (citeLeft != (getLeft(anchorID)+"px") ||
53         citeTop != (getTop(anchorID)+"px")) {
54 = "none";
55     }
57     if ( != "table-cell") {
58        movebox(citeID, anchorID);
59 = "table-cell";
60     }
61     else {
62 = "none";
63     };
64     return;
65   }
67   function movebox(citeID, anchorID) {
69     cite = document.getElementById(citeID);
71     // alert(cite.offsetWidth + " by " + cite.offsetHeight)
73     horizontalOffset = getLeft(anchorID);
74     // horizontalOffset = (inMain(anchorID)) ?
75     // (horizontalOffset - 260) : (horizontalOffset + 20)
76     // (horizontalOffset - (20 + cite.offsetWidth)) : (horizontalOffset + 20)
78     verticalOffset = getTop(anchorID);
79     // verticalOffset = (inMain(anchorID)) ?
80     // (verticalOffset - 20) : (verticalOffset + 20)
81     // (verticalOffset - (20 + cite.offsetHeight)) : (verticalOffset + 20)
83     /*
84     horizontalOffset = getAbsoluteLeft(anchorID) - getScrollLeft(anchorID) + 20;
85     if (inMain(anchorID)) {
86       horizontalOffset = horizontalOffset - 300;
87     }
88     verticalOffset = getAbsoluteTop(anchorID) - getScrollTop(anchorID) - 40;
89     if (inMain(anchorID)) {
90       verticalOffset = verticalOffset - 300;
91     }
92     */
94 = horizontalOffset + "px";
95 = verticalOffset + "px";
96   }
98   function getLeft(objectID) {
99     var left = getAbsoluteLeft(objectID) - getScrollLeft(objectID);
100     left = (inMain(objectID)) ? (left - 260) : (left + 20)   
101     return left;
102   }
104   function getTop(objectID) {
105     var top = getAbsoluteTop(objectID) - getScrollTop(objectID);
106     top = (inMain(objectID)) ? (top - 50) : (top + 20)
107     return top;     
108   }
110   function getAbsoluteLeft(objectId) {
111   // Get an object left position from the upper left viewport corner
112     o = document.getElementById(objectId)
113     oLeft = o.offsetLeft            // Get left position from the parent object
114     while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
115       oParent = o.offsetParent    // Get parent object reference
116       oLeft += oParent.offsetLeft // Add parent left position
117       o = oParent
118      }
119    return oLeft
120    }
122    function getAbsoluteTop(objectId) {
123    // Get an object top position from the upper left viewport corner
124      o = document.getElementById(objectId)
125      oTop = o.offsetTop            // Get top position from the parent object
126      while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
127        oParent = o.offsetParent  // Get parent object reference
128        oTop += oParent.offsetTop // Add parent top position
129        o = oParent
130      }
131    return oTop
132    }
134   function getScrollLeft(objectId) {
135     // Get a left scroll position
136     o = document.getElementById(objectId)
137     oLeft = o.scrollLeft            // Get left position from the parent object
138     while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
139       oParent = o.offsetParent    // Get parent object reference
140       oLeft += oParent.scrollLeft // Add parent left position
141       o = oParent
142      }
143    return oLeft
144    }
146    function getScrollTop(objectId) {
147    // Get a right scroll position
148      o = document.getElementById(objectId)
149      oTop = o.scrollTop            // Get top position from the parent object
150      while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
151        oParent = o.offsetParent  // Get parent object reference
152        oTop += oParent.scrollTop // Add parent top position
153        o = oParent
154      }
155    return oTop
156    }
158    function inMain(objectId) {
159    // returns true if in div#main
160      o = document.getElementById(objectId)
161      while(o.parentNode != null) { // Parse the parent hierarchy up to div#main
162        oParent = o.parentNode
163        if ( == "main") { return true; }
164        o = oParent;
165      }
166    return false;
167    }
170   /*
171   function showcite(citeID) {
172      cite = document.getElementById(citeID);
173      if ( != "table-cell") {
174 = "table-cell";
175      }
176      else {
177 = "none";
178      };
179      return;
180    }
181    */
183      </script>
186<div class="inline-citation" id="cite-CameronHerdyLin2008" style="display:none;width: 240px">
187<a class="quiet" href="javascript:hidecite('cite-CameronHerdyLin2008')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Cameron, Robert D., Herdy, Kenneth S. and Lin, Dan. High performance XML parsing using parallel bit stream technology. CASCON'08: Proc. 2008 conference of the center for advanced studies on collaborative research. 2008 New York, NY, USA</p>
189<div class="inline-citation" id="cite-papi" style="display:none;width: 240px">
190<a class="quiet" href="javascript:hidecite('cite-papi')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Innovative Computing Laboratory, University of Texas. Performance Application Programming Interface.<a href="" class="link" target="_new"></a></p>
192<div class="inline-citation" id="cite-perf" style="display:none;width: 240px">
193<a class="quiet" href="javascript:hidecite('cite-perf')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Eranian, Stephane, Gouriou, Eric, Moseley, Tipp and Bruijn, Willem de. Linux kernel profiling with perf.<a href="" class="link" target="_new"></a></p>
195<div class="inline-citation" id="cite-Cameron2008" style="display:none;width: 240px">
196<a class="quiet" href="javascript:hidecite('cite-Cameron2008')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Cameron, Robert D.. A case study in SIMD text processing with parallel bit streams: UTF-8 to UTF-16 transcoding. Proc. 13th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming. 2008 New York, NY, USA</p>
198<div class="inline-citation" id="cite-ParaDOM2009" style="display:none;width: 240px">
199<a class="quiet" href="javascript:hidecite('cite-ParaDOM2009')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Shah, Bhavik, Rao, Praveen, Moon, Bongki and Rajagopalan, Mohan. A Data Parallel Algorithm for XML DOM Parsing. Database and XML Technologies. 2009</p>
201<div class="inline-citation" id="cite-XMLSSE42" style="display:none;width: 240px">
202<a class="quiet" href="javascript:hidecite('cite-XMLSSE42')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Lei, Zhai. XML Parsing Accelerator with Intel Streaming SIMD Extensions 4 (Intel SSE4). 2008<a href="Intel%20Software%20Network" class="link" target="_new">Intel Software Network</a></p>
204<div class="inline-citation" id="cite-Cameron2009" style="display:none;width: 240px">
205<a class="quiet" href="javascript:hidecite('cite-Cameron2009')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Cameron, Rob, Herdy, Ken and Amiri, Ehsan Amiri. Parallel Bit Stream Technology as a Foundation for XML Parsing Performance. Int'l Symposium on Processing XML Efficiently: Overcoming Limits on Space, Time, or Bandwidth. 2009</p>
207<div class="inline-citation" id="cite-HilewitzLee2006" style="display:none;width: 240px">
208<a class="quiet" href="javascript:hidecite('cite-HilewitzLee2006')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Hilewitz, Yedidya and Lee, Ruby B.. Fast Bit Compression and Expansion with Parallel Extract and Parallel Deposit Instructions. ASAP '06: Proc. IEEE 17th Int'l Conference on Application-specific Systems, Architectures and Processors. 2006 Washington, DC, USA</p>
210<div class="inline-citation" id="cite-Asanovic-EECS-2006-183" style="display:none;width: 240px">
211<a class="quiet" href="javascript:hidecite('cite-Asanovic-EECS-2006-183')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Asanovic, Krste and others. The Landscape of Parallel Computing Research: A View from Berkeley. 2006</p>
213<div class="inline-citation" id="cite-GRID2006" style="display:none;width: 240px">
214<a class="quiet" href="javascript:hidecite('cite-GRID2006')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Lu, Wei, Chiu, Kenneth and Pan, Yinfei. A Parallel Approach to XML Parsing. Proceedings of the 7th IEEE/ACM International Conference on Grid Computing. 2006 Washington, DC, USA</p>
216<div class="inline-citation" id="cite-cameron-EuroPar2011" style="display:none;width: 240px">
217<a class="quiet" href="javascript:hidecite('cite-cameron-EuroPar2011')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Cameron, Robert D., Amiri, Ehsan, Herdy, Kenneth S., Lin, Dan, Shermer, Thomas C. and Popowich, Fred P.. Parallel Scanning with Bitstream Addition: An XML Case Study. Euro-Par 2011, LNCS 6853, Part II. 2011 Berlin, Heidelberg</p>
219<div class="inline-citation" id="cite-HPCA2012" style="display:none;width: 240px">
220<a class="quiet" href="javascript:hidecite('cite-HPCA2012')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Lin, Dan, Medforth, Nigel, Herdy, Kenneth S., Shriraman, Arrvindh and Cameron, Rob. Parabix: Boosting the efficiency of text processing on commodity processors. International Symposium on High-Performance Computer Architecture. 2012 Los Alamitos, CA, USA</p>
222<div class="inline-citation" id="cite-HPCC2011" style="display:none;width: 240px">
223<a class="quiet" href="javascript:hidecite('cite-HPCC2011')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">You, Cheng-Han and Wang, Sheng-De. A Data Parallel Approach to XML Parsing and Query. 10th IEEE International Conference on High Performance Computing and Communications. 2011 Los Alamitos, CA, USA</p>
225<div class="inline-citation" id="cite-E-SCIENCE2007" style="display:none;width: 240px">
226<a class="quiet" href="javascript:hidecite('cite-E-SCIENCE2007')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Pan, Yinfei, Zhang, Ying, Chiu, Kenneth and Lu, Wei. Parallel XML Parsing Using Meta-DFAs. International Conference on e-Science and Grid Computing. 2007 Los Alamitos, CA, USA</p>
228<div class="inline-citation" id="cite-ICWS2008" style="display:none;width: 240px">
229<a class="quiet" href="javascript:hidecite('cite-ICWS2008')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Pan, Yinfei, Zhang, Ying and Chiu, Kenneth. Hybrid Parallelism for XML SAX Parsing. IEEE International Conference on Web Services. 2008 Los Alamitos, CA, USA</p>
231<div class="inline-citation" id="cite-IPDPS2008" style="display:none;width: 240px">
232<a class="quiet" href="javascript:hidecite('cite-IPDPS2008')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Pan, Yinfei, Zhang, Ying and Chiu, Kenneth. Simultaneous transducers for data-parallel XML parsing. International Parallel and Distributed Processing Symposium. 2008 Los Alamitos, CA, USA</p>
234<div class="inline-citation" id="cite-HackersDelight" style="display:none;width: 240px">
235<a class="quiet" href="javascript:hidecite('cite-HackersDelight')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Warren, Henry S.. Hacker's Delight. 2002</p>
237<div class="inline-citation" id="cite-lu2007advances" style="display:none;width: 240px">
238<a class="quiet" href="javascript:hidecite('cite-lu2007advances')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Lu, C.T., Dos Santos, R.F., Sripada, L.N. and Kou, Y.. Advances in GML for geospatial applications. 2007</p>
240<div class="inline-citation" id="cite-lake2004geography" style="display:none;width: 240px">
241<a class="quiet" href="javascript:hidecite('cite-lake2004geography')" style="font-size:90%"><img src="eks.png" alt="[x]" style="float:right;clear:both;margin:1px"></a><p style="margin:0ex">Lake, R., Burggraf, D.S., Trninic, M. and Rae, L.. Geography mark-up language (GML) [foundation for the geo-web]. 2004</p>
243<div id="mast"><div class="content">
244<h2 class="article-title" id="idp76432">icXML:  Accelerating a Commercial XML
245     Parser Using SIMD and Multicore Technologies</h2>
246<div class="author">
247<h3 class="author">Nigel Medforth</h3>
248<div class="affiliation">
249<p class="jobtitle">Developer</p>
250<p class="orgname">International Characters Inc.</p>
252<div class="affiliation">
253<p class="jobtitle">Graduate Student</p>
254<p class="orgname">School of Computing Science, Simon Fraser University </p>
256<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
258<div class="author">
259<h3 class="author">Dan Lin</h3>
260<div class="affiliation">
261<p class="jobtitle">Graduate Student</p>
262<p class="orgname">School of Computing Science, Simon Fraser University </p>
264<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
266<div class="author">
267<h3 class="author">Kenneth Herdy</h3>
268<div class="affiliation">
269<p class="jobtitle">Graduate Student</p>
270<p class="orgname">School of Computing Science, Simon Fraser University </p>
272<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
274<div class="author">
275<h3 class="author">Rob Cameron</h3>
276<div class="affiliation">
277<p class="jobtitle">Professor of Computing Science</p>
278<p class="orgname">Simon Fraser University</p>
280<div class="affiliation">
281<p class="jobtitle">Chief Technology Officer</p>
282<p class="orgname">International Characters, Inc.</p>
284<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
286<div class="author">
287<h3 class="author">Arrvindh Shriraman</h3>
288<div class="affiliation">
289<p class="jobtitle">Assistant Professor</p>
290<p class="orgname">School of Computing Science, Simon Fraser University</p>
292<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
294<div class="legalnotice-block"><p id="idp284896">Copyright © 2013 Nigel Medforth, Dan Lin, Kenneth S. Herdy, Robert D. Cameron  and Arrvindh Shriraman.
295            This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative
296            Works 2.5 Canada License.</p></div>
297<div class="mast-box">
298<p class="title"><a href="javascript:toggle('idp77216')" class="quiet"><img class="toc-icon" src="plus.png" alt="expand" id="icon-idp77216"></a> <span onclick="javascript:toggle('idp77216');return true">Abstract</span></p>
299<div class="folder" id="folder-idp77216" style="display:none"><p id="idp77520">Prior research on the acceleration of XML processing using single-instruction
300           multiple-data (SIMD) and multi-core
301            parallelism has lead to a number of interesting research prototypes. This work is
302            the first to investigate to the extent to which the techniques underlying these prototypes
303            could result
304            in systematic performance benefits when fully integrated into a commercial XML parser
305            The widely used Xerces-C++ parser of the Apache Software Foundation was chosen as the
306            foundation for the study. A systematic restructuring of the parser was undertaken, while
307            maintaining the existing API for application programmers. Using SIMD techniques alone,
308            an increase in parsing speed of at least 50% was observed in a range of applications.
309            When coupled with pipeline parallelism on dual core processors, improvements of 2x and
310            beyond were realized.
312            icXML is intended as an important industrial contribution in its own right as well
313            as an important case study for the underlying Parabix parallel processing framework.
314            Based on the success of the icXML development, there is a strong case for continued
315            development of that framework as well as for the application of that framework
316            to other important XML technology stacks.   An important area for further work is
317            the extension of Parabix technology to accelerate Java-based implementations as
318            well as ones based on C/C++.
320            </p></div>
322<div class="toc">
323<p><b>Table of Contents</b></p>
325<dt><span class="section"><a href="#idp286832" class="toc">Introduction</a></span></dt>
326<dt><span class="section"><a href="#background" class="toc">Background</a></span></dt>
328<dt><span class="section"><a href="#background-xerces" class="toc">Xerces C++ Structure</a></span></dt>
329<dt><span class="section"><a href="#idp361744" class="toc">The Parabix Framework</a></span></dt>
330<dt><span class="section"><a href="#idp457376" class="toc">Sequential vs. Parallel Paradigm</a></span></dt>
332<dt><span class="section"><a href="#architecture" class="toc">Architecture</a></span></dt>
334<dt><span class="section"><a href="#idp465008" class="toc">Overview</a></span></dt>
335<dt><span class="section"><a href="#character-set-adapter" class="toc">Character Set Adapters</a></span></dt>
336<dt><span class="section"><a href="#par-filter" class="toc">Combined Parallel Filtering</a></span></dt>
337<dt><span class="section"><a href="#contentstream" class="toc">Content Stream</a></span></dt>
338<dt><span class="section"><a href="#namespace-handling" class="toc">Namespace Handling</a></span></dt>
339<dt><span class="section"><a href="#errorhandling" class="toc">Error Handling</a></span></dt>
341<dt><span class="section"><a href="#multithread" class="toc">Multithreading with Pipeline Parallelism</a></span></dt>
342<dt><span class="section"><a href="#performance" class="toc">Performance</a></span></dt>
344<dt><span class="section"><a href="#idp654464" class="toc">Xerces C++ SAXCount</a></span></dt>
345<dt><span class="section"><a href="#idp680992" class="toc">GML2SVG</a></span></dt>
347<dt><span class="section"><a href="#conclusion" class="toc">Conclusion and Future Work</a></span></dt>
350<div class="mast-box">
351<p class="title"><a href="javascript:toggle('idp79584')" class="linkbox"><img class="toc-icon" src="plus.png" alt="expand" id="icon-idp79584"></a> <span onclick="javascript:toggle('idp79584');return true">Nigel Medforth</span></p>
352<div class="folder" id="folder-idp79584" style="display:none">
353<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
354<div class="affiliation">
355<p class="jobtitle">Developer</p>
356<p class="orgname">International Characters Inc.</p>
358<div class="affiliation">
359<p class="jobtitle">Graduate Student</p>
360<p class="orgname">School of Computing Science, Simon Fraser University </p>
362<div class="personblurb">
363<p id="idp61840">Nigel Medforth is a M.Sc. student at Simon Fraser University and the lead
364               developer of icXML. He earned a Bachelor of Technology in Information Technology at
365               Kwantlen Polytechnic University in 2009 and was awarded the Dean’s Medal for
366               Outstanding Achievement.</p>
367<p id="idp62848">Nigel is currently researching ways to leverage both the Parabix framework and
368               stream-processing models to further accelerate XML parsing within icXML.</p>
372<div class="mast-box">
373<p class="title"><a href="javascript:toggle('idp66496')" class="linkbox"><img class="toc-icon" src="plus.png" alt="expand" id="icon-idp66496"></a> <span onclick="javascript:toggle('idp66496');return true">Dan Lin</span></p>
374<div class="folder" id="folder-idp66496" style="display:none">
375<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
376<div class="affiliation">
377<p class="jobtitle">Graduate Student</p>
378<p class="orgname">School of Computing Science, Simon Fraser University </p>
380<div class="personblurb"><p id="idp68208">Dan Lin is a Ph.D student at Simon Fraser University. She earned a Master of Science
381             in Computing Science at Simon Fraser University in 2010. Her research focus on on high
382             performance algorithms that exploit parallelization strategies on various multicore platforms.
383           </p></div>
386<div class="mast-box">
387<p class="title"><a href="javascript:toggle('idp70752')" class="linkbox"><img class="toc-icon" src="plus.png" alt="expand" id="icon-idp70752"></a> <span onclick="javascript:toggle('idp70752');return true">Kenneth Herdy</span></p>
388<div class="folder" id="folder-idp70752" style="display:none">
389<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
390<div class="affiliation">
391<p class="jobtitle">Graduate Student</p>
392<p class="orgname">School of Computing Science, Simon Fraser University </p>
394<div class="personblurb">
395<p id="idp271952"> Ken Herdy completed an Advanced Diploma of Technology in Geographical Information
396               Systems at the British Columbia Institute of Technology in 2003 and earned a Bachelor
397               of Science in Computing Science with a Certificate in Spatial Information Systems at
398               Simon Fraser University in 2005. </p>
399<p id="idp272688"> Ken is currently pursuing PhD studies in Computing Science at Simon Fraser
400               University with industrial scholarship support from the Natural Sciences and
401               Engineering Research Council of Canada, the Mathematics of Information Technology and
402               Complex Systems NCE, and the BC Innovation Council. His research focus is an analysis
403               of the principal techniques that may be used to improve XML processing performance in
404               the context of the Geography Markup Language (GML). </p>
408<div class="mast-box">
409<p class="title"><a href="javascript:toggle('idp275424')" class="linkbox"><img class="toc-icon" src="plus.png" alt="expand" id="icon-idp275424"></a> <span onclick="javascript:toggle('idp275424');return true">Rob Cameron</span></p>
410<div class="folder" id="folder-idp275424" style="display:none">
411<h5 class="author-email"><code class="email">&lt;<a class="email" href=""></a>&gt;</code></h5>
412<div class="affiliation">
413<p class="jobtitle">Professor of Computing Science</p>
414<p class="orgname">Simon Fraser University</p>
416<div class="affiliation">
417<p class="jobtitle">Chief Technology Officer</p>
418<p class="orgname">International Characters, Inc.</p>
420<div class="personblurb"><p id="idp277088">Dr. Rob Cameron is Professor of Computing Science and Associate Dean of Applied
421               Sciences at Simon Fraser University. His research interests include programming
422               language and software system technology, with a specific focus on high performance
423               text processing using SIMD and multicore parallelism. He is the developer of the REX
424               XML shallow parser as well as the parallel bit stream (Parabix) framework for SIMD
425               text processing. </p></div>
429<div id="navbar"></div>
430<div id="balisage-header" style="background-color: #6699CC">
431<a class="quiet" href=""><img style="float:right;border:none" alt="Balisage logo" height="130" src=""></a><h2 class="page-header">Balisage: The Markup Conference</h2>
432<h1 class="page-header">Proceedings preview</h1>
434<div id="main">
435<div class="article">
436<h2 class="article-title" id="idp76432">icXML:  Accelerating a Commercial XML
437     Parser Using SIMD and Multicore Technologies</h2>
438<div class="section" id="idp286832">
439<h2 class="title" style="clear: both">Introduction</h2>
440<p id="idp287472">   
441        Parallelization and acceleration of XML parsing is a widely
442        studied problem that has seen the development of a number
443        of interesting research prototypes using both SIMD and
444        multicore parallelism.   Most works have investigated
445        data parallel solutions on multicore
446        architectures using various strategies to break input
447        documents into segments that can be allocated to different cores.
448        For example, one possibility for data
449        parallelization is to add a pre-parsing step to compute
450        a skeleton tree structure of an  XML document <a class="xref" id="idp288288" href="javascript:showcite('cite-GRID2006','idp288288')">[Lu and Chiu 2006]</a>.
451        The parallelization of the pre-parsing stage itself can be tackled with
452          state machines <a class="xref" id="idp301312" href="javascript:showcite('cite-E-SCIENCE2007','idp301312')">[Pan and Zhang 2007]</a>, <a class="xref" id="idp302064" href="javascript:showcite('cite-IPDPS2008','idp302064')">[Pan and Zhang 2008b]</a>.
453        Methods without pre-parsing have used speculation <a class="xref" id="idp302880" href="javascript:showcite('cite-HPCC2011','idp302880')">[You and Wang 2011]</a> or post-processing that
454        combines the partial results <a class="xref" id="idp303712" href="javascript:showcite('cite-ParaDOM2009','idp303712')">[Shah and Rao 2009]</a>.
455        A hybrid technique that combines data and pipeline parallelism was proposed to
456        hide the latency of a "job" that has to be done sequentially <a class="xref" id="idp304576" href="javascript:showcite('cite-ICWS2008','idp304576')">[Pan and Zhang 2008a]</a>.
457      </p>
458<p id="idp305456">
459        Fewer efforts have investigated SIMD parallelism, although this approach
460        has the potential advantage of improving single core performance as well
461        as offering savings in energy consumption <a class="xref" id="idp305920" href="javascript:showcite('cite-HPCA2012','idp305920')">[Lin and Medforth 2012]</a>.
462        Intel introduced specialized SIMD string processing instructions in the SSE 4.2 instruction set extension
463        and showed how they can be used to improve the performance of XML parsing <a class="xref" id="idp306864" href="javascript:showcite('cite-XMLSSE42','idp306864')">[Lei 2008]</a>.
464        The Parabix framework uses generic SIMD extensions and bit parallel methods to
465        process hundreds of XML input characters simultaneously <a class="xref" id="idp307776" href="javascript:showcite('cite-Cameron2009','idp307776')">[Balisage 2009]</a> <a class="xref" id="idp308528" href="javascript:showcite('cite-cameron-EuroPar2011','idp308528')">[Parabix2 2011]</a>.
466        Parabix prototypes have also combined SIMD methods with thread-level parallelism to
467        achieve further acceleration on multicore systems <a class="xref" id="idp309440" href="javascript:showcite('cite-HPCA2012','idp309440')">[Lin and Medforth 2012]</a>.
468      </p>
469<p id="idp310208">
470        In this paper, we move beyond research prototypes to consider
471        the detailed integration of both SIMD and multicore parallelism into the
472        Xerces-C++ parser of the Apache Software Foundation, an existing
473        standards-compliant open-source parser that is widely used
474        in commercial practice.    The challenge of this work is
475        to parallelize the Xerces parser in such a way as to
476        preserve the existing APIs as well as offering worthwhile
477        end-to-end acceleration of XML processing.   
478        To achieve the best results possible, we undertook
479        a nine-month comprehensive restructuring of the Xerces-C++ parser,
480        seeking to expose as many critical aspects of XML parsing
481        as possible for parallelization, the result of which we named icXML.   
482        Overall, we employed Parabix-style methods of transcoding, tokenization
483        and tag parsing, parallel string comparison methods in symbol
484        resolution, bit parallel methods in namespace processing,
485        as well as staged processing using pipeline parallelism to take advantage of
486        multiple cores.
487      </p>
488<p id="idp311648">
489        The remainder of this paper is organized as follows.   
490          <a class="xref" href="#background" title="Background">section “Background”</a> discusses the structure of the Xerces and Parabix XML parsers and the fundamental
491        differences between the two parsing models.   
492        <a class="xref" href="#architecture" title="Architecture">section “Architecture”</a> then presents the icXML design based on a restructured Xerces architecture to
493        incorporate SIMD parallelism using Parabix methods.   
494        <a class="xref" href="#multithread" title="Multithreading with Pipeline Parallelism">section “Multithreading with Pipeline Parallelism”</a> moves on to consider the multithreading of the icXML architecture
495        using the pipeline parallelism model. 
496        <a class="xref" href="#performance" title="Performance">section “Performance”</a> analyzes the performance of both the single-threaded and
497        multi-threaded versions of icXML in comparison to original Xerces,
498        demonstrating substantial end-to-end acceleration of
499        a GML-to-SVG translation application written against the Xerces API.
500          <a class="xref" href="#conclusion" title="Conclusion and Future Work">section “Conclusion and Future Work”</a> concludes the paper with a discussion of future work and the potential for
501        applying the techniques discussed herein in other application domains.
502      </p>
504<div class="section" id="background">
505<h2 class="title" style="clear: both">Background</h2>
506<div class="section" id="background-xerces">
507<h3 class="title" style="clear: both">Xerces C++ Structure</h3>
508<p id="idp318976"> The Xerces C++ parser is a widely-used standards-conformant
509            XML parser produced as open-source software
510             by the Apache Software Foundation.
511            It features comprehensive support for a variety of character encodings both
512            commonplace (e.g., UTF-8, UTF-16) and rarely used (e.g., EBCDIC), support for multiple
513            XML vocabularies through the XML namespace mechanism, as well as complete
514            implementations of structure and data validation through multiple grammars declared
515            using either legacy DTDs (document type definitions) or modern XML Schema facilities.
516            Xerces also supports several APIs for accessing parser services, including event-based
517            parsing using either pull parsing or SAX/SAX2 push-style parsing as well as a DOM
518            tree-based parsing interface. </p>
519<p id="idp321104">
520            Xerces,
521            like all traditional parsers, processes XML documents sequentially a byte-at-a-time from
522            the first to the last byte of input data. Each byte passes through several processing
523            layers and is classified and eventually validated within the context of the document
524            state. This introduces implicit dependencies between the various tasks within the
525            application that make it difficult to optimize for performance. As a complex software
526              system, no one feature dominates the overall parsing performance. <a class="xref" href="#xerces-profile">Table I</a>
527            shows the execution time profile of the top ten functions in a
528            typical run. Even if it were possible, Amdahl's Law dictates that tackling any one of
529            these functions for parallelization in isolation would only produce a minute improvement
530            in performance. Unfortunately, early investigation into these functions found that
531            incorporating speculation-free thread-level parallelization was impossible and they were
532            already performing well in their given tasks; thus only trivial enhancements were
533            attainable. In order to obtain a systematic acceleration of Xerces, it should be
534            expected that a comprehensive restructuring is required, involving all aspects of the
535            parser. </p>
536<div class="table-wrapper" id="xerces-profile">
537<p class="title">Table I</p>
538<div class="caption"><p id="idp13392">Execution Time of Top 10 Xerces Functions</p></div>
539<table class="table" xml:id="xerces-profile">
540<colgroup span="1">
541<col align="left" valign="top" span="1">
542<col align="left" valign="top" span="1">
545<th>Time (%) </th>
546<th> Function Name </th>
549<tr valign="top">
550<td>13.29       </td>
551<td>XMLUTF8Transcoder::transcodeFrom </td>
553<tr valign="top">
554<td>7.45        </td>
555<td>IGXMLScanner::scanCharData </td>
557<tr valign="top">
558<td>6.83        </td>
559<td>memcpy </td>
561<tr valign="top">
562<td>5.83        </td>
563<td>XMLReader::getNCName </td>
565<tr valign="top">
566<td>4.67        </td>
567<td>IGXMLScanner::buildAttList </td>
569<tr valign="top">
570<td>4.54        </td>
571<td>RefHashTableO&lt;&gt;::findBucketElem </td>
573<tr valign="top">
574<td>4.20        </td>
575<td>IGXMLScanner::scanStartTagNS </td>
577<tr valign="top">
578<td>3.75        </td>
579<td>ElemStack::mapPrefixToURI </td>
581<tr valign="top">
582<td>3.58        </td>
583<td>ReaderMgr::getNextChar </td>
585<tr valign="top">
586<td>3.20        </td>
587<td>IGXMLScanner::basicAttrValueScan </td>
593<div class="section" id="idp361744">
594<h3 class="title" style="clear: both">The Parabix Framework</h3>
595<p id="idp362384"> The Parabix (parallel bit stream) framework is a transformative approach to XML
596            parsing (and other forms of text processing.) The key idea is to exploit the
597            availability of wide SIMD registers (e.g., 128-bit) in commodity processors to represent
598            data from long blocks of input data by using one register bit per single input byte. To
599            facilitate this, the input data is first transposed into a set of basis bit streams.
600              For example, <a class="xref" href="#xml-bytes">Table II</a> shows  the ASCII bytes for the string "<code class="code">b7&lt;A</code>" with
601                the corresponding  8 basis bit streams, b<sub>0</sub> through  b<sub>7</sub> shown in  <a class="xref" href="#xml-bits">Table III</a>.
602            The bits used to construct b<sub>7</sub> have been highlighted in this example.
603              Boolean-logic operations (∧, \√ and ¬ denote the
604              boolean AND, OR and NOT operators) are used to classify the input bits into a set of
605               <span class="ital">character-class bit streams</span>, which identify key
606            characters (or groups of characters) with a <code class="code">1</code>. For example, one of the
607            fundamental characters in XML is a left-angle bracket. A character is an
608               <code class="code">'&lt;' if and only if
609               Â¬(b<sub>0</sub> âˆš b<sub>1</sub>)
610               âˆ§ (b<sub>2</sub> âˆ§ b<sub>3</sub>)
611               âˆ§ (b<sub>4</sub> âˆ§ b<sub>5</sub>)
612               âˆ§ ¬ (b<sub>6</sub> âˆš
613               b<sub>7</sub>) = 1</code>. Similarly, a character is numeric, <code class="code">[0-9]
614               if and only if ¬(b<sub>0</sub> âˆš
615               b<sub>1</sub>) ∧ (b<sub>2</sub> âˆ§
616                  b<sub>3</sub>) ∧ ¬(b<sub>4</sub>
617               âˆ§ (b<sub>5</sub> âˆš
618            b<sub>6</sub>))</code>. An important observation here is that ranges of
619            characters may require fewer operations than individual characters and
620             multiple
621            classes can share the classification cost. </p>
622<div class="table-wrapper" id="xml-bytes">
623<p class="title">Table II</p>
624<div class="caption"><p id="idp376256">XML Source Data</p></div>
625<table class="table" xml:id="xml-bytes">
626<colgroup span="1">
627<col align="right" valign="top" span="1">
628<col align="centre" valign="top" span="1">
629<col align="centre" valign="top" span="1">
630<col align="centre" valign="top" span="1">
631<col align="centre" valign="top" span="1">
635<td>String </td>
636<td> <code class="code">b</code> </td>
637<td> <code class="code">7</code> </td>
638<td> <code class="code">&lt;</code> </td>
639<td> <code class="code">A</code> </td>
642<td>ASCII </td>
643<td> <code class="code">0110001<span class="bold">0</span></code> </td>
644<td> <code class="code">0011011<span class="bold">1</span></code> </td>
645<td> <code class="code">0011110<span class="bold">0</span></code> </td>
646<td> <code class="code">0100000<span class="bold">1</span></code> </td>
651<div class="table-wrapper" id="xml-bits">
652<p class="title">Table III</p>
653<div class="caption"><p id="idp392528">8-bit ASCII Basis Bit Streams</p></div>
654<table class="table" xml:id="xml-bits">
655<colgroup span="1">
656<col align="centre" valign="top" span="1">
657<col align="centre" valign="top" span="1">
658<col align="centre" valign="top" span="1">
659<col align="centre" valign="top" span="1">
660<col align="centre" valign="top" span="1">
661<col align="centre" valign="top" span="1">
662<col align="centre" valign="top" span="1">
663<col align="centre" valign="top" span="1">
667<td> b<sub>0</sub> </td>
668<td> b<sub>1</sub> </td>
669<td> b<sub>2</sub> </td>
670<td> b<sub>3</sub>
672<td> b<sub>4</sub> </td>
673<td> b<sub>5</sub> </td>
674<td> b<sub>6</sub> </td>
675<td> b<sub>7</sub> </td>
678<td> <code class="code">0</code> </td>
679<td> <code class="code">1</code> </td>
680<td> <code class="code">1</code> </td>
681<td> <code class="code">0</code> </td>
682<td> <code class="code">0</code> </td>
683<td> <code class="code">0</code> </td>
684<td> <code class="code">1</code> </td>
685<td> <span class="bold"><code class="code">0</code></span> </td>
688<td> <code class="code">0</code> </td>
689<td> <code class="code">0</code> </td>
690<td> <code class="code">1</code> </td>
691<td> <code class="code">1</code> </td>
692<td> <code class="code">0</code> </td>
693<td> <code class="code">1</code> </td>
694<td> <code class="code">1</code> </td>
695<td> <span class="bold"><code class="code">1</code></span> </td>
698<td> <code class="code">0</code> </td>
699<td> <code class="code">0</code> </td>
700<td> <code class="code">1</code> </td>
701<td> <code class="code">1</code> </td>
702<td> <code class="code">1</code> </td>
703<td> <code class="code">1</code> </td>
704<td> <code class="code">0</code> </td>
705<td> <span class="bold"><code class="code">0</code></span> </td>
708<td> <code class="code">0</code> </td>
709<td> <code class="code">1</code> </td>
710<td> <code class="code">0</code> </td>
711<td> <code class="code">0</code> </td>
712<td> <code class="code">0</code> </td>
713<td> <code class="code">0</code> </td>
714<td> <code class="code">0</code> </td>
715<td> <span class="bold"><code class="code">1</code></span> </td>
720<p id="idp432656"> Consider, for example, the XML source data stream shown in the first line of <a class="xref" href="#derived">Table IV</a>.
721The remaining lines of this figure show
722            several parallel bit streams that are computed in Parabix-style parsing, with each bit
723            of each stream in one-to-one correspondence to the source character code units of the
724            input stream. For clarity, 1 bits are denoted with 1 in each stream and 0 bits are
725            represented as underscores. The first bit stream shown is that for the opening angle
726            brackets that represent tag openers in XML. The second and third streams show a
727            partition of the tag openers into start tag marks and end tag marks depending on the
728            character immediately following the opener (i.e., "<code class="code">/</code>") or
729            not. The remaining three lines show streams that can be computed in subsequent parsing
730            (using the technique of bitstream addition <a class="xref" id="idp435760" href="javascript:showcite('cite-cameron-EuroPar2011','idp435760')">[Parabix2 2011]</a>), namely streams
731            marking the element names, attribute names and attribute values of tags. </p>
732<div class="table-wrapper" id="derived">
733<p class="title">Table IV</p>
734<div class="caption"><p id="idp437472">XML Source Data and Derived Parallel Bit Streams</p></div>
735<table class="table" xml:id="derived">
736<colgroup span="1">
737<col align="centre" valign="top" span="1">
738<col align="left" valign="top" span="1">
742<td> Source Data </td>
743<td> <code class="code"> &lt;document&gt;fee&lt;element a1='fie' a2 = 'foe'&gt;&lt;/element&gt;fum&lt;/document&gt; </code>
747<td> Tag Openers </td>
748<td> <code class="code">1____________1____________________________1____________1__________</code>
752<td> Start Tag Marks </td>
753<td> <code class="code">_1____________1___________________________________________________</code>
757<td> End Tag Marks </td>
758<td> <code class="code">___________________________________________1____________1_________</code>
762<td> Empty Tag Marks </td>
763<td> <code class="code">__________________________________________________________________</code>
767<td> Element Names </td>
768<td> <code class="code">_11111111_____1111111_____________________________________________</code>
772<td> Attribute Names </td>
773<td> <code class="code">______________________11_______11_________________________________</code>
777<td> Attribute Values </td>
778<td> <code class="code">__________________________111________111__________________________</code>
784<p id="idp450576"> Two intuitions may help explain how the Parabix approach can lead to improved XML
785            parsing performance. The first is that the use of the full register width offers a
786            considerable information advantage over sequential byte-at-a-time parsing. That is,
787            sequential processing of bytes uses just 8 bits of each register, greatly limiting the
788            processor resources that are effectively being used at any one time. The second is that
789            byte-at-a-time loop scanning loops are actually often just computing a single bit of
790            information per iteration: is the scan complete yet? Rather than computing these
791            individual decision-bits, an approach that computes many of them in parallel (e.g., 128
792            bytes at a time using 128-bit registers) should provide substantial benefit. </p>
793<p id="idp452688"> Previous studies have shown that the Parabix approach improves many aspects of XML
794            processing, including transcoding <a class="xref" id="idp453088" href="javascript:showcite('cite-Cameron2008','idp453088')">[u8u16 2008]</a>, character classification and
795            validation, tag parsing and well-formedness checking. The first Parabix parser used
796            processor bit scan instructions to considerably accelerate sequential scanning loops for
797            individual characters <a class="xref" id="idp453984" href="javascript:showcite('cite-CameronHerdyLin2008','idp453984')">[Parabix1 2008]</a>. Recent work has incorporated a method
798            of parallel scanning using bitstream addition <a class="xref" id="idp454800" href="javascript:showcite('cite-cameron-EuroPar2011','idp454800')">[Parabix2 2011]</a>, as well as
799            combining SIMD methods with 4-stage pipeline parallelism to further improve throughput
800            <a class="xref" id="idp455584" href="javascript:showcite('cite-HPCA2012','idp455584')">[Lin and Medforth 2012]</a>. Although these research prototypes handled the full syntax of
801            schema-less XML documents, they lacked the functionality required by full XML parsers. </p>
802<p id="idp456528"> Commercial XML processors support transcoding of multiple character sets and can
803            parse and validate against multiple document vocabularies. Additionally, they provide
804            API facilities beyond those found in research prototypes, including the widely used SAX,
805            SAX2 and DOM interfaces. </p>
807<div class="section" id="idp457376">
808<h3 class="title" style="clear: both">Sequential vs. Parallel Paradigm</h3>
809<p id="idp458064"> Xerces—like all traditional XML parsers—processes XML documents
810            sequentially. Each character is examined to distinguish between the XML-specific markup,
811            such as a left angle bracket <code class="code">&lt;</code>, and the content held within the
812            document. As the parser progresses through the document, it alternates between markup
813            scanning, validation and content processing modes. </p>
814<p id="idp459600"> In other words, Xerces belongs to an equivalence class of applications termed FSM
815           applications<sup class="fn-label"><a href="#FSM" class="footnoteref">[1]</a></sup>.<sup class="fn-label"><a href="#FSM" class="footnoteref" id="FSM-ref">[1]</a></sup> Each state transition indicates the processing context of
816            subsequent characters. Unfortunately, textual data tends to be unpredictable and any
817            character could induce a state transition. </p>
818<p id="idp462080"> Parabix-style XML parsers utilize a concept of layered processing. A block of source
819            text is transformed into a set of lexical bitstreams, which undergo a series of
820            operations that can be grouped into logical layers, e.g., transposition, character
821            classification, and lexical analysis. Each layer is pipeline parallel and require
822            neither speculation nor pre-parsing stages<a class="xref" id="idp462768" href="javascript:showcite('cite-HPCA2012','idp462768')">[Lin and Medforth 2012]</a>. To meet the API requirements
823            of the document-ordered Xerces output, the results of the Parabix processing layers must
824            be interleaved to produce the equivalent behaviour. </p>
827<div class="section" id="architecture">
828<h2 class="title" style="clear: both">Architecture</h2>
829<div class="section" id="idp465008">
830<h3 class="title" style="clear: both">Overview</h3>
831<p id="idp466064"> icXML is more than an optimized version of Xerces. Many components were grouped,
832            restructured and rearchitected with pipeline parallelism in mind. In this section, we
833            highlight the core differences between the two systems. As shown in Figure
834              <a class="xref" href="#xerces-arch" title="Xerces Architecture">Figure 1</a>, Xerces is comprised of five main modules: the transcoder, reader,
835            scanner, namespace binder, and validator. The <span class="ital">Transcoder</span> converts source data into UTF-16 before Xerces parses it as XML;
836            the majority of the character set encoding validation is performed as a byproduct of
837            this process. The <span class="ital">Reader</span> is responsible for the
838            streaming and buffering of all raw and transcoded (UTF-16) text. It tracks the current
839            line/column position,
841            performs line-break normalization and validates context-specific character set issues,
842            such as tokenization of qualified-names. The <span class="ital">Scanner</span>
843            pulls data through the reader and constructs the intermediate representation (IR) of the
844            document; it deals with all issues related to entity expansion, validates the XML
845            well-formedness constraints and any character set encoding issues that cannot be
846            completely handled by the reader or transcoder (e.g., surrogate characters, validation
847            and normalization of character references, etc.) The <span class="ital">Namespace
848               Binder</span> is a core piece of the element stack. It handles namespace scoping
849            issues between different XML vocabularies. This allows the scanner to properly select
850            the correct schema grammar structures. The <span class="ital">Validator</span>
851            takes the IR produced by the Scanner (and potentially annotated by the Namespace Binder)
852            and assesses whether the final output matches the user-defined DTD and schema grammar(s)
853            before passing it to the end-user. </p>
854<div class="figure" id="xerces-arch">
855<p class="title">Figure 1: Xerces Architecture</p>
856<div class="figure-contents">
857<div class="mediaobject" id="idp474032"><img alt="png image (xerces.png)" src="xerces.png" width="150cm"></div>
858<div class="caption"></div>
861<p id="idp476352"> In icXML functions are grouped into logical components. As shown in
862             <a class="xref" href="#xerces-arch" title="Xerces Architecture">Figure 1</a>, two major categories exist: (1) the Parabix Subsystem and (2) the
863               Markup Processor. All tasks in (1) use the Parabix Framework <a class="xref" id="idp477440" href="javascript:showcite('cite-HPCA2012','idp477440')">[Lin and Medforth 2012]</a>, which
864            represents data as a set of parallel bitstreams. The <span class="ital">Character Set
865              Adapter</span>, discussed in <a class="xref" href="#character-set-adapter" title="Character Set Adapters">section “Character Set Adapters”</a>, mirrors
866            Xerces's Transcoder duties; however instead of producing UTF-16 it produces a set of
867              lexical bitstreams, similar to those shown in <a class="xref" id="idp479904" href="javascript:showcite('cite-CameronHerdyLin2008','idp479904')">[Parabix1 2008]</a>. These lexical
868            bitstreams are later transformed into UTF-16 in the Content Stream Generator, after
869            additional processing is performed. The first precursor to producing UTF-16 is the
870               <span class="ital">Parallel Markup Parser</span> phase. It takes the lexical
871            streams and produces a set of marker bitstreams in which a 1-bit identifies significant
872            positions within the input data. One bitstream for each of the critical piece of
873            information is created, such as the beginning and ending of start tags, end tags,
874            element names, attribute names, attribute values and content. Intra-element
875            well-formedness validation is performed as an artifact of this process. Like Xerces,
876            icXML must provide the Line and Column position of each error. The <span class="ital">Line-Column Tracker</span> uses the lexical information to keep track of the
877            document position(s) through the use of an optimized population count algorithm,
878              described in <a class="xref" href="#errorhandling" title="Error Handling">section “Error Handling”</a>. From here, two data-independent
879            branches exist: the Symbol Resolver and Content Preparation Unit. </p>
880<p id="idp483888"> A typical XML file contains few unique element and attribute names—but
881            each of them will occur frequently. icXML stores these as distinct data structures,
882            called symbols, each with their own global identifier (GID). Using the symbol marker
883            streams produced by the Parallel Markup Parser, the <span class="ital">Symbol
884               Resolver</span> scans through the raw data to produce a sequence of GIDs, called
885            the <span class="ital">symbol stream</span>. </p>
886<p id="idp486544"> The final components of the Parabix Subsystem are the <span class="ital">Content
887               Preparation Unit</span> and <span class="ital">Content Stream
888            Generator</span>. The former takes the (transposed) basis bitstreams and selectively
889            filters them, according to the information provided by the Parallel Markup Parser, and
890            the latter transforms the filtered streams into the tagged UTF-16 <span class="ital">content stream</span>, discussed in <a class="xref" href="#contentstream" title="Content Stream">section “Content Stream”</a>. </p>
891<p id="idp490144"> Combined, the symbol and content stream form icXML's compressed IR of the XML
892            document. The <span class="ital">Markup Processor</span>
893            parses the IR to
894            validate and produce the sequential output for the end user. The <span class="ital">Final WF checker</span> performs inter-element well-formedness validation that
895            would be too costly to perform in bit space, such as ensuring every start tag has a
896            matching end tag. Xerces's namespace binding functionality is replaced by the <span class="ital">Namespace Processor</span>. Unlike Xerces, it is a discrete phase
897            that produces a series of URI identifiers (URI IDs), the <span class="ital">URI
898               stream</span>, which are associated with each symbol occurrence. This is
899                 discussed in <a class="xref" href="#namespace-handling" title="Namespace Handling">section “Namespace Handling”</a>. Finally, the <span class="ital">Validation</span> layer implements the Xerces's validator. However,
900            preprocessing associated with each symbol greatly reduces the work of this stage. </p>
901<div class="figure" id="icxml-arch">
902<p class="title">Figure 2: icXML Architecture</p>
903<div class="figure-contents">
904<div class="mediaobject" id="idp496608"><img alt="png image (icxml.png)" src="icxml.png" width="500cm"></div>
905<div class="caption"></div>
909<div class="section" id="character-set-adapter">
910<h3 class="title" style="clear: both">Character Set Adapters</h3>
911<p id="idp500096"> In Xerces, all input is transcoded into UTF-16 to simplify the parsing costs of
912            Xerces itself and provide the end-consumer with a single encoding format. In the
913            important case of UTF-8 to UTF-16 transcoding, the transcoding costs can be significant,
914            because of the need to decode and classify each byte of input, mapping variable-length
915            UTF-8 byte sequences into 16-bit UTF-16 code units with bit manipulation operations. In
916            other cases, transcoding may involve table look-up operations for each byte of input. In
917            any case, transcoding imposes at least a cost of buffer copying. </p>
918<p id="idp501152"> In icXML, however, the concept of Character Set Adapters (CSAs) is used to minimize
919            transcoding costs. Given a specified input encoding, a CSA is responsible for checking
920            that input code units represent valid characters, mapping the characters of the encoding
921            into the appropriate bitstreams for XML parsing actions (i.e., producing the lexical
922            item streams), as well as supporting ultimate transcoding requirements. All of this work
923            is performed using the parallel bitstream representation of the source input. </p>
924<p id="idp40944"> An important observation is that many character sets are an extension to the legacy
925            7-bit ASCII character set. This includes the various ISO Latin character sets, UTF-8,
926            UTF-16 and many others. Furthermore, all significant characters for parsing XML are
927            confined to the ASCII repertoire. Thus, a single common set of lexical item calculations
928            serves to compute lexical item streams for all such ASCII-based character sets. </p>
929<p id="idp41824"> A second observation is that—regardless of which character set is
930            used—quite often all of the characters in a particular block of input will be
931            within the ASCII range. This is a very simple test to perform using the bitstream
932            representation, simply confirming that the bit 0 stream is zero for the entire block.
933            For blocks satisfying this test, all logic dealing with non-ASCII characters can simply
934            be skipped. Transcoding to UTF-16 becomes trivial as the high eight bitstreams of the
935            UTF-16 form are each set to zero in this case. </p>
936<p id="idp43744"> A third observation is that repeated transcoding of the names of XML elements,
937            attributes and so on can be avoided by using a look-up mechanism. That is, the first
938            occurrence of each symbol is stored in a look-up table mapping the input encoding to a
939            numeric symbol ID. Transcoding of the symbol is applied at this time. Subsequent look-up
940            operations can avoid transcoding by simply retrieving the stored representation. As
941            symbol look up is required to apply various XML validation rules, there is achieves the
942            effect of transcoding each occurrence without additional cost. </p>
943<p id="idp44800"> The cost of individual character transcoding is avoided whenever a block of input is
944            confined to the ASCII subset and for all but the first occurrence of any XML element or
945            attribute name. Furthermore, when transcoding is required, the parallel bitstream
946            representation supports efficient transcoding operations. In the important case of UTF-8
947            to UTF-16 transcoding, the corresponding UTF-16 bitstreams can be calculated in bit
948              parallel fashion based on UTF-8 streams <a class="xref" id="idp45600" href="javascript:showcite('cite-Cameron2008','idp45600')">[u8u16 2008]</a>, and all but the final bytes
949            of multi-byte sequences can be marked for deletion as discussed in the following
950            subsection. In other cases, transcoding within a block only need be applied for
951            non-ASCII bytes, which are conveniently identified by iterating through the bit 0 stream
952            using bit scan operations. </p>
954<div class="section" id="par-filter">
955<h3 class="title" style="clear: both">Combined Parallel Filtering</h3>
956<p id="idp47952"> As just mentioned, UTF-8 to UTF-16 transcoding involves marking all but the last
957            bytes of multi-byte UTF-8 sequences as positions for deletion. For example, the two
958            Chinese characters <code class="code">䜠奜</code> are represented as two
959            three-byte UTF-8 sequences <code class="code">E4 BD A0</code> and <code class="code">E5 A5 BD</code> while the
960            UTF-16 representation must be compressed down to the two code units <code class="code">4F60</code>
961            and <code class="code">597D</code>. In the bit parallel representation, this corresponds to a
962            reduction from six bit positions representing UTF-8 code units (bytes) down to just two
963            bit positions representing UTF-16 code units (double bytes). This compression may be
964            achieved by arranging to calculate the correct UTF-16 bits at the final position of each
965            sequence and creating a deletion mask to mark the first two bytes of each 3-byte
966            sequence for deletion. In this case, the portion of the mask corresponding to these
967            input bytes is the bit sequence <code class="code">110110</code>. Using this approach, transcoding
968            may then be completed by applying parallel deletion and inverse transposition of the
969            UTF-16 bitstreams<a class="xref" id="idp521312" href="javascript:showcite('cite-Cameron2008','idp521312')">[u8u16 2008]</a>. </p>
970<p id="idp522112"> Rather than immediately paying the costs of deletion and transposition just for
971            transcoding, however, icXML defers these steps so that the deletion masks for several
972            stages of processing may be combined. In particular, this includes core XML requirements
973            to normalize line breaks and to replace character reference and entity references by
974            their corresponding text. In the case of line break normalization, all forms of line
975            breaks, including bare carriage returns (CR), line feeds (LF) and CR-LF combinations
976            must be normalized to a single LF character in each case. In icXML, this is achieved by
977            first marking CR positions, performing two bit parallel operations to transform the
978            marked CRs into LFs, and then marking for deletion any LF that is found immediately
979            after the marked CR as shown by the Pablo source code in
980              <a class="xref" href="#fig-LBnormalization">Figure 3</a>.
981              <div class="figure" id="fig-LBnormalization">
982<p class="title">Figure 3</p>
983<div class="figure-contents">
984<div class="caption">Line Break Normalization Logic</div>
985<pre class="programlisting" id="idp525120">
986# XML 1.0 line-break normalization rules.
987if lex.CR:
988# Modify CR (#x0D) to LF (#x0A)
989  u16lo.bit_5 ^= lex.CR
990  u16lo.bit_6 ^= lex.CR
991  u16lo.bit_7 ^= lex.CR
992  CRLF = pablo.Advance(lex.CR) &amp; lex.LF
993  callouts.delmask |= CRLF
994# Adjust LF streams for line/column tracker
995  lex.LF |= lex.CR
996  lex.LF ^= CRLF
1000         </p>
1001<p id="idp526592"> In essence, the deletion masks for transcoding and for line break normalization each
1002            represent a bitwise filter; these filters can be combined using bitwise-or so that the
1003            parallel deletion algorithm need only be applied once. </p>
1004<p id="idp527248"> A further application of combined filtering is the processing of XML character and
1005           entity references. Consider, for example, the references <code class="code">&amp;amp;</code> or
1006             <code class="code">&amp;#x3C;</code> which must be replaced in XML processing with the single
1007               <code class="code">&amp;</code> and <code class="code">&lt;</code> characters, respectively. The
1008            approach in icXML is to mark all but the first character positions of each reference for
1009            deletion, leaving a single character position unmodified. Thus, for the references
1010               <code class="code">&amp;amp;</code> or <code class="code">&amp;#x3C;</code> the masks <code class="code">01111</code> and
1011               <code class="code">011111</code> are formed and combined into the overall deletion mask. After the
1012            deletion and inverse transposition operations are finally applied, a post-processing
1013            step inserts the proper character at these positions. One note about this process is
1014            that it is speculative; references are assumed to generally be replaced by a single
1015            UTF-16 code unit. In the case, that this is not true, it is addressed in
1016            post-processing. </p>
1017<p id="idp532096"> The final step of combined filtering occurs during the process of reducing markup
1018            data to tag bytes preceding each significant XML transition as described in
1019              <a class="xref" href="#contentstream" title="Content Stream">section “Content Stream”</a>. Overall, icXML avoids separate buffer copying
1020            operations for each of the these filtering steps, paying the cost of parallel deletion
1021            and inverse transposition only once. Currently, icXML employs the parallel-prefix
1022            compress algorithm of Steele <a class="xref" id="idp533408" href="javascript:showcite('cite-HackersDelight','idp533408')">[Warren 2002]</a>. Performance is independent of the
1023            number of positions deleted. Future versions of icXML are expected to take advantage of
1024            the parallel extract operation <a class="xref" id="idp534304" href="javascript:showcite('cite-HilewitzLee2006','idp534304')">[Hilewitz and Lee 2006]</a> that Intel is now providing in its
1025            Haswell architecture. </p>
1027<div class="section" id="contentstream">
1028<h3 class="title" style="clear: both">Content Stream</h3>
1029<p id="idp536352"> A relatively-unique concept for icXML is the use of a filtered content stream.
1030            Rather that parsing an XML document in its original format, the input is transformed
1031            into one that is easier for the parser to iterate through and produce the sequential
1032            output. In <a class="xref" href="#fig-parabix2">Table V</a>, the source data
1033             <code class="code"> &lt;document&gt;fee&lt;element a1='fie' a2 = 'foe'&gt;&lt;/element&gt;fum&lt;/document&gt;</code>
1034             is transformed into <code class="code"><span class="ital">0</span>fee<span class="ital">0</span>=fie<span class="ital">0</span>=foe<span class="ital">0</span>&gt;<span class="ital">0</span>/fum<span class="ital">0</span>/</code>
1035            through the parallel filtering algorithm, described in <a class="xref" href="#par-filter" title="Combined Parallel Filtering">section “Combined Parallel Filtering”</a>. </p>
1036<div class="table-wrapper" id="fig-parabix2">
1037<p class="title">Table V</p>
1038<div class="caption">XML Source Data and Derived Parallel Bit Streams</div>
1039<table class="table" xml:id="fig-parabix2">
1040<colgroup span="1">
1041<col align="centre" valign="top" span="1">
1042<col align="left" valign="top" span="1">
1046<td> Source Data </td>
1048                                    <code class="code"> &lt;document&gt;fee&lt;element a1='fie' a2 = 'foe'&gt;&lt;/element&gt;fum&lt;/document&gt; </code>
1052<td> String Ends </td>
1053<td> <code class="code">1____________1_______________1__________1_1____________1__________</code>
1057<td> Markup Identifiers </td>
1058<td>         <code class="code">_________1______________1_________1______1_1____________1_________</code>
1062<td> Deletion Mask </td>
1063<td>              <code class="code">_11111111_____1111111111_1____1111_11_______11111111_____111111111</code>
1067<td> Undeleted Data </td>
1068<td> <code class="code"><span class="ital">0</span>________&gt;fee<span class="ital">0</span>__________=_fie<span class="ital">0</span>____=__foe<span class="ital">0</span>&gt;<span class="ital">0</span>/________fum<span class="ital">0</span>/_________</code>
1074<p id="idp557712"> Combined with the symbol stream, the parser traverses the content stream to
1075            effectively reconstructs the input document in its output form. The initial <span class="ital">0</span> indicates an empty content string. The following
1076               <code class="code">&gt;</code> indicates that a start tag without any attributes is the first
1077            element in this text and the first unused symbol, <code class="code">document</code>, is the element
1078            name. Succeeding that is the content string <code class="code">fee</code>, which is null-terminated
1079            in accordance with the Xerces API specification. Unlike Xerces, no memory-copy
1080            operations are required to produce these strings, which as
1081              <a class="xref" href="#xerces-profile">Table I</a> shows accounts for 6.83% of Xerces's execution time.
1082            Additionally, it is cheap to locate the terminal character of each string: using the
1083            String End bitstream, the Parabix Subsystem can effectively calculate the offset of each
1084            null character in the content stream in parallel, which in turn means the parser can
1085            directly jump to the end of every string without scanning for it. </p>
1086<p id="idp561792"> Following <code class="code">'fee'</code> is a <code class="code">=</code>, which marks the
1087            existence of an attribute. Because all of the intra-element was performed in the Parabix
1088            Subsystem, this must be a legal attribute. Since attributes can only occur within start
1089            tags and must be accompanied by a textual value, the next symbol in the symbol stream
1090            must be the element name of a start tag, and the following one must be the name of the
1091            attribute and the string that follows the <code class="code">=</code> must be its value. However, the
1092            subsequent <code class="code">=</code> is not treated as an independent attribute because the parser
1093            has yet to read a <code class="code">&gt;</code>, which marks the end of a start tag. Thus only
1094            one symbol is taken from the symbol stream and it (along with the string value) is added
1095            to the element. Eventually the parser reaches a <code class="code">/</code>, which marks the
1096            existence of an end tag. Every end tag requires an element name, which means they
1097            require a symbol. Inter-element validation whenever an empty tag is detected to ensure
1098            that the appropriate scope-nesting rules have been applied. </p>
1100<div class="section" id="namespace-handling">
1101<h3 class="title" style="clear: both">Namespace Handling</h3>
1102<p id="idp567360"> In XML, namespaces prevents naming conflicts when multiple vocabularies are used
1103            together. It is especially important when a vocabulary application-dependant meaning,
1104            such as when XML or SVG documents are embedded within XHTML files. Namespaces are bound
1105            to uniform resource identifiers (URIs), which are strings used to identify specific
1106            names or resources. On line 1 in <a class="xref" href="#namespace-ex">Table VI</a>, the <code class="code">xmlns</code>
1107            attribute instructs the XML processor to bind the prefix <code class="code">p</code> to the URI
1108               '<code class="code"></code>' and the default (empty) prefix to
1109               <code class="code"></code>. Thus to the XML processor, the <code class="code">title</code> on line 2
1110            and <code class="code">price</code> on line 4 both read as
1111            <code class="code">"":title</code> and
1112               <code class="code">"":price</code> respectively, whereas on line 3 and
1113            5, <code class="code">p:name</code> and <code class="code">price</code> are seen as
1114               <code class="code">"":name</code> and
1115               <code class="code">"":price</code>. Even though the actual element name
1116               <code class="code">price</code>, due to namespace scoping rules they are viewed as two
1117            uniquely-named items because the current vocabulary is determined by the namespace(s)
1118            that are in-scope. </p>
1119<div class="table-wrapper" id="namespace-ex">
1120<p class="title">Table VI</p>
1121<div class="caption"><p id="idp576096">XML Namespace Example</p></div>
1122<table class="table" xml:id="namespace-ex">
1123<colgroup span="1">
1124<col align="centre" valign="top" span="1">
1125<col align="left" valign="top" span="1">
1129<td>1. </td>
1130<td>&lt;book xmlns:p="" xmlns=""&gt; </td>
1133<td>2. </td>
1134<td>  &lt;title&gt;BOOK NAME&lt;/title&gt; </td>
1137<td>3. </td>
1138<td>  &lt;p:name&gt;PUBLISHER NAME&lt;/p:name&gt; </td>
1141<td>4. </td>
1142<td>  &lt;price&gt;X&lt;/price&gt; </td>
1145<td>5. </td>
1146<td>  &lt;price xmlns=""&gt;Y&lt;/price&gt; </td>
1149<td>6. </td>
1150<td>&lt;/book&gt; </td>
1155<p id="idp585136"> In both Xerces and icXML, every URI has a one-to-one mapping to a URI ID. These
1156            persist for the lifetime of the application through the use of a global URI pool. Xerces
1157            maintains a stack of namespace scopes that is pushed (popped) every time a start tag
1158            (end tag) occurs in the document. Because a namespace declaration affects the entire
1159            element, it must be processed prior to grammar validation. This is a costly process
1160            considering that a typical namespaced XML document only comes in one of two forms: (1)
1161            those that declare a set of namespaces upfront and never change them, and (2) those that
1162            repeatedly modify the namespaces in predictable patterns. </p>
1163<p id="idp586272"> For that reason, icXML contains an independent namespace stack and utilizes bit
1164            vectors to cheaply perform
1165             When a prefix is
1166            declared (e.g., <code class="code">xmlns:p=""</code>), a namespace binding
1167            is created that maps the prefix (which are assigned Prefix IDs in the symbol resolution
1168            process) to the URI. Each unique namespace binding has a unique namespace id (NSID) and
1169            every prefix contains a bit vector marking every NSID that has ever been associated with
1170              it within the document. For example, in <a class="xref" href="#namespace-ex">Table VI</a>, the prefix binding
1171            set of <code class="code">p</code> and <code class="code">xmlns</code> would be <code class="code">01</code> and
1172            <code class="code">11</code> respectively. To resolve the in-scope namespace binding for each prefix,
1173            a bit vector of the currently visible namespaces is maintained by the system. By ANDing
1174            the prefix bit vector with the currently visible namespaces, the in-scope NSID can be
1175            found using a bit-scan intrinsic. A namespace binding table, similar to
1176            <a class="xref" href="#namespace-binding">Table VII</a>, provides the actual URI ID. </p>
1177<div class="table-wrapper" id="namespace-binding">
1178<p class="title">Table VII</p>
1179<div class="caption"><p id="idp592944">Namespace Binding Table Example</p></div>
1180<table class="table" xml:id="namespace-binding">
1181<colgroup span="1">
1182<col align="centre" valign="top" span="1">
1183<col align="centre" valign="top" span="1">
1184<col align="centre" valign="top" span="1">
1185<col align="centre" valign="top" span="1">
1186<col align="centre" valign="top" span="1">
1189<th>NSID </th>
1190<th> Prefix </th>
1191<th> URI </th>
1192<th> Prefix ID </th>
1193<th> URI ID </th>
1197<td>0 </td>
1198<td> <code class="code"> p</code> </td>
1199<td> <code class="code"></code> </td>
1200<td> 0 </td>
1201<td> 0 </td>
1204<td>1 </td>
1205<td> <code class="code"> xmlns</code> </td>
1206<td> <code class="code"></code> </td>
1207<td> 1 </td>
1208<td> 1 </td>
1211<td>2 </td>
1212<td> <code class="code"> xmlns</code> </td>
1213<td> <code class="code"></code> </td>
1214<td> 1 </td>
1215<td> 0 </td>
1220<p id="idp609264">
1225         </p>
1226<p id="idp611168"> To ensure that scoping rules are adhered to, whenever a start tag is encountered,
1227            any modification to the currently visible namespaces is calculated and stored within a
1228            stack of bit vectors denoting the locally modified namespace bindings. When an end tag
1229            is found, the currently visible namespaces is XORed with the vector at the top of the
1230            stack. This allows any number of changes to be performed at each scope-level with a
1231            constant time.
1233         </p>
1235<div class="section" id="errorhandling">
1236<h3 class="title" style="clear: both">Error Handling</h3>
1237<p id="idp613600">
1239            Xerces outputs error messages in two ways: through the programmer API and as thrown
1240            objects for fatal errors. As Xerces parses a file, it uses context-dependant logic to
1241            assess whether the next character is legal; if not, the current state determines the
1242            type and severity of the error. icXML emits errors in the similar manner—but
1243            how it discovers them is substantially different. Recall that in Figure
1244            <a class="xref" href="#icxml-arch" title="icXML Architecture">Figure 2</a>, icXML is divided into two sections: the Parabix Subsystem and
1245            Markup Processor, each with its own system for detecting and producing error messages. </p>
1246<p id="idp616160"> Within the Parabix Subsystem, all computations are performed in parallel, a block at
1247            a time. Errors are derived as artifacts of bitstream calculations, with a 1-bit marking
1248            the byte-position of an error within a block, and the type of error is determined by the
1249            equation that discovered it. The difficulty of error processing in this section is that
1250            in Xerces the line and column number must be given with every error production. Two
1251            major issues exist because of this: (1) line position adheres to XML white-normalization
1252            rules; as such, some sequences of characters, e.g., a carriage return followed by a line
1253            feed, are counted as a single new line character. (2) column position is counted in
1254            characters, not bytes or code units; thus multi-code-unit code-points and surrogate
1255            character pairs are all counted as a single column position. Note that typical XML
1256            documents are error-free but the calculation of the line/column position is a constant
1257            overhead in Xerces.  To
1258            reduce this, icXML pushes the bulk cost of the line/column calculation to the occurrence
1259            of the error and performs the minimal amount of book-keeping necessary to facilitate it.
1260            icXML leverages the byproducts of the Character Set Adapter (CSA) module and amalgamates
1261            the information within the Line Column Tracker (LCT). One of the CSA's major
1262            responsibilities is transcoding an input text.
1263             During this process,
1264            white-space normalization rules are applied and multi-code-unit and surrogate characters
1265            are detected and validated. A <span class="ital">line-feed bitstream</span>,
1266            which marks the positions of the normalized new lines characters, is a natural
1267            derivative of this process. Using an optimized population count algorithm, the line
1268            count can be summarized cheaply for each valid block of text.
1269             Column position is more
1270            difficult to calculate. It is possible to scan backwards through the bitstream of new
1271            line characters to determine the distance (in code-units) between the position between
1272            which an error was detected and the last line feed. However, this distance may exceed
1273            than the actual character position for the reasons discussed in (2). To handle this, the
1274            CSA generates a <span class="ital">skip mask</span> bitstream by ORing together
1275            many relevant bitstreams, such as all trailing multi-code-unit and surrogate characters,
1276            and any characters that were removed during the normalization process. When an error is
1277            detected, the sum of those skipped positions is subtracted from the distance to
1278            determine the actual column number. </p>
1279<p id="idp621680"> The Markup Processor is a state-driven machine. As such, error detection within it
1280            is very similar to Xerces. However, reporting the correct line/column is a much more
1281            difficult problem. The Markup Processor parses the content stream, which is a series of
1282            tagged UTF-16 strings. Each string is normalized in accordance with the XML
1283            specification. All symbol data and unnecessary whitespace is eliminated from the stream;
1284            thus its impossible to derive the current location using only the content stream. To
1285            calculate the location, the Markup Processor borrows three additional pieces of
1286            information from the Parabix Subsystem: the line-feed, skip mask, and a <span class="ital">deletion mask stream</span>, which is a bitstream denoting the
1287            (code-unit) position of every datum that was suppressed from the source during the
1288            production of the content stream. Armed with these, it is possible to calculate the
1289            actual line/column using the same system as the Parabix Subsystem until the sum of the
1290            negated deletion mask stream is equal to the current position. </p>
1293<div class="section" id="multithread">
1294<h2 class="title" style="clear: both">Multithreading with Pipeline Parallelism</h2>
1295<p id="idp625216"> As discussed in section <a class="xref" href="#background-xerces" title="Xerces C++ Structure">section “Xerces C++ Structure”</a>, Xerces can be considered a FSM
1296         application. These are "embarrassingly
1297         sequential."<a class="xref" id="idp626368" href="javascript:showcite('cite-Asanovic-EECS-2006-183','idp626368')">[Asanovic et al. 2006]</a> and notoriously difficult to
1298         parallelize. However, icXML is designed to organize processing into logical layers. In
1299         particular, layers within the Parabix Subsystem are designed to operate over significant
1300         segments of input data before passing their outputs on for subsequent processing. This fits
1301         well into the general model of pipeline parallelism, in which each thread is in charge of a
1302         single module or group of modules. </p>
1303<p id="idp627680"> The most straightforward division of work in icXML is to separate the Parabix Subsystem
1304         and the Markup Processor into distinct logical layers into two separate stages. The
1305         resultant application, <span class="ital">icXML-p</span>, is a course-grained
1306         software-pipeline application. In this case, the Parabix Subsystem thread
1307               <code class="code">T<sub>1</sub></code> reads 16k of XML input <code class="code">I</code> at a
1308         time and produces the content, symbol and URI streams, then stores them in a pre-allocated
1309         shared data structure <code class="code">S</code>. The Markup Processor thread
1310            <code class="code">T<sub>2</sub></code> consumes <code class="code">S</code>, performs well-formedness
1311         and grammar-based validation, and the provides parsed XML data to the application through
1312         the Xerces API. The shared data structure is implemented using a ring buffer, where every
1313         entry contains an independent set of data streams. In the examples of
1314           <a class="xref" href="#threads_timeline1" title="Thread Balance in Two-Stage Pipelines: Stage 1 Dominant">Figure 4</a>, the ring buffer has four entries. A
1315         lock-free mechanism is applied to ensure that each entry can only be read or written by one
1316         thread at the same time. In  <a class="xref" href="#threads_timeline1" title="Thread Balance in Two-Stage Pipelines: Stage 1 Dominant">Figure 4</a> the processing time of
1317               <code class="code">T<sub>1</sub></code> is longer than
1318         <code class="code">T<sub>2</sub></code>; thus <code class="code">T<sub>2</sub></code> always
1319         waits for <code class="code">T<sub>1</sub></code> to write to the shared memory. 
1320         <a class="xref" href="#threads_timeline2" title="Thread Balance in Two-Stage Pipelines: Stage 2 Dominant">Figure 5</a> illustrates the scenario in which
1321         <code class="code">T<sub>1</sub></code> is faster and must wait for
1322            <code class="code">T<sub>2</sub></code> to finish reading the shared data before it can
1323         reuse the memory space. </p>
1324<p id="idp638752">
1325        <div class="figure" id="threads_timeline1">
1326<p class="title">Figure 4: Thread Balance in Two-Stage Pipelines: Stage 1 Dominant</p>
1327<div class="figure-contents"><div class="mediaobject" id="idp640080"><img alt="png image (threads_timeline1.png)" src="threads_timeline1.png" width="500cm"></div></div>
1329        <div class="figure" id="threads_timeline2">
1330<p class="title">Figure 5: Thread Balance in Two-Stage Pipelines: Stage 2 Dominant</p>
1331<div class="figure-contents"><div class="mediaobject" id="idp643088"><img alt="png image (threads_timeline2.png)" src="threads_timeline2.png" width="500cm"></div></div>
1333      </p>
1334<p id="idp645120"> Overall, our design is intended to benefit a range of applications. Conceptually, we
1335         consider two design points. The first, the parsing performed by the Parabix Subsystem
1336         dominates at 67% of the overall cost, with the cost of application processing (including
1337         the driver logic within the Markup Processor) at 33%. The second is almost the opposite
1338         scenario, the cost of application processing dominates at 60%, while the cost of XML
1339         parsing represents an overhead of 40%. </p>
1340<p id="idp646032"> Our design is predicated on a goal of using the Parabix framework to achieve a 50% to
1341         100% improvement in the parsing engine itself. In a best case scenario, a 100% improvement
1342         of the Parabix Subsystem for the design point in which XML parsing dominates at 67% of the
1343         total application cost. In this case, the single-threaded icXML should achieve a 1.5x
1344         speedup over Xerces so that the total application cost reduces to 67% of the original.
1345         However, in icXML-p, our ideal scenario gives us two well-balanced threads each performing
1346         about 33% of the original work. In this case, Amdahl's law predicts that we could expect up
1347         to a 3x speedup at best. </p>
1348<p id="idp647152"> At the other extreme of our design range, we consider an application in which core
1349         parsing cost is 40%. Assuming the 2x speedup of the Parabix Subsystem over the
1350         corresponding Xerces core, single-threaded icXML delivers a 25% speedup. However, the most
1351         significant aspect of our two-stage multi-threaded design then becomes the ability to hide
1352         the entire latency of parsing within the serial time required by the application. In this
1353         case, we achieve an overall speedup in processing time by 1.67x. </p>
1354<p id="idp648096"> Although the structure of the Parabix Subsystem allows division of the work into
1355         several pipeline stages and has been demonstrated to be effective for four pipeline stages
1356         in a research prototype <a class="xref" id="idp648576" href="javascript:showcite('cite-HPCA2012','idp648576')">[Lin and Medforth 2012]</a>, our analysis here suggests that the further
1357         pipelining of work within the Parabix Subsystem is not worthwhile if the cost of
1358         application logic is little as 33% of the end-to-end cost using Xerces. To achieve benefits
1359         of further parallelization with multi-core technology, there would need to be reductions in
1360         the cost of application logic that could match reductions in core parsing cost. </p>
1362<div class="section" id="performance">
1363<h2 class="title" style="clear: both">Performance</h2>
1364<p id="idp650960"> We evaluate Xerces-C++ 3.1.1, icXML, icXML-p against two benchmarking applications: the
1365         Xerces C++ SAXCount sample application, and a real world GML to SVG transformation
1366         application. We investigated XML parser performance using an Intel Core i7 quad-core (Sandy
1367         Bridge) processor (3.40GHz, 4 physical cores, 8 threads (2 per core), 32+32 kB (per core)
1368         L1 cache, 256 kB (per core) L2 cache, 8 MB L3 cache) running the 64-bit version of Ubuntu
1369         12.04 (Linux). </p>
1370<p id="idp651872"> We analyzed the execution profiles of each XML parser using the performance counters
1371         found in the processor. We chose several key hardware events that provide insight into the
1372         profile of each application and indicate if the processor is doing useful work. The set of
1373         events included in our study are: processor cycles, branch instructions, branch
1374         mispredictions, and cache misses. The Performance Application Programming Interface (PAPI)
1375         Version 5.5.0 <a class="xref" id="idp652640" href="javascript:showcite('cite-papi','idp652640')">[PAPI]</a> toolkit was installed on the test system to facilitate the
1376         collection of hardware performance monitoring statistics. In addition, we used the Linux
1377         perf <a class="xref" id="idp653568" href="javascript:showcite('cite-perf','idp653568')">[perf]</a> utility to collect per core hardware events. </p>
1378<div class="section" id="idp654464">
1379<h3 class="title" style="clear: both">Xerces C++ SAXCount</h3>
1380<p id="idp655104"> Xerces comes with sample applications that demonstrate salient features of the
1381            parser. SAXCount is the simplest such application: it counts the elements, attributes
1382            and characters of a given XML file using the (event based) SAX API and prints out the
1383            totals. </p>
1384<p id="idp655808"> <a class="xref" href="#XMLdocs">Table VIII</a> shows the document characteristics of the XML input files
1385            selected for the Xerces C++ SAXCount benchmark. The jaw.xml represents document-oriented
1386            XML inputs and contains the three-byte and four-byte UTF-8 sequence required for the
1387            UTF-8 encoding of Japanese characters. The remaining data files are data-oriented XML
1388            documents and consist entirely of single byte encoded ASCII characters.
1389  <div class="table-wrapper" id="XMLdocs">
1390<p class="title">Table VIII</p>
1391<div class="caption"><p id="idp658256">XML Document Characteristics</p></div>
1392<table class="table" xml:id="XMLdocs">
1393<colgroup span="1">
1394<col align="left" valign="top" span="1">
1395<col align="centre" valign="top" span="1">
1396<col align="centre" valign="top" span="1">
1397<col align="centre" valign="top" span="1">
1398<col align="centre" valign="top" span="1">
1402<td>File Name           </td>
1403<td> jaw.xml            </td>
1404<td> road.gml   </td>
1405<td> po.xml     </td>
1406<td> soap.xml </td>
1409<td>File Type           </td>
1410<td> document           </td>
1411<td> data               </td>
1412<td> data               </td>
1413<td> data        </td>
1416<td>File Size (kB)              </td>
1417<td> 7343                       </td>
1418<td> 11584      </td>
1419<td> 76450              </td>
1420<td> 2717 </td>
1423<td>Markup Item Count   </td>
1424<td> 74882              </td>
1425<td> 280724     </td>
1426<td> 4634110    </td>
1427<td> 18004 </td>
1430<td>Markup Density              </td>
1431<td> 0.13                       </td>
1432<td> 0.57       </td>
1433<td> 0.76               </td>
1434<td> 0.87       </td>
1440<p id="idp673856"> A key predictor of the overall parsing performance of an XML file is markup
1441           density<sup class="fn-label"><a href="#idp674224" class="footnoteref" id="idp674224-ref">[2]</a></sup>. This metric has substantial influence on the
1442            performance of traditional recursive descent XML parsers because it directly corresponds
1443            to the number of state transitions that occur when parsing a document. We use a mixture
1444            of document-oriented and data-oriented XML files to analyze performance over a spectrum
1445            of markup densities. </p>
1446<p id="idp675392"> <a class="xref" href="#perf_SAX" title="SAXCount Performance Comparison">Figure 6</a> compares the performance of Xerces, icXML and pipelined icXML
1447            in terms of CPU cycles per byte for the SAXCount application. The speedup for icXML over
1448            Xerces is 1.3x to 1.8x. With two threads on the multicore machine, icXML-p can achieve
1449            speedup up to 2.7x. Xerces is substantially slowed by dense markup but icXML is less
1450            affected through a reduction in branches and the use of parallel-processing techniques.
1451            icXML-p performs better as markup-density increases because the work performed by each
1452            stage is well balanced in this application. </p>
1453<p id="idp677136">
1454        <div class="figure" id="perf_SAX">
1455<p class="title">Figure 6: SAXCount Performance Comparison</p>
1456<div class="figure-contents">
1457<div class="mediaobject" id="idp678448"><img alt="png image (perf_SAX.png)" src="perf_SAX.png" width="500cm"></div>
1458<div class="caption"></div>
1461         </p>
1463<div class="section" id="idp680992">
1464<h3 class="title" style="clear: both">GML2SVG</h3>
1465<p id="idp681664">       As a more substantial application of XML processing, the GML-to-SVG (GML2SVG) application
1466was chosen.   This application transforms geospatially encoded data represented using
1467an XML representation in the form of Geography Markup Language (GML) <a class="xref" id="idp682192" href="javascript:showcite('cite-lake2004geography','idp682192')">[Lake and Burggraf 2004]</a> 
1468into a different XML format  suitable for displayable maps:
1469Scalable Vector Graphics (SVG) format <a class="xref" id="idp683088" href="javascript:showcite('cite-lu2007advances','idp683088')">[Lu and Dos Santos 2007]</a>. In the GML2SVG benchmark, GML feature elements
1470and GML geometry elements tags are matched. GML coordinate data are then extracted
1471and transformed to the corresponding SVG path data encodings.
1472Equivalent SVG path elements are generated and output to the destination
1473SVG document.  The GML2SVG application is thus considered typical of a broad
1474class of XML applications that parse and extract information from
1475a known XML format for the purpose of analysis and restructuring to meet
1476the requirements of an alternative format.</p>
1477<p id="idp684464">Our GML to SVG data translations are executed on GML source data
1478modelling the city of Vancouver, British Columbia, Canada.
1479The GML source document set
1480consists of 46 distinct GML feature layers ranging in size from approximately 9 KB to 125.2 MB
1481and with an average document size of 18.6 MB. Markup density ranges from approximately 0.045 to 0.719
1482and with an average markup density of 0.519. In this performance study,
1483213.4 MB of source GML data generates 91.9 MB of target SVG data.</p>
1484<div class="figure" id="perf_GML2SVG">
1485<p class="title">Figure 7: Performance Comparison for GML2SVG</p>
1486<div class="figure-contents">
1487<div class="mediaobject" id="idp686464"><img alt="png image (Throughput.png)" src="Throughput.png" width="500cm"></div>
1488<div class="caption"></div>
1491<p id="idp688752"><a class="xref" href="#perf_GML2SVG" title="Performance Comparison for GML2SVG">Figure 7</a> compares the performance of the GML2SVG application linked against
1492the Xerces, icXML and icXML-p.   
1493On the GML workload with this application, single-thread icXML
1494achieved about a 50% acceleration over Xerces,
1495increasing throughput on our test machine from 58.3 MB/sec to 87.9 MB/sec.   
1496Using icXML-p, a further throughput increase to 111 MB/sec was recorded,
1497approximately a 2X speedup.</p>
1498<p id="idp690160">An important aspect of icXML is the replacement of much branch-laden
1499sequential code inside Xerces with straight-line SIMD code using far
1500fewer branches.  <a class="xref" href="#branchmiss_GML2SVG" title="Comparative Branch Misprediction Rate">Figure 8</a> shows the corresponding
1501improvement in branching behaviour, with a dramatic reduction in branch misses per kB.
1502It is also interesting to note that icXML-p goes even further.   
1503In essence, in using pipeline parallelism to split the instruction
1504stream onto separate cores, the branch target buffers on each core are
1505less overloaded and able to increase the successful branch prediction rate.</p>
1506<div class="figure" id="branchmiss_GML2SVG">
1507<p class="title">Figure 8: Comparative Branch Misprediction Rate</p>
1508<div class="figure-contents">
1509<div class="mediaobject" id="idp692896"><img alt="png image (BM.png)" src="BM.png" width="500cm"></div>
1510<div class="caption"></div>
1513<p id="idp695184">The behaviour of the three versions with respect to L1 cache misses per kB is shown
1514in <a class="xref" href="#cachemiss_GML2SVG" title="Comparative Cache Miss Rate">Figure 9</a>.   Improvements are shown in both instruction-
1515and data-cache performance with the improvements in instruction-cache
1516behaviour the most dramatic.   Single-threaded icXML shows substantially improved
1517performance over Xerces on both measures.   
1518Although icXML-p is slightly worse with respect to data-cache performance,
1519this is more than offset by a further dramatic reduction in instruction-cache miss rate.
1520Again partitioning the instruction stream through the pipeline parallelism model has
1521significant benefit.</p>
1522<div class="figure" id="cachemiss_GML2SVG">
1523<p class="title">Figure 9: Comparative Cache Miss Rate</p>
1524<div class="figure-contents">
1525<div class="mediaobject" id="idp697984"><img alt="png image (CM.png)" src="CM.png" width="500cm"></div>
1526<div class="caption"></div>
1529<p id="idp700272">One caveat with this study is that the GML2SVG application did not exhibit
1530a relative balance of processing between application code and Xerces library
1531code reaching the 33% figure.  This suggests that for this application and
1532possibly others, further separating the logical layers of the
1533icXML engine into different pipeline stages could well offer significant benefit.
1534This remains an area of ongoing work.</p>
1537<div class="section" id="conclusion">
1538<h2 class="title" style="clear: both">Conclusion and Future Work</h2>
1539<p id="idp702432"> This paper is the first case study documenting the significant performance benefits
1540         that may be realized through the integration of parallel bitstream technology into existing
1541         widely-used software libraries. In the case of the Xerces-C++ XML parser, the combined
1542         integration of SIMD and multicore parallelism was shown capable of dramatic producing
1543         dramatic increases in throughput and reductions in branch mispredictions and cache misses.
1544         The modified parser, going under the name icXML is designed to provide the full
1545         functionality of the original Xerces library with complete compatibility of APIs. Although
1546         substantial re-engineering was required to realize the performance potential of parallel
1547         technologies, this is an important case study demonstrating the general feasibility of
1548         these techniques. </p>
1549<p id="idp703712"> The further development of icXML to move beyond 2-stage pipeline parallelism is
1550         ongoing, with realistic prospects for four reasonably balanced stages within the library.
1551         For applications such as GML2SVG which are dominated by time spent on XML parsing, such a
1552         multistage pipelined parsing library should offer substantial benefits. </p>
1553<p id="idp704480"> The example of XML parsing may be considered prototypical of finite-state machines
1554         applications which have sometimes been considered "embarassingly
1555         sequential" and so difficult to parallelize that "nothing
1556         works." So the case study presented here should be considered an important data
1557         point in making the case that parallelization can indeed be helpful across a broad array of
1558         application types. </p>
1559<p id="idp705856"> To overcome the software engineering challenges in applying parallel bitstream
1560         technology to existing software systems, it is clear that better library and tool support
1561         is needed. The techniques used in the implementation of icXML and documented in this paper
1562         could well be generalized for applications in other contexts and automated through the
1563         creation of compiler technology specifically supporting parallel bitstream programming.
1564      </p>
1566<div class="bibliography" id="idp706864">
1567<h2 class="title" style="clear:both">Bibliography</h2>
1568<p class="bibliomixed" id="CameronHerdyLin2008"><a href="#idp453984">[[Parabix1 2008]] </a>Cameron, Robert D., Herdy, Kenneth S. and Lin, Dan. High performance XML parsing using parallel bit stream technology. CASCON'08: Proc. 2008 conference of the center for advanced studies on collaborative research. 2008 New York, NY, USA</p>
1569<p class="bibliomixed" id="papi"><a href="#idp652640">[[PAPI]] </a>Innovative Computing Laboratory, University of Texas. Performance Application Programming Interface.<a href="" class="link" target="_new"></a></p>
1570<p class="bibliomixed" id="perf"><a href="#idp653568">[[perf]] </a>Eranian, Stephane, Gouriou, Eric, Moseley, Tipp and Bruijn, Willem de. Linux kernel profiling with perf.<a href="" class="link" target="_new"></a></p>
1571<p class="bibliomixed" id="Cameron2008"><a href="#idp453088">[[u8u16 2008]] </a>Cameron, Robert D.. A case study in SIMD text processing with parallel bit streams: UTF-8 to UTF-16 transcoding. Proc. 13th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming. 2008 New York, NY, USA</p>
1572<p class="bibliomixed" id="ParaDOM2009"><a href="#idp303712">[[Shah and Rao 2009]] </a>Shah, Bhavik, Rao, Praveen, Moon, Bongki and Rajagopalan, Mohan. A Data Parallel Algorithm for XML DOM Parsing. Database and XML Technologies. 2009</p>
1573<p class="bibliomixed" id="XMLSSE42"><a href="#idp306864">[[Lei 2008]] </a>Lei, Zhai. XML Parsing Accelerator with Intel Streaming SIMD Extensions 4 (Intel SSE4). 2008<a href="Intel%20Software%20Network" class="link" target="_new">Intel Software Network</a></p>
1574<p class="bibliomixed" id="Cameron2009"><a href="#idp307776">[[Balisage 2009]] </a>Cameron, Rob, Herdy, Ken and Amiri, Ehsan Amiri. Parallel Bit Stream Technology as a Foundation for XML Parsing Performance. Int'l Symposium on Processing XML Efficiently: Overcoming Limits on Space, Time, or Bandwidth. 2009</p>
1575<p class="bibliomixed" id="HilewitzLee2006"><a href="#idp534304">[[Hilewitz and Lee 2006]] </a>Hilewitz, Yedidya and Lee, Ruby B.. Fast Bit Compression and Expansion with Parallel Extract and Parallel Deposit Instructions. ASAP '06: Proc. IEEE 17th Int'l Conference on Application-specific Systems, Architectures and Processors. 2006 Washington, DC, USA</p>
1576<p class="bibliomixed" id="Asanovic-EECS-2006-183"><a href="#idp626368">[[Asanovic et al. 2006]] </a>Asanovic, Krste and others. The Landscape of Parallel Computing Research: A View from Berkeley. 2006</p>
1577<p class="bibliomixed" id="GRID2006"><a href="#idp288288">[[Lu and Chiu 2006]] </a>Lu, Wei, Chiu, Kenneth and Pan, Yinfei. A Parallel Approach to XML Parsing. Proceedings of the 7th IEEE/ACM International Conference on Grid Computing. 2006 Washington, DC, USA</p>
1578<p class="bibliomixed" id="cameron-EuroPar2011"><a href="#idp308528">[[Parabix2 2011]] </a>Cameron, Robert D., Amiri, Ehsan, Herdy, Kenneth S., Lin, Dan, Shermer, Thomas C. and Popowich, Fred P.. Parallel Scanning with Bitstream Addition: An XML Case Study. Euro-Par 2011, LNCS 6853, Part II. 2011 Berlin, Heidelberg</p>
1579<p class="bibliomixed" id="HPCA2012"><a href="#idp305920">[[Lin and Medforth 2012]] </a>Lin, Dan, Medforth, Nigel, Herdy, Kenneth S., Shriraman, Arrvindh and Cameron, Rob. Parabix: Boosting the efficiency of text processing on commodity processors. International Symposium on High-Performance Computer Architecture. 2012 Los Alamitos, CA, USA</p>
1580<p class="bibliomixed" id="HPCC2011"><a href="#idp302880">[[You and Wang 2011]] </a>You, Cheng-Han and Wang, Sheng-De. A Data Parallel Approach to XML Parsing and Query. 10th IEEE International Conference on High Performance Computing and Communications. 2011 Los Alamitos, CA, USA</p>
1581<p class="bibliomixed" id="E-SCIENCE2007"><a href="#idp301312">[[Pan and Zhang 2007]] </a>Pan, Yinfei, Zhang, Ying, Chiu, Kenneth and Lu, Wei. Parallel XML Parsing Using Meta-DFAs. International Conference on e-Science and Grid Computing. 2007 Los Alamitos, CA, USA</p>
1582<p class="bibliomixed" id="ICWS2008"><a href="#idp304576">[[Pan and Zhang 2008a]] </a>Pan, Yinfei, Zhang, Ying and Chiu, Kenneth. Hybrid Parallelism for XML SAX Parsing. IEEE International Conference on Web Services. 2008 Los Alamitos, CA, USA</p>
1583<p class="bibliomixed" id="IPDPS2008"><a href="#idp302064">[[Pan and Zhang 2008b]] </a>Pan, Yinfei, Zhang, Ying and Chiu, Kenneth. Simultaneous transducers for data-parallel XML parsing. International Parallel and Distributed Processing Symposium. 2008 Los Alamitos, CA, USA</p>
1584<p class="bibliomixed" id="HackersDelight"><a href="#idp533408">[[Warren 2002]] </a>Warren, Henry S.. Hacker's Delight. 2002</p>
1585<p class="bibliomixed" id="lu2007advances"><a href="#idp683088">[[Lu and Dos Santos 2007]] </a>Lu, C.T., Dos Santos, R.F., Sripada, L.N. and Kou, Y.. Advances in GML for geospatial applications. 2007</p>
1586<p class="bibliomixed" id="lake2004geography"><a href="#idp682192">[[Lake and Burggraf 2004]] </a>Lake, R., Burggraf, D.S., Trninic, M. and Rae, L.. Geography mark-up language (GML) [foundation for the geo-web]. 2004</p>
1588<div class="footnotes">
1589<br><hr width="100" align="left">
1590<div id="FSM" class="footnote"><p><sup class="fn-label"><a href="#FSM-ref" class="footnoteref">[1]</a></sup> Herein FSM applications are considered software systems whose
1591            behaviour is defined by the inputs, current state and the events associated with
1592              transitions of states.</p></div>
1593<div id="idp674224" class="footnote"><p><sup class="fn-label"><a href="#idp674224-ref" class="footnoteref">[2]</a></sup> Markup Density: the ratio of markup bytes used to define the structure
1594             of the document vs. its file size.</p></div>
1597<div id="balisage-footer"><h3 style="font-family: serif; margin:0.25em; font-style: italic">Balisage Series on Markup Technologies</h3></div>
1601<div id="balisage-footer"><h3 style="font-family: serif; margin:0.25em">
1602<i>Balisage:</i> <small>The Markup Conference</small>
Note: See TracBrowser for help on using the repository browser.