Skip to content

Commit

Permalink
fix: random_page_cost and effective_io_concurrency
Browse files Browse the repository at this point in the history
added rules to compute those params.

Signed-off-by: Sebastian Webber <[email protected]>
  • Loading branch information
sebastianwebber committed Feb 17, 2021
1 parent bcffadb commit 83e4a83
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/rules/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var allRules = []rule{
computeArch,
computeOS,
computeProfile,
computeStorage,

// computeVersion can remove values deppending on the version
// to be sure that it will not break other rules, leave it at
Expand Down
24 changes: 24 additions & 0 deletions pkg/rules/storage.go
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
}
29 changes: 29 additions & 0 deletions pkg/rules/storage_test.go
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")
}
}
2 changes: 1 addition & 1 deletion rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ categories:
elsif disk_type == "SSD":
200
elsif disk_type == "SAN":
200
300

0 comments on commit 83e4a83

Please sign in to comment.