mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-02 19:15:26 +00:00
Remove MAX_NUMBER_OF_GOROUTINES
environment variable
This commit is contained in:
@@ -216,7 +216,6 @@ func startMemoryProfiler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func closeTimedoutTcpStreamChannels() {
|
func closeTimedoutTcpStreamChannels() {
|
||||||
maxNumberOfGoroutines = GetMaxNumberOfGoroutines()
|
|
||||||
TcpStreamChannelTimeoutMs := GetTcpChannelTimeoutMs()
|
TcpStreamChannelTimeoutMs := GetTcpChannelTimeoutMs()
|
||||||
for {
|
for {
|
||||||
_debug.FreeOSMemory()
|
_debug.FreeOSMemory()
|
||||||
|
@@ -13,11 +13,9 @@ const (
|
|||||||
MaxBufferedPagesTotalEnvVarName = "MAX_BUFFERED_PAGES_TOTAL"
|
MaxBufferedPagesTotalEnvVarName = "MAX_BUFFERED_PAGES_TOTAL"
|
||||||
MaxBufferedPagesPerConnectionEnvVarName = "MAX_BUFFERED_PAGES_PER_CONNECTION"
|
MaxBufferedPagesPerConnectionEnvVarName = "MAX_BUFFERED_PAGES_PER_CONNECTION"
|
||||||
TcpStreamChannelTimeoutMsEnvVarName = "TCP_STREAM_CHANNEL_TIMEOUT_MS"
|
TcpStreamChannelTimeoutMsEnvVarName = "TCP_STREAM_CHANNEL_TIMEOUT_MS"
|
||||||
MaxNumberOfGoroutinesEnvVarName = "MAX_NUMBER_OF_GOROUTINES"
|
|
||||||
MaxBufferedPagesTotalDefaultValue = 5000
|
MaxBufferedPagesTotalDefaultValue = 5000
|
||||||
MaxBufferedPagesPerConnectionDefaultValue = 5000
|
MaxBufferedPagesPerConnectionDefaultValue = 5000
|
||||||
TcpStreamChannelTimeoutMsDefaultValue = 5000
|
TcpStreamChannelTimeoutMsDefaultValue = 5000
|
||||||
MaxNumberOfGoroutinesDefaultValue = 4000
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type globalSettings struct {
|
type globalSettings struct {
|
||||||
@@ -62,14 +60,6 @@ func GetTcpChannelTimeoutMs() time.Duration {
|
|||||||
return time.Duration(valueFromEnv) * time.Millisecond
|
return time.Duration(valueFromEnv) * time.Millisecond
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMaxNumberOfGoroutines() int {
|
|
||||||
valueFromEnv, err := strconv.Atoi(os.Getenv(MaxNumberOfGoroutinesEnvVarName))
|
|
||||||
if err != nil {
|
|
||||||
return MaxNumberOfGoroutinesDefaultValue
|
|
||||||
}
|
|
||||||
return valueFromEnv
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetMemoryProfilingEnabled() bool {
|
func GetMemoryProfilingEnabled() bool {
|
||||||
return os.Getenv(MemoryProfilingEnabledEnvVarName) == "1"
|
return os.Getenv(MemoryProfilingEnabledEnvVarName) == "1"
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package tap
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -33,8 +32,6 @@ type tcpStreamWrapper struct {
|
|||||||
var streams *sync.Map = &sync.Map{} // global
|
var streams *sync.Map = &sync.Map{} // global
|
||||||
var streamId int64 = 0
|
var streamId int64 = 0
|
||||||
|
|
||||||
var maxNumberOfGoroutines int
|
|
||||||
|
|
||||||
func (factory *tcpStreamFactory) New(net, transport gopacket.Flow, tcp *layers.TCP, ac reassembly.AssemblerContext) reassembly.Stream {
|
func (factory *tcpStreamFactory) New(net, transport gopacket.Flow, tcp *layers.TCP, ac reassembly.AssemblerContext) reassembly.Stream {
|
||||||
rlog.Debugf("* NEW: %s %s", net, transport)
|
rlog.Debugf("* NEW: %s %s", net, transport)
|
||||||
fsmOptions := reassembly.TCPSimpleFSMOptions{
|
fsmOptions := reassembly.TCPSimpleFSMOptions{
|
||||||
@@ -61,11 +58,6 @@ func (factory *tcpStreamFactory) New(net, transport gopacket.Flow, tcp *layers.T
|
|||||||
superIdentifier: &api.SuperIdentifier{},
|
superIdentifier: &api.SuperIdentifier{},
|
||||||
}
|
}
|
||||||
if stream.isTapTarget {
|
if stream.isTapTarget {
|
||||||
if runtime.NumGoroutine() > maxNumberOfGoroutines {
|
|
||||||
appStats.IncDroppedTcpStreams()
|
|
||||||
rlog.Debugf("Dropped a TCP stream because of load. Total dropped: %d Total Goroutines: %d\n", appStats.DroppedTcpStreams, runtime.NumGoroutine())
|
|
||||||
return stream
|
|
||||||
}
|
|
||||||
streamId++
|
streamId++
|
||||||
stream.id = streamId
|
stream.id = streamId
|
||||||
for i, extension := range extensions {
|
for i, extension := range extensions {
|
||||||
|
Reference in New Issue
Block a user