Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement some best practices, fix error in static_ips test & avoid excessive regex calls when line is not spruce line #382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adberger
Copy link

Hi there

I've made a few changes, the biggest one being the matchPattern function which should make spruce much faster especially when rendering larges files.

If you are open to a review (& possible merge), I ask you to do it thoroughly as I don't have much experience with Go.

Here is a benchmark comparsion from our tool, which uses spruce under the hood:

Before:

BenchmarkExecute-12            1        8906495459 ns/op        65408706864 B/op        679075642 allocs/op
PASS
ok      github.com/bedag/subst/subst/cmd        9.524s

After:

BenchmarkExecute-12            1        1447321000 ns/op        1864258368 B/op 20667868 allocs/op
PASS
ok      github.com/bedag/subst/subst/cmd        2.065s

Memory consumption went down from ~60GB to ~1GB, so much less garbage collection.

fix: error in static_ips test
fix: avoid excessive regex calls when line is not spruce line

Signed-off-by: Adrian Berger <[email protected]>
@adberger
Copy link
Author

adberger commented Nov 6, 2024

@geofffranks Do you consider reviewing & merging this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant