-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: random_page_cost and effective_io_concurrency
added rules to compute those params. Signed-off-by: Sebastian Webber <[email protected]>
- Loading branch information
1 parent
bcffadb
commit 83e4a83
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package rules | ||
|
||
import ( | ||
"github.com/pgconfig/api/pkg/category" | ||
"github.com/pgconfig/api/pkg/config" | ||
) | ||
|
||
func computeStorage(in *config.Input, cfg *category.ExportCfg) (*category.ExportCfg, error) { | ||
|
||
switch in.DiskType { | ||
case "SSD": | ||
cfg.Storage.EffectiveIOConcurrency = 200 | ||
case "SAN": | ||
cfg.Storage.EffectiveIOConcurrency = 300 | ||
default: | ||
cfg.Storage.EffectiveIOConcurrency = 2 | ||
} | ||
|
||
if in.DiskType != "HDD" { | ||
cfg.Storage.RandomPageCost = 1.1 | ||
} | ||
|
||
return cfg, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package rules | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/pgconfig/api/pkg/category" | ||
) | ||
|
||
func Test_computeStorage(t *testing.T) { | ||
in := fakeInput() | ||
in.DiskType = "SSD" | ||
outSSD, _ := computeStorage(in, category.NewExportCfg(*in)) | ||
in.DiskType = "SAN" | ||
outSAN, _ := computeStorage(in, category.NewExportCfg(*in)) | ||
in.DiskType = "HDD" | ||
outHDD, _ := computeStorage(in, category.NewExportCfg(*in)) | ||
|
||
if outSSD.Storage.RandomPageCost > 1.1 || outSAN.Storage.RandomPageCost > 1.1 { | ||
t.Error("should use lower values for random_page_cost on both SSD and SAN") | ||
} | ||
|
||
if outSSD.Storage.EffectiveIOConcurrency < 200 || outSAN.Storage.EffectiveIOConcurrency < 300 { | ||
t.Error("should use higher values for effective_io_concurrency on both SSD and SAN") | ||
} | ||
|
||
if outHDD.Storage.EffectiveIOConcurrency > 2 { | ||
t.Error("should use lower values for effective_io_concurrency on HDD drives") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,4 +126,4 @@ categories: | |
elsif disk_type == "SSD": | ||
200 | ||
elsif disk_type == "SAN": | ||
200 | ||
300 |