Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b5145e19
Commit
b5145e19
authored
Oct 08, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Oct 08, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #34322 from wojtek-t/cacher_improvements
Automatic merge from submit-queue Improve some logging in cacher
parents
46c00995
c02df26a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
cacher.go
pkg/storage/cacher.go
+21
-9
No files found.
pkg/storage/cacher.go
View file @
b5145e19
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/conversion"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
utilruntime
"k8s.io/kubernetes/pkg/util/runtime"
utilruntime
"k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/util/wait"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/watch"
...
@@ -651,11 +652,14 @@ func (c *cacheWatcher) add(event *watchCacheEvent) {
...
@@ -651,11 +652,14 @@ func (c *cacheWatcher) add(event *watchCacheEvent) {
default
:
default
:
}
}
resultLen
:=
len
(
c
.
result
)
// OK, block sending, but only for up to 5 seconds.
// OK, block sending, but only for up to 5 seconds.
// cacheWatcher.add is called very often, so arrange
// cacheWatcher.add is called very often, so arrange
// to reuse timers instead of constantly allocating.
// to reuse timers instead of constantly allocating.
startTime
:=
time
.
Now
()
trace
:=
util
.
NewTrace
(
fmt
.
Sprintf
(
"cacheWatcher %v: waiting for add (initial result size %v)"
,
reflect
.
TypeOf
(
event
.
Object
)
.
String
(),
len
(
c
.
result
)))
defer
trace
.
LogIfLong
(
5
*
time
.
Millisecond
)
const
timeout
=
5
*
time
.
Second
const
timeout
=
5
*
time
.
Second
t
,
ok
:=
timerPool
.
Get
()
.
(
*
time
.
Timer
)
t
,
ok
:=
timerPool
.
Get
()
.
(
*
time
.
Timer
)
if
ok
{
if
ok
{
...
@@ -680,8 +684,6 @@ func (c *cacheWatcher) add(event *watchCacheEvent) {
...
@@ -680,8 +684,6 @@ func (c *cacheWatcher) add(event *watchCacheEvent) {
c
.
forget
(
false
)
c
.
forget
(
false
)
c
.
stop
()
c
.
stop
()
}
}
glog
.
V
(
2
)
.
Infof
(
"cacheWatcher add function blocked processing of %v for %v (initial result size %v)"
,
reflect
.
TypeOf
(
event
.
Object
)
.
String
(),
time
.
Since
(
startTime
),
resultLen
)
}
}
func
(
c
*
cacheWatcher
)
sendWatchCacheEvent
(
event
watchCacheEvent
)
{
func
(
c
*
cacheWatcher
)
sendWatchCacheEvent
(
event
watchCacheEvent
)
{
...
@@ -717,17 +719,27 @@ func (c *cacheWatcher) process(initEvents []watchCacheEvent, resourceVersion uin
...
@@ -717,17 +719,27 @@ func (c *cacheWatcher) process(initEvents []watchCacheEvent, resourceVersion uin
// As long as these are not processed, we are not processing
// As long as these are not processed, we are not processing
// any incoming events, so if it takes long, we may actually
// any incoming events, so if it takes long, we may actually
// block all watchers for some time.
// block all watchers for some time.
// TODO: If it appears to be long in some cases, we may consider
// TODO: From the logs it seems that there happens processing
// - longer result buffers if there are a lot of initEvents
// times even up to 1s which is very long. However, this doesn't
// - try some parallelization
// depend that much on the number of initEvents. E.g. from the
const
initProcessThreshold
=
5
*
time
.
Millisecond
// 2000-node Kubemark run we have logs like this, e.g.:
// ... processing 13862 initEvents took 66.808689ms
// ... processing 14040 initEvents took 993.532539ms
// We should understand what is blocking us in those cases (e.g.
// is it lack of CPU, network, or sth else) and potentially
// consider increase size of result buffer in those cases.
const
initProcessThreshold
=
50
*
time
.
Millisecond
startTime
:=
time
.
Now
()
startTime
:=
time
.
Now
()
for
_
,
event
:=
range
initEvents
{
for
_
,
event
:=
range
initEvents
{
c
.
sendWatchCacheEvent
(
event
)
c
.
sendWatchCacheEvent
(
event
)
}
}
processingTime
:=
time
.
Since
(
startTime
)
processingTime
:=
time
.
Since
(
startTime
)
if
processingTime
>
initProcessThreshold
{
if
processingTime
>
initProcessThreshold
{
glog
.
V
(
2
)
.
Infof
(
"processing %d initEvents took %v"
,
len
(
initEvents
),
processingTime
)
objType
:=
"<null>"
if
len
(
initEvents
)
>
0
{
objType
=
reflect
.
TypeOf
(
initEvents
[
0
]
.
Object
)
.
String
()
}
glog
.
V
(
2
)
.
Infof
(
"processing %d initEvents of %stook %v"
,
len
(
initEvents
),
objType
,
processingTime
)
}
}
defer
close
(
c
.
result
)
defer
close
(
c
.
result
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment