[llvm-commits] [PATCH] YAML parser.

Michael Spencer bigcheesegs at gmail.com
Mon Jan 30 12:08:27 PST 2012


Attached is the patch for the YAML parser I've been working on. YAML
is a super set of JSON that adds many features that I want for writing
tests for lld (the llvm linker) and other places where we use object
files.

The API is very similar to the existing JSON API, but is not exactly
the same as YAML has an extended data model.

This parser is slower than the currently existing JSON parser. For
files with large scalars, there is almost no difference. For medium
scalars, there's a ~2x slowdown. And for small scalars, there's a ~6x
slowdown.

Here are some performance numbers for {yaml,json}-bench -memory-limit
100 (a 32bit build can't do much more than that :P). Note that for
YAML. The Parsing time includes the Tokenizing time.

c:\Users\mspencer\Projects\llvm-project\llvm>yaml-bench -memory-limit 100
===-------------------------------------------------------------------------===
                             YAML parser benchmark
===-------------------------------------------------------------------------===
  Total Execution Time: 5.2104 seconds (5.2185 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall
Time---  --- Name ---
   2.8392 ( 56.3%)   0.1716 (100.0%)   3.0108 ( 57.8%)   3.0118 (
57.7%)  Small Values: Parsing
   2.1216 ( 42.1%)   0.0000 (  0.0%)   2.1216 ( 40.7%)   2.1257 (
40.7%)  Small Values: Tokenizing
   0.0780 (  1.5%)   0.0000 (  0.0%)   0.0780 (  1.5%)   0.0810 (
1.6%)  Small Values: Loop
   5.0388 (100.0%)   0.1716 (100.0%)   5.2104 (100.0%)   5.2185 (100.0%)  Total

===-------------------------------------------------------------------------===
                             YAML parser benchmark
===-------------------------------------------------------------------------===
  Total Execution Time: 0.4836 seconds (0.4740 wall clock)

   ---User Time---   --User+System--   ---Wall Time---  --- Name ---
   0.2184 ( 45.2%)   0.2184 ( 45.2%)   0.2200 ( 46.4%)  Medium Values: Parsing
   0.1716 ( 35.5%)   0.1716 ( 35.5%)   0.1710 ( 36.1%)  Medium Values:
Tokenizing
   0.0936 ( 19.4%)   0.0936 ( 19.4%)   0.0830 ( 17.5%)  Medium Values: Loop
   0.4836 (100.0%)   0.4836 (100.0%)   0.4740 (100.0%)  Total

===-------------------------------------------------------------------------===
                             YAML parser benchmark
===-------------------------------------------------------------------------===
  Total Execution Time: 0.2496 seconds (0.2480 wall clock)

   ---User Time---   --User+System--   ---Wall Time---  --- Name ---
   0.0780 ( 31.3%)   0.0780 ( 31.3%)   0.0830 ( 33.5%)  Large Values: Parsing
   0.0936 ( 37.5%)   0.0936 ( 37.5%)   0.0830 ( 33.5%)  Large Values: Tokenizing
   0.0780 ( 31.3%)   0.0780 ( 31.3%)   0.0820 ( 33.1%)  Large Values: Loop
   0.2496 (100.0%)   0.2496 (100.0%)   0.2480 (100.0%)  Total

c:\Users\mspencer\Projects\llvm-project\llvm>json-bench -memory-limit 100
===-------------------------------------------------------------------------===
                             JSON parser benchmark
===-------------------------------------------------------------------------===
  Total Execution Time: 0.6552 seconds (0.6531 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall
Time---  --- Name ---
   0.5460 ( 87.5%)   0.0312 (100.0%)   0.5772 ( 88.1%)   0.5721 (
87.6%)  Small Values: Parsing
   0.0780 ( 12.5%)   0.0000 (  0.0%)   0.0780 ( 11.9%)   0.0810 (
12.4%)  Small Values: Loop
   0.6240 (100.0%)   0.0312 (100.0%)   0.6552 (100.0%)   0.6531 (100.0%)  Total

===-------------------------------------------------------------------------===
                             JSON parser benchmark
===-------------------------------------------------------------------------===
  Total Execution Time: 0.1872 seconds (0.1830 wall clock)

   ---User Time---   --User+System--   ---Wall Time---  --- Name ---
   0.1092 ( 58.3%)   0.1092 ( 58.3%)   0.1030 ( 56.3%)  Medium Values: Parsing
   0.0780 ( 41.7%)   0.0780 ( 41.7%)   0.0800 ( 43.7%)  Medium Values: Loop
   0.1872 (100.0%)   0.1872 (100.0%)   0.1830 (100.0%)  Total

===-------------------------------------------------------------------------===
                             JSON parser benchmark
===-------------------------------------------------------------------------===
  Total Execution Time: 0.1716 seconds (0.1620 wall clock)

   ---User Time---   --User+System--   ---Wall Time---  --- Name ---
   0.0780 ( 45.5%)   0.0780 ( 45.5%)   0.0810 ( 50.0%)  Large Values: Parsing
   0.0936 ( 54.5%)   0.0936 ( 54.5%)   0.0810 ( 50.0%)  Large Values: Loop
   0.1716 (100.0%)   0.1716 (100.0%)   0.1620 (100.0%)  Total


- Michael Spencer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yaml-parser.patch
Type: application/octet-stream
Size: 150895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120130/48c6e717/attachment.obj>


More information about the llvm-commits mailing list