Skip to content

std.format is slow #464

Open
Open
@buremba

Description

@buremba

We're heavily using string concentration via std.format and I realized that it dramatically hurts the performance. We had to switch using the old way '' + '' and had a huge performance boost. Here is an example:

["%s and %s" % ['test', 'test1'] for x in std.range(0, 1000)]

The script above is compiled in ~5000ms whereas the following one only takes around 50ms:

local test = 'test';
local test1 = 'test1';

[test + 'and' + test1 for x in std.range(0, 1000)]

I see that std.format is implemented in Jsonnet but I believe it might be best to implement it as a native function as the logic is complex and it affects the performance dramatically.

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