forked from SUSE/saptune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.go
69 lines (60 loc) · 2.35 KB
/
db.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package note
import (
"github.com/SUSE/saptune/sap"
"github.com/SUSE/saptune/system"
"github.com/SUSE/saptune/txtparser"
)
// LinuxPagingImprovements defines SAP Note 1557506
// 1557506 - Linux paging improvements
type LinuxPagingImprovements struct {
PagingConfig string // configuration file for page cache, used by test cases and during optimise
VMPagecacheLimitMB uint64
VMPagecacheLimitIgnoreDirty int
UseAlgorithmForHANA bool
}
// Name returns the name of the related SAP Note
func (paging LinuxPagingImprovements) Name() string {
return "Linux paging improvements"
}
// Initialise reads the parameter values from current system
func (paging LinuxPagingImprovements) Initialise() (Note, error) {
vmPagecach, _ := system.GetSysctlUint64(system.SysctlPagecacheLimitMB)
vmIgnoreDirty, _ := system.GetSysctlInt(system.SysctlPagecacheLimitIgnoreDirty)
return LinuxPagingImprovements{
PagingConfig: paging.PagingConfig,
VMPagecacheLimitMB: vmPagecach,
VMPagecacheLimitIgnoreDirty: vmIgnoreDirty,
UseAlgorithmForHANA: true,
}, nil
}
// Optimise gets the expected pagecache values from the configuration
// or calculates new values
func (paging LinuxPagingImprovements) Optimise() (Note, error) {
newPaging := paging
conf, err := txtparser.ParseSysconfigFile(newPaging.PagingConfig, false)
if err != nil {
return nil, err
}
inputEnable := conf.GetBool("ENABLE_PAGECACHE_LIMIT", false)
inputOverride := conf.GetInt("OVERRIDE_PAGECACHE_LIMIT_MB", 0)
// As discussed with SAP and Alliance team, use the HANA formula for
// Netweaver too.
// So for HANA and Netweaver: new limit is 2% system memory
newPaging.VMPagecacheLimitMB = system.GetMainMemSizeMB() * 2 / 100
if inputOverride != 0 {
newPaging.VMPagecacheLimitMB = uint64(inputOverride)
}
if !inputEnable {
newPaging.VMPagecacheLimitMB = 0
}
newPaging.VMPagecacheLimitIgnoreDirty = conf.GetInt(system.SysctlPagecacheLimitIgnoreDirty, 1)
return newPaging, err
}
// Apply sets the new values in the system
func (paging LinuxPagingImprovements) Apply() error {
errs := make([]error, 0, 0)
errs = append(errs, system.SetSysctlUint64(system.SysctlPagecacheLimitMB, paging.VMPagecacheLimitMB))
errs = append(errs, system.SetSysctlInt(system.SysctlPagecacheLimitIgnoreDirty, paging.VMPagecacheLimitIgnoreDirty))
err := sap.PrintErrors(errs)
return err
}