-
Notifications
You must be signed in to change notification settings - Fork 13
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
CalendarSync has quite a large memory footprint #180
Comments
I did a bit of memory profiling. The memory usage peak is probably mostly caused by
The higher memory usage with the non-release builds is probably caused by #195 . Bluemonday doesn't use particularly much memory. And as the transformers are called sequentially, this allows go to run GC during the transformations if necessary. #197 should reduce the peak memory usage by running a GC after the storage decryption is completed. That should at least limit the memory peak to around 300MB. |
Btw, I've used the following patch for memory profiling (run diff --git a/cmd/calendarsync/main.go b/cmd/calendarsync/main.go
index 3cb4ac6..de2b3cc 100644
--- a/cmd/calendarsync/main.go
+++ b/cmd/calendarsync/main.go
@@ -10,6 +10,7 @@ import (
"github.com/inovex/CalendarSync/internal/models"
"github.com/charmbracelet/log"
+ "github.com/pkg/profile"
"github.com/urfave/cli/v2"
"github.com/inovex/CalendarSync/internal/adapter"
@@ -103,6 +104,8 @@ func main() {
}
func Run(c *cli.Context) error {
+ defer profile.Start(profile.MemProfile, profile.MemProfileRate(1)).Stop()
+
if c.Bool(flagVersion) {
fmt.Println("Version:", Version)
os.Exit(0)
@@ -211,5 +214,8 @@ func Run(c *cli.Context) error {
log.Fatalf("we had some errors during synchronization:\n%v", err)
}
}
+
+ // this looks weird, but without it the profile was incomplete
+ runtime.GC()
+ time.Sleep(1 * time.Second)
return nil
} |
I looked a little closer at the output of systemd and noticed the large amount of memory CalendarSync apparently uses:
It is fluctuating around 300 to < 600MB with the current 0.10.0 release.
During validation of #177 I noticed an even bigger memory footprint, especially for the first run:
CalendarSync.service: Consumed 10.940s CPU time, 1.5G memory peak.
But later runs appear to be using more memory than before: destination):
CalendarSync.service: Consumed 3.885s CPU time, 954.7M memory peak.
This is without any changes to the source (or updates being pushed to the sink).
Maybe the cause therefore lies somewhere in the use of the https://github.com/microcosm-cc/bluemonday sanitizer?
There was a change allowing bluemonday to stream its output to a writer directly: microcosm-cc/bluemonday#110. Maybe that would help some?
Let me now if you want me to run some pprof or to provide any other debug info.
^^ @alxndr13 FYI
The text was updated successfully, but these errors were encountered: