Skip to content

Commit 2ebaade

Browse files
committed
Added support for memory ballast
1 parent 6529095 commit 2ebaade

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ This is recommended for dev environments only.
9797
* `ENABLE_EVENT_TRACING`: Enables event trace logging. Splunk events will now contain a UUID, Splunk Nozzle Event Counts, and a Subscription-ID for Splunk correlation searches. (Default: false)
9898
* `STATUS_MONITOR_INTERVAL`: Time interval (in s/m/h. For example, 3600s or 60m or 1h) for monitoring memory queue pressure. Use to help with back-pressure insights. (Increases CPU load. Use for insights purposes only) Default is 0s (Disabled).
9999
* `DROP_WARN_THRESHOLD`: Threshold for the count of dropped events in case the downstream is slow. Based on the threshold, the errors will be logged.
100+
* `MEMORY_BALLAST_SIZE`: Size of memory allocated to reduce GC cycles. Default is 0, Size should be less than the total memory.
100101

101102
__About app cache params:__
102103

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ func main() {
2727
signal.Notify(shutdownChan, syscall.SIGINT, syscall.SIGTERM)
2828

2929
config := splunknozzle.NewConfigFromCmdFlags(version, branch, commit, buildos)
30+
if config.MemoryBallastSize > 0 {
31+
ballast := make([]byte, config.MemoryBallastSize<<20)
32+
_ = ballast
33+
}
34+
3035
if config.AppCacheTTL == 0 && config.OrgSpaceCacheTTL > 0 {
3136
logger.Info("Apps are not being cached. When apps are not cached, the org and space caching TTL is ineffective")
3237
}

splunknozzle/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type Config struct {
5656
Debug bool `json:"debug"`
5757
StatusMonitorInterval time.Duration `json:"mem-queue-monitor-interval"`
5858
DropWarnThreshold int `json:"drop-warn-threshold"`
59+
MemoryBallastSize int `json:"memory-ballast-size"`
5960
}
6061

6162
func NewConfigFromCmdFlags(version, branch, commit, buildos string) *Config {
@@ -138,6 +139,8 @@ func NewConfigFromCmdFlags(version, branch, commit, buildos string) *Config {
138139
OverrideDefaultFromEnvar("STATUS_MONITOR_INTERVAL").Default("0s").DurationVar(&c.StatusMonitorInterval)
139140
kingpin.Flag("drop-warn-threshold", "Log error with dropped events count at each threshold count due to slow downstream").
140141
OverrideDefaultFromEnvar("DROP_WARN_THRESHOLD").Default("1000").IntVar(&c.DropWarnThreshold)
142+
kingpin.Flag("memory-ballast-size", "Size of ballast in MB").
143+
OverrideDefaultFromEnvar("MEMORY_BALLAST_SIZE").Default("0").IntVar(&c.MemoryBallastSize)
141144

142145
kingpin.Parse()
143146
c.ApiEndpoint = strings.TrimSpace(c.ApiEndpoint)

splunknozzle/config_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var _ = Describe("Config", func() {
6464
os.Setenv("ENABLE_EVENT_TRACING", "true")
6565
os.Setenv("DEBUG", "true")
6666
os.Setenv("DROP_WARN_THRESHOLD", "100")
67+
os.Setenv("MEMORY_BALLAST_SIZE", "512")
6768

6869
c := NewConfigFromCmdFlags(version, branch, commit, buildos)
6970

@@ -110,6 +111,7 @@ var _ = Describe("Config", func() {
110111
Expect(c.TraceLogging).To(BeTrue())
111112
Expect(c.Debug).To(BeTrue())
112113
Expect(c.DropWarnThreshold).To(Equal(100))
114+
Expect(c.MemoryBallastSize).To(Equal(512))
113115
})
114116

115117
It("check defaults", func() {
@@ -142,6 +144,7 @@ var _ = Describe("Config", func() {
142144
Expect(c.TraceLogging).To(BeFalse())
143145
Expect(c.Debug).To(BeFalse())
144146
Expect(c.DropWarnThreshold).To(Equal(1000))
147+
Expect(c.MemoryBallastSize).To(Equal(0))
145148
})
146149
})
147150

@@ -188,6 +191,7 @@ var _ = Describe("Config", func() {
188191
"--enable-event-tracing",
189192
"--debug",
190193
"--drop-warn-threshold=10",
194+
"--memory-ballast-size=512",
191195
}
192196
os.Args = args
193197
})
@@ -232,6 +236,7 @@ var _ = Describe("Config", func() {
232236
Expect(c.Debug).To(BeTrue())
233237
Expect(c.TraceLogging).To(BeTrue())
234238
Expect(c.DropWarnThreshold).To(Equal(10))
239+
Expect(c.MemoryBallastSize).To(Equal(512))
235240

236241
Expect(c.Version).To(Equal(version))
237242
Expect(c.Branch).To(Equal(branch))

tile/tile.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ forms:
199199
label: Drop Warn Threshold
200200
default: 1000
201201
description: Log error with dropped events count at each threshold count due to slow downstream
202+
- name: memory_ballast_size
203+
type: integer
204+
label: Memory Ballast Size
205+
default: 0
206+
description: Size of memory allocated to reduce GC cycles. Default is 0, Size should be less than the total memory.
202207

203208
migration: |
204209
if (typeof properties['properties']['.properties.add_app_info']['value'] == "boolean") {

0 commit comments

Comments
 (0)