Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use new Roast library for custom AST serialization #1001

Merged
merged 1 commit into from
Aug 21, 2024
Merged

Conversation

anderseknert
Copy link
Member

And the jsoniter library for any JSON handling.

This is quite a big win for linting performance:

➜ hyperfine --warmup 2 'regal_main lint bundle' 'regal_jsoniter lint bundle'
Benchmark 1: regal_main lint bundle
  Time (mean ± σ):      2.707 s ±  0.035 s    [User: 19.171 s, System: 0.636 s]
  Range (min … max):    2.662 s …  2.785 s    10 runs

Benchmark 2: regal_jsoniter lint bundle
  Time (mean ± σ):      2.185 s ±  0.019 s    [User: 14.932 s, System: 0.466 s]
  Range (min … max):    2.147 s …  2.207 s    10 runs

Summary
  regal_jsoniter lint bundle ran
    1.24 ± 0.02 times faster than regal_main lint bundle

But importantly, it doesn't make the AST harder to read or work with — quite the opposite actually!

See the Roast README for all the details:
https://github.com/anderseknert/roast

And the `jsoniter` library for any JSON handling.

This is quite a big win for linting performance:

```
➜ hyperfine --warmup 2 'regal_main lint bundle' 'regal_jsoniter lint bundle'
Benchmark 1: regal_main lint bundle
  Time (mean ± σ):      2.707 s ±  0.035 s    [User: 19.171 s, System: 0.636 s]
  Range (min … max):    2.662 s …  2.785 s    10 runs

Benchmark 2: regal_jsoniter lint bundle
  Time (mean ± σ):      2.185 s ±  0.019 s    [User: 14.932 s, System: 0.466 s]
  Range (min … max):    2.147 s …  2.207 s    10 runs

Summary
  regal_jsoniter lint bundle ran
    1.24 ± 0.02 times faster than regal_main lint bundle
```

But importantly, it doesn't make the AST harder to read or work with — quite
the opposite actually!

See the Roast README for all the details:
https://github.com/anderseknert/roast

Signed-off-by: Anders Eknert <anders@styra.com>
Copy link
Member

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It's a bit of a bummer that we can't measure the impact of jsoniter alone vs perf improvements from the AST change. 🤔

@anderseknert anderseknert merged commit f28ac7d into main Aug 21, 2024
3 checks passed
@anderseknert anderseknert deleted the roast branch August 21, 2024 08:14
@anderseknert
Copy link
Member Author

@srenatus yeah ... we'd have to use jsoniter in OPA for that too, or else all the marshalling of AST nodes will just pass through the encoding/json implementations. For the few places where we're serializing other things, like capabilities, the difference was negligible.

srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
And the `jsoniter` library for any JSON handling.

This is quite a big win for linting performance:

```
➜ hyperfine --warmup 2 'regal_main lint bundle' 'regal_jsoniter lint bundle'
Benchmark 1: regal_main lint bundle
  Time (mean ± σ):      2.707 s ±  0.035 s    [User: 19.171 s, System: 0.636 s]
  Range (min … max):    2.662 s …  2.785 s    10 runs

Benchmark 2: regal_jsoniter lint bundle
  Time (mean ± σ):      2.185 s ±  0.019 s    [User: 14.932 s, System: 0.466 s]
  Range (min … max):    2.147 s …  2.207 s    10 runs

Summary
  regal_jsoniter lint bundle ran
    1.24 ± 0.02 times faster than regal_main lint bundle
```

But importantly, it doesn't make the AST harder to read or work with — quite
the opposite actually!

See the Roast README for all the details:
https://github.com/anderseknert/roast

Signed-off-by: Anders Eknert <anders@styra.com>
charlieegan3 pushed a commit to charlieegan3/regal that referenced this pull request Jan 6, 2025
And the `jsoniter` library for any JSON handling.

This is quite a big win for linting performance:

```
➜ hyperfine --warmup 2 'regal_main lint bundle' 'regal_jsoniter lint bundle'
Benchmark 1: regal_main lint bundle
  Time (mean ± σ):      2.707 s ±  0.035 s    [User: 19.171 s, System: 0.636 s]
  Range (min … max):    2.662 s …  2.785 s    10 runs

Benchmark 2: regal_jsoniter lint bundle
  Time (mean ± σ):      2.185 s ±  0.019 s    [User: 14.932 s, System: 0.466 s]
  Range (min … max):    2.147 s …  2.207 s    10 runs

Summary
  regal_jsoniter lint bundle ran
    1.24 ± 0.02 times faster than regal_main lint bundle
```

But importantly, it doesn't make the AST harder to read or work with — quite
the opposite actually!

See the Roast README for all the details:
https://github.com/anderseknert/roast

Signed-off-by: Anders Eknert <anders@styra.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants