You need to sign in or sign up before continuing.
feat: Cache glab env config to improve overall command performance
Created by: pgollangi
Cache glab env config which avoids loading env file from file system which in turn improves overall command performance
Description Have a map of env config on first load which will used for all subsequent environment searches.
Related Issue Closes #144 (closed)
Motivation and Context
How Has This Been Tested?
Benchmarks without cache (bench-before.txt
):
BenchmarkGetEnv-4 50974 23479 ns/op 816 B/op 6 allocs/op
BenchmarkGetEnv-4 51392 23192 ns/op 816 B/op 6 allocs/op
BenchmarkGetEnv-4 51847 24126 ns/op 816 B/op 6 allocs/op
BenchmarkGetEnv-4 51861 23541 ns/op 816 B/op 6 allocs/op
BenchmarkGetEnv-4 51854 23891 ns/op 816 B/op 6 allocs/op
Benchmarks with cache (bench-after.txt
):
BenchmarkGetEnv-4 92289234 12.4 ns/op 0 B/op 0 allocs/op
BenchmarkGetEnv-4 100000000 12.2 ns/op 0 B/op 0 allocs/op
BenchmarkGetEnv-4 85945108 12.7 ns/op 0 B/op 0 allocs/op
BenchmarkGetEnv-4 92740719 12.3 ns/op 0 B/op 0 allocs/op
BenchmarkGetEnv-4 92294202 12.5 ns/op 0 B/op 0 allocs/op
Overall improvement is almost 100%
:
$ benchstat bench-before.txt bench-after.txt
name old time/op new time/op delta
GetEnv-4 23.6µs ± 2% 0.0µs ± 2% -99.95% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
GetEnv-4 816B ± 0% 0B -100.00% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
GetEnv-4 6.00 ± 0% 0.00 -100.00% (p=0.008 n=5+5)
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
-
My code follows the code style of this project. -
My change requires a change to the documentation. -
I have updated the documentation accordingly. -
I have read the CONTRIBUTING document. -
I have added tests to cover my changes. -
All new and existing tests passed.