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

What is "large" versus "huge"? Here's the answer ....

  • From: Roger L Costello <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Fri, 25 Mar 2022 11:15:27 +0000

What is "large" versus "huge"? Here's the answer ....
Hi Folks,

Here's the number that separates large from huge:

	8K

Allow me to explain.

An XML lexer breaks up into tokens the stream of characters comprising an XML document. For example, this stream of characters that we recognize as an XML document:

<Document>Hello, world</Document>

might be broken up into these tokens:

'<'
Document
'>'
Hello, world
'</'
Document
'>'

All of those tokens are very short. But there are some XML documents with very long tokens.

How long should your tokens be? What are large tokens? What are huge tokens?

Practically speaking, if an XML element contains a string, how long should you allow the string to be?

The answer is 8K. 

Tokens less than 8K are large. They are of acceptable length and won't incur performance penalties in the lexer. 

Tokens greater than 8K are huge. They will incur performance penalties in the lexer. 

Don't create XML documents with elements containing strings longer than 8K.

"Flex" is a tool that auto-generates lexers. Page 49 of the Flex manual [1] says this:

Another final note regarding performance: as mentioned in Chapter 7 [Matching],
page 14, dynamically resizing yytext to accommodate huge tokens is a slow process
because it presently requires that the (huge) token be rescanned from the beginning. Thus
if performance is vital, you should attempt to match "large" quantities of text but not
"huge" quantities, where the cutoff between the two is at about 8K characters per token.

There you have it, the numerical definition of "large" and "huge".

/Roger

[1] https://epaperpress.com/lexandyacc/download/flex.pdf


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


PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.