aquaproj / aqua

Declarative CLI Version manager written in Go. Support Lazy Install, Registry, and continuous update with Renovate. CLI version is switched seamlessly
https://aquaproj.github.io
861 stars 39 forks source link

Convert standard registry from YAML to JSON when installing it #2517

Closed suzuki-shunsuke closed 11 months ago

suzuki-shunsuke commented 11 months ago

Feature Overview

Convert standard registry from YAML to JSON when installing it.

Why is the feature needed?

To improve the performance to read the standard registry. Stanard registry is a huge YAML file over 30,000 lines so it has a little overhead to read it. By converting YAML to JSON, we can decrease the overhead. And the registry maintainer don't need to convert YAML to JSON themselves because aqua converts it internally.

How to reproduce the issue

No response

Workaround

No response

Example Code

aqua converts registry.yaml to registry.yaml.json when aqua installs the registry. When aqua reads the registry, aqua tries to read registry.yaml.json first. If registry.yaml.json isn't found aqua looks for registry.yaml. If registry.yaml is found, aqua creates registry.yaml.json. If registry.yaml isn't found aqua installs it.

Reference

No response

suzuki-shunsuke commented 11 months ago

Benchmark

Convert registry.yaml to registry.yaml.json

yaml2json < registry.yaml > registry.yaml.json

https://github.com/sharkdp/hyperfine

$ hyperfine -N --warmup 3 'env AQUA_CONFIG=aqua.yaml jq --version' 'env AQUA_CONFIG=aqua-json.yaml jq --version'
Benchmark 1: env AQUA_CONFIG=aqua.yaml jq --version
  Time (mean ± σ):      99.0 ms ±   2.1 ms    [User: 33.1 ms, System: 5.5 ms]
  Range (min … max):    94.6 ms … 102.8 ms    30 runs

Benchmark 2: env AQUA_CONFIG=aqua-json.yaml jq --version
  Time (mean ± σ):      43.9 ms ±   6.7 ms    [User: 10.7 ms, System: 3.0 ms]
  Range (min … max):    41.0 ms …  92.2 ms    68 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Summary
  env AQUA_CONFIG=aqua-json.yaml jq --version ran
    2.25 ± 0.35 times faster than env AQUA_CONFIG=aqua.yaml jq --version

$ hyperfine -N --warmup 3 'env AQUA_CONFIG=aqua.yaml jq --version' 'env AQUA_CONFIG=aqua-json.yaml jq --version'
Benchmark 1: env AQUA_CONFIG=aqua.yaml jq --version
  Time (mean ± σ):      98.8 ms ±   2.9 ms    [User: 28.6 ms, System: 4.8 ms]
  Range (min … max):    94.9 ms … 108.2 ms    30 runs

Benchmark 2: env AQUA_CONFIG=aqua-json.yaml jq --version
  Time (mean ± σ):      42.4 ms ±   1.4 ms    [User: 11.0 ms, System: 2.9 ms]
  Range (min … max):    41.1 ms …  48.7 ms    69 runs

Summary
  env AQUA_CONFIG=aqua-json.yaml jq --version ran
    2.33 ± 0.10 times faster than env AQUA_CONFIG=aqua.yaml jq --version
suzuki-shunsuke commented 11 months ago