Skip to content

Execution performance ideas #111

Open
@sbarzowski

Description

@sbarzowski

First we need to have some benchmarking in place, and some reasonable "corpus" of jsonnet to test on. We can start by using current test suite, but dedicated benchmarks make more sense.

Once we have that, we can try to find bottlenecks and potentially optimize. Instead of having them scattered throughout the code, I'll dump some of these ideas here:

  • caching of object locals (they're desugared to locals in each field now)
  • caching of object fields (controversial and important, we need a discussion first)
  • memory usage of tail recursion
  • making sure that we don't keep objects for too long
  • generate unique numbers for variables statically and use that instead of names
  • faster implementation of std.join, uniq, setInter and other array building builtins
  • native implementation of std.sort, std.parseInt and other functions that the user may expect to be optimized
  • interning of booleans for faster comparisons (by using the pointer directly and never actually dereferencing) and lower memusage.
  • avoid desugaring operators, call builtins directly instead (fewer things to check, no need to do std lookup and verifying that it's actually a function etc.).
  • fast & easy way for users to build arrays- perhaps a more sophisticated representation of an array would help, so that + behaves reasonably and/or more native higher-order functions. This stuff often applies to strings, too.
  • faster indexing of objects with deep inheritance chains
  • reduce overhead of function call argument checking (currently we check for a lot of special cases, because of optional arguments and that requires building maps and multiple lookups for each argument - maybe it would help to skip these checks when there are only positional arguments)
  • check performance of environment capturing (and reuse the environment when possible)
  • interning of identifiers
  • try other representations of cachedThunk

Before we implement any of these we should have a benchmark that proves that it actually helps.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions