[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How efficient are XML parsers?

  • From: Michael Kay <mike@saxonica.com>
  • To: "Costello, Roger L." <costello@mitre.org>
  • Date: Wed, 15 Nov 2017 12:59:59 +0000

Re:  How efficient are XML parsers?
A classic example of how you can nearly always improve performance by sacrificing something else, e.g. simplicity, or conformance to standards, or potential for change, or ease of writing an application to produce or consume the data.

Just don't do it unless (a) you know you need the extra performance, and (b) you know what you're sacrificing to get it.

Michael Kay

On 15 Nov 2017, at 12:07, Costello, Roger L. <costello@mitre.org> wrote:

Hi Folks,


I recently read an article about Facebook dumping JSON due to inadequate performance of JSON parsers. See below. I wonder how XML parsers would stack up. Do you have numbers?


Parse a 20KB stream

Facebook requirement: must not exceed the UI frame refresh interval of 16.6 ms

JSON parser: 35 ms to parse a JSON stream of 20 KB (a typical response size for Facebook)

XML parser: ??


Parser initialization

Facebook requirement: Not specified

JSON parser: 100 ms to 200 ms before it can start parsing

XML parser: ??


Garbage collection

Facebook requirement: Not specified

JSON parser: 100 KB of transient memory allocated when parsing a JSON stream of 20 KB

XML parser: ??


Here’s why Facebook dumped JSON

As you know, people use Facebook to create connections with family and friends. Facebook stores all the data that makes up the social graph of these connections. On mobile clients, the entire graph can’t be downloaded, so only a node and some of its connections are downloaded as a local tree structure.

One of the key issues Facebook needed to address was how to represent and store the social graph data in an app. Their initial approach was to store the data in JSON. They used the Jackson JSON parser on Android. However, they dumped JSON after finding these issues:

Parsing speed. It took 35 ms to parse a JSON stream of 20 KB (a typical response size for Facebook), which exceeds the UI frame refresh interval of 16.6 ms. Users were unable to load stories on demand from disk cache without observing frame drops (visual stutters) while scrolling.

Parser initialization. A JSON parser needs to build a field mapping before it can start parsing, which can take 100 ms to 200 ms, substantially slowing down the application start time.

Garbage collection. A lot of small objects are created during JSON parsing, and testing revealed around 100 KB of transient memory was allocated when parsing a JSON stream of 20 KB, which placed significant pressure on the garbage collector.

Facebook needed a better storage format to increase the performance of their Android app.

What did they choose?

Answer: Google FlatBuffers.




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.