Open freedge opened 1 year ago
@freedge How did you capture the flamegraph, please? (I'm doing a little existing-issue hunt before I file a bug report about terraform 1.4.5 being ~2-3x slower than 1.3.7, and having some more data is always nice).
you need to build terraform with pprof with some modification
diff --git a/main.go b/main.go
index c807bb5a40..cc18baa0a2 100644
--- a/main.go
+++ b/main.go
@@ -25,6 +25,9 @@ import (
"github.com/mitchellh/colorstring"
backendInit "github.com/hashicorp/terraform/internal/backend/init"
+
+ "net/http"
+ _ "net/http/pprof"
)
const (
@@ -55,6 +58,10 @@ func init() {
}
func main() {
+ go func() {
+ log.Println(http.ListenAndServe("localhost:6059", nil))
+ }()
+
os.Exit(realMain())
}
Terraform Version
Terraform Configuration Files
Debug Output
Expected Behavior
the marshalling of the state, that takes 0.5s in my case, should be done once, before the lock is taken.
we experience performance degradation with a large tfstate.
Actual Behavior
marshalling of the state is done twice, and there is also an extra marshalling of the backup state, done with the lock taken, causing terraform apply to be super slow.
Steps to Reproduce
though the behavior of this case (json marshalling done 3 times with lock taken) should be common to all terraform apply.
Additional Context
during my tests in observe that in practice the state is always changed. Running with
makes the
terraform apply
completes in 2m15 instead of 5min30References
No response