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

eskipfile: optimize Watch.LoadUpdates #3448

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AlexanderYastrebov
Copy link
Member

@AlexanderYastrebov AlexanderYastrebov commented Mar 21, 2025

Do not parse routes if file content did not change since last successful read.

Note that after #2304 RemoteWatch does not update file if response Etag did not change but underlying Watch would still parse routes.

goos: linux
goarch: amd64
pkg: github.com/zalando/skipper/eskipfile
cpu: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
                  │     HEAD~1     │                 HEAD                 │
                  │     sec/op     │    sec/op     vs base                │
WatchLoadUpdate-8   17889.7µ ± 24%   220.0µ ± 24%  -98.77% (p=0.000 n=10)

                  │    HEAD~1     │                 HEAD                 │
                  │     B/op      │     B/op      vs base                │
WatchLoadUpdate-8   7837.4Ki ± 0%   528.5Ki ± 0%  -93.26% (p=0.000 n=10)

                  │     HEAD~1      │                HEAD                │
                  │    allocs/op    │ allocs/op   vs base                │
WatchLoadUpdate-8   110110.000 ± 0%   6.000 ± 0%  -99.99% (p=0.000 n=10)

@AlexanderYastrebov AlexanderYastrebov force-pushed the eskipfile/benchmark-watch-load-update branch 2 times, most recently from ac1126a to 69b94cc Compare March 21, 2025 13:24
@AlexanderYastrebov AlexanderYastrebov added the minor no risk changes, for example new filters label Mar 21, 2025
@AlexanderYastrebov AlexanderYastrebov force-pushed the eskipfile/benchmark-watch-load-update branch from 69b94cc to c308d19 Compare March 21, 2025 13:27
@MustafaSaber
Copy link
Member

👍

quit chan struct{}
once sync.Once
fileName string
lastContent []byte
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should better store the sha256 value and compare that one to detect a change, because it is really fast and doesn't require to duplicate the memory of routes as byte slice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Its fast but not computing it is even faster :)
Do we care about memory consumed by eskip given that we parse and keep routes for lookup anyways?

Copy link
Member

Choose a reason for hiding this comment

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

I think we can move forward with this, given that the concern with large eskipfiles is more about network not memory, and we can update later if we need.

Signed-off-by: Alexander Yastrebov <[email protected]>
Do not parse routes if file content did not change since last successful read.

Note that after #2304 RemoteWatch does not update file if response Etag did not
change but underlying Watch would still parse routes.

```
goos: linux
goarch: amd64
pkg: github.com/zalando/skipper/eskipfile
cpu: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
                  │     HEAD~1     │                 HEAD                 │
                  │     sec/op     │    sec/op     vs base                │
WatchLoadUpdate-8   17889.7µ ± 24%   220.0µ ± 24%  -98.77% (p=0.000 n=10)

                  │    HEAD~1     │                 HEAD                 │
                  │     B/op      │     B/op      vs base                │
WatchLoadUpdate-8   7837.4Ki ± 0%   528.5Ki ± 0%  -93.26% (p=0.000 n=10)

                  │     HEAD~1      │                HEAD                │
                  │    allocs/op    │ allocs/op   vs base                │
WatchLoadUpdate-8   110110.000 ± 0%   6.000 ± 0%  -99.99% (p=0.000 n=10)
```

Signed-off-by: Alexander Yastrebov <[email protected]>
@AlexanderYastrebov AlexanderYastrebov force-pushed the eskipfile/benchmark-watch-load-update branch from c308d19 to f78437d Compare March 31, 2025 07:51
@MustafaSaber
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor no risk changes, for example new filters performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants