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

runtime/race: 20x perf slowdown when program built with the race detector #22244

kevinburke opened this issue Oct 13, 2017 · 3 comments


Copy link

Terraform is a tool for provisioning clusters of servers. You define
configuration files in a configuration language called "hcl". Terraform parses
these files and applies updates to your servers based on the configuration.

Terraform also ships with a tool called "fmt", that works similarly to "go fmt".
You apply it to hcl files, it parses them and then writes the updated file to

I was interested that when you build terraform with the race detector enabled,
it runs about 20 times slower than with the race detector disabled.

0s kevin at warthog in ~/src/...
± (ads-3*) $ time ~/bin/terraform fmt dev/terraform.tfvars
~/bin/terraform fmt dev/terraform.tfvars  0.02s user 0.02s system 52% cpu 0.085 total

With the race detector enabled:

0s kevin at warthog in ~/src/...
± (ads-3*) $ time ~/bin/terraform fmt dev/terraform.tfvars
~/bin/terraform fmt dev/terraform.tfvars  0.09s user 0.07s system 7% cpu 2.164 total

This is the configuration file I'm trying to format:

# Terragrunt is a thin wrapper for Terraform that provides extra tools for working with multiple Terraform modules,
# remote state, and locking:
terragrunt = {
  # Configure Terragrunt to automatically store tfstate files in an S3 bucket
  remote_state {
    backend = "s3"
    config {
      encrypt = true
      bucket = "mybucket"
      key = "${path_relative_to_include()}/terraform.tfstate"
      region = "us-west-2"
      dynamodb_table = "dynamo-table"

I don't know if we have explicit performance benchmarks for running code with
the race detector enabled, but a 20x slowdown on a popular-ish program seems

I've been enabling the race detector on more Go programs now in the hopes of
catching more errors and stressing programs but maybe it's not appropriate in
all situations.

I'm using the latest version of terraform (hashicorp/terraform@5fb1fe9) and the current Go tip.

Copy link

Copy link

Using the race detector for testing should always be appropriate.

Nobody is expected to use the race detector in production.

Copy link
Contributor Author

OK, closing, since a 20x slowdown is within the bounds of acceptable performance.

@golang golang locked and limited conversation to collaborators Oct 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

4 participants