Skip to content

(name subject to change, thanks github suggestions) Stupidly fast json parsing in Java

Notifications You must be signed in to change notification settings

niloc132/drunken-wallhack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Premature optimization of the week - take the GWT AutoBean splittable interface and teach it how to read JSON from a ByteBuffer. Parses the structure of the JSON in a single pass, so you can access a few properties and move on.

Not designed (or tested) to be a great way to read every property, but instead optimizing expressly for the minute use case of sparse reading.

Tests run in one jvm with 10 seconds (should be much more than required) of warmup against GSON with a few included sample files. On a 2.4ghz i7 mbp, with the 190mb json file at https://github.com/zeMirco/sf-city-lots-json, GSON sits at all cores pegged for 10-12 seconds, this Splittable does it in about 1.1s, and for about a quarter of the heap churn. Included sample files (thanks http://www.json-generator.com/) show a much closer race, with Splittable only winning by 10-20%.

Downsides (oh yes):

  • incomplete
  • can't traverse structure
  • asking for properties that don't exist? that's an exception.
  • readonly (at present)
  • second commit in this tree is another 15% faster, but doesn't track as nice of offsets
  • strings are left as-is, no escaping is implemented
  • not tested with actual AutoBeans
  • might have problems with any object, array longer than 250mb...
  • generated name on github, unimaginative name in pom.xml

Upsides:

The code:

The tests:

About

(name subject to change, thanks github suggestions) Stupidly fast json parsing in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages