Coder Social home page Coder Social logo

JSON.parse performance about argo HOT 13 CLOSED

thoughtbot avatar thoughtbot commented on June 4, 2024
JSON.parse performance

from argo.

Comments (13)

tonyd256 avatar tonyd256 commented on June 4, 2024

This is cool, thanks for doing it! This looks like the master branch right?

from argo.

piercifani avatar piercifani commented on June 4, 2024

Yep, Argo v0.4.2 from CocoaPods. I just saw that you pushed 0.4.3, do you want me to re-run the tests again?

from argo.

tonyd256 avatar tonyd256 commented on June 4, 2024

We did some testing. Using a 85KB JSON file we made we are seeing ~160ms to run JSON.parse. Messing around a bit we discovered some optimizations that can bring this down to ~130ms. We will make this changes for sure.

That being said, we are running our tests under the Release scheme which is configured for a Optimization level of Fastest [-O]. When I changed that to None [-Onone] we saw a large increase in execution time. ~360ms with the code as is on master and ~177ms with the optimizations we found. If you are running this in Instruments do you think it's being build to the debug scheme and therfore has an Optimization level of None [-Onone]? I'm curious to see if your tests are running with Fastest [-O] and if not, what times are you seeing if you make that change.

from argo.

tonyd256 avatar tonyd256 commented on June 4, 2024

Also, to answer your question, 0.4.3 should not make a difference in execution time of that function.

from argo.

piercifani avatar piercifani commented on June 4, 2024

The results I mentioned are with the DEBUG scheme. However, I also tried running it on my phone under the Release scheme and all compiler optimizations turned in, and it did bring it down from 620ms to 450ms or around there. It's still way higher than what it should be, but I can't seem to figure out what the bottleneck is...

from argo.

tonyd256 avatar tonyd256 commented on June 4, 2024

That's good to know that the Release scheme is helping a bit. We have an optimization that should cut that down even more and we'll push it next week. The big problem here is the lack of native support around combining dictionaries. Because of this, the compiler isn't optimizing much for us. I think future improvements to Swift will help with this. Also, you might want to look at cutting down the size of the JSON response as large responses like this can take a noticeable amount of time to download in slow network areas.

from argo.

piercifani avatar piercifani commented on June 4, 2024

Yes, trimming down the JSON size is one of our main objectives right now. But my goal opening this issue was pointing out the huge performance difference between Argo and competing solutions. I'd gladly pay a 2x performance hit if I get all the huge benefits I get by using Argo, but 10x it's hard to justify to my teammates.

Let's hope that next week's release with your improvements will help performance and further Swift enhancements will give us better tools to build faster code.

All the best!

from argo.

tonyd256 avatar tonyd256 commented on June 4, 2024

@piercifani ... #88 addresses this issue. If you can try that out and let me know how it goes that would be great.

from argo.

piercifani avatar piercifani commented on June 4, 2024

I couldn't install the td-faster branch using CocoaPods since it looks like there are some dependencies that are not specified in the Podspec yet.

However, I was able to copy-paste the new JSON.parse implementation into my project and try it out.

These are the results on the Simulator:

Build Config Branch Time to parse
Debug master 0.195s
Debug td-faster 0.192s
Release master 0.183s
Release td-faster 0.092s

So there is a big improvement on the Release build, awesome!

from argo.

piercifani avatar piercifani commented on June 4, 2024

However, when testing on a device, I get a nasty EXC_BAD_ACCESS while parsing if I build with Release, weirdest crash ever....

from argo.

tonyd256 avatar tonyd256 commented on June 4, 2024

A lot of what's on master is for Swift 1.2 beta3 ... if you're using it in Swift 1.1 or even an earlier beta then crashes are very possible. Anyways, that's great that the speed improved. I'll close this issue when the PR is merged and we'll continue to seek better performance with newer versions of Swift.

from argo.

piercifani avatar piercifani commented on June 4, 2024

No, that can't be it, I'm building with latest Xcode beta, with latest Swift version:

pcifani$ swift -v
Apple Swift version 1.2 (swiftlang-602.0.44.6 clang-602.0.45)
Target: x86_64-apple-darwin14.1.0

However, awesome, please close as soon as you merge the new code, as it looks like these issues are resolved.

from argo.

tonyd256 avatar tonyd256 commented on June 4, 2024

The PR code is now on master.

from argo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.