Giter VIP home page Giter VIP logo

Comments (3)

sbarzowski avatar sbarzowski commented on July 28, 2024

This is quadratic, because every reference to $.A evaluates std.range(1, 3000) again.

{
    A: std.range(1, 3000),
    B: std.makeArray(3000, function(x) $.A[x])
}

from go-jsonnet.

sbarzowski avatar sbarzowski commented on July 28, 2024

@sparkprime
Continuing discussion from: google/jsonnet#451

Requiring cacheing isn't a good idea because you can't control memory use anymore.

I really don't see how it could make the memory situation noticeably worse. In particular how is it different from keeping values captured in closures? Or even more similar: preparing a local just outside of object? It seems very natural to me that when I have an object I keep all the fields and all the stuff they reference.

There is a lot to gain from field caching.

  • I suspect some caching will result in massive speedup in existing real world code.
  • It will eliminate the need of hoisting expressions out of objects for performance. Refactoring will no longer have such a drastic effect on performance.
  • I think it's what people expect by default. It will eliminate a major footgun for newcomers.
  • In some cases it might even improve memory usage - you keep the field only once instead of 17 copies of it.
  • Helps a little with cyclic asserts: google/jsonnet#451

I ran a little experiment on code provided by @redbaron (aka @rossmohax). Object field caching reduced evaluation (not counting parsing, analysis etc.) time ~6x. It's 40% speedup if you count static stuff which is the new bottleneck.
(The measurements were performed with this fix applied #183)

from go-jsonnet.

sbarzowski avatar sbarzowski commented on July 28, 2024

Implemented in #280.

from go-jsonnet.

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.