Comments (3)
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.
@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.
Implemented in #280.
from go-jsonnet.
Related Issues (20)
- jsonnet-lint missing std.objectKeysValues HOT 1
- parseYaml panics when passed empty string
- gazelle naming convention changes
- Decimal number displayed differently
- Need help building the c-bindings
- jsonnetfmt cli tool could support a canonical mode
- [Question] Parser package, children function
- std.splitLimitR is missing from go-jsonnet
- Support for stdlib context (cancellation / timeouts)
- Concurrency safe `FileImporter` HOT 6
- Interest for import toml ? HOT 1
- Buggy field visibility handling in`objectHas` in Go impl
- escapeStringXml vs escapeStringXML
- `--jpath` does not support multiple search paths HOT 4
- std.parseYaml wraps result in an array when string values contain HOT 3
- Question: Any chance a more recent stdlib could be pulled in? HOT 1
- Is it possible to define a native function with a default argument?
- INTERNAL ERROR: (CRASH) interface conversion: interface {} is int, not float64 HOT 1
- Error when using custom functions with `int` parameters or return types HOT 1
- Requests: Tool to statically expand import/importstr expressions and consolidate Jsonnet files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-jsonnet.