-
Notifications
You must be signed in to change notification settings - Fork 712
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
Re-implement LatestMap as a sorted slice for better performance #2870
Conversation
both the Python generator and the Go generated code are checked in
report/latest_map_generated.go
Outdated
} | ||
for ; j < len(n.entries); j++ { | ||
out = append(out, n.entries[j]) | ||
} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
iirc rendering is quite heavy on LatestMap lookups. I'd like to see some comparative results for pumping real reports through various stages of processing. I might have a go at that myself, since I did quite a lot of that in the past using
and then timing something like
extras/copyreport is also handy for benchmarking. |
This PR makes no difference to rendering performance. Which I suppose is a good thing. I grabbed a current Weave Cloud production report from the UI and ran
and then
I repeated this for a few other topology types, taking care to restart scope every time since otherwise rendering hits the internal gcache.
where old=master and new=this-branch. |
I don't see much difference when copying a report, perhaps because it's dominated by writing:
old=2.6s, new=2.5s I then applied index 434edcd8..5bc5b135 100644
--- a/app/collector.go
+++ b/app/collector.go
@@ -248,6 +248,7 @@ func NewFileCollector(path string, window time.Duration) (Collector, error) {
timestamps []time.Time
reports []report.Report
)
+ start := time.Now()
allTimestamped := true
if err := filepath.Walk(path,
func(p string, info os.FileInfo, err error) error {
@@ -272,12 +273,12 @@ func NewFileCollector(path string, window time.Duration) (Collector, error) {
}); err != nil {
return nil, err
}
- if len(reports) > 1 && allTimestamped {
- collector := NewCollector(window)
- go replay(collector, timestamps, reports)
- return collector, nil
- }
- return StaticCollector(NewSmartMerger().Merge(reports).Upgrade()), nil
+ fmt.Println("read in", time.Since(start))
+ m := NewSmartMerger()
+ start = time.Now()
+ r := m.Merge(reports)
+ fmt.Println("merged in", time.Since(start))
+ return StaticCollector(r.Upgrade()), nil
}
func timestampFromFilepath(path string) (time.Time, error) { and ran
where the specified directory contains 30s worth of Weave Cloud prod reports from a few months ago, in msgpack.gz format. I did five runs and averaged the results:
So that's a reasonable improvement in read performance and a significant improvement in merge performance. Let's get this PR merged! |
I can recommend the Go benchmark support for this kind of experiment - you call |
Part of fixing #2866
Benchmarks
Before
After