Git Product home page Git Product logo

Comments (5)

aschackmull avatar aschackmull commented on June 2, 2024

The worst case time complexity is much much worse than what you suggest. It's polynomial at least, but it includes lots of additional factors, and #nodes is most definitely included. Another factor is #fields + #capturedvariables (which factors in worse than linearly). And virtual dispatch edges also play a role.
But fortunately we aren't really hitting the worst case, as we do lots of optimisations to improve the common case (without being able to completely shed the worst-case from a theoretical perspective). In the good case, I'd expect the total complexity to be about #nodes. The number of sources and sinks definitely play a role as well, but the average time complexity is actually, much better than a simple linear scaling there, because we can share a lot of flow reachability calculation between a set of sources and a set of sinks.

from codeql.

aschackmull avatar aschackmull commented on June 2, 2024

If I were to reduce the worst-case complexity to depend on just a single variable n being the size of the code base, then the complexity would be O(n^k) where k is just about 25, as far as I could count.

from codeql.

odipar avatar odipar commented on June 2, 2024

So that means if your code size grows 10 times bigger, there will be 10^25 more work?
Indeed, the worse case complexity is much much worse than I thought.

from codeql.

aschackmull avatar aschackmull commented on June 2, 2024

So that means if your code size grows 10 times bigger, there will be 10^25 more work?

Potential work in the worst case, yes, that's right (caveat, 25 might not be exactly right - it's a rough estimate based on a quick count). But again, the average case never really hits the worst case, so the typical experience is more like O(n).

Indeed, the worse case complexity is much much worse than I thought

Yes.

from codeql.

aschackmull avatar aschackmull commented on June 2, 2024

Actually, there are some safeguards in place, which I think might keep the worst-case bounded at O(n^7) instead of O(n^25). But the theoretical complexity doesn't really matter much in practice anyway.

from codeql.

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.