Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
71516733
Commit
71516733
authored
Dec 14, 2016
by
4ast
Committed by
GitHub
Dec 14, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #861 from brendangregg/master
Improve linear histogram limit, and improve error message.
parents
698e4f7c
e7427d95
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
10 deletions
+22
-10
src/python/bcc/table.py
src/python/bcc/table.py
+22
-10
No files found.
src/python/bcc/table.py
View file @
71516733
...
...
@@ -33,6 +33,8 @@ BPF_MAP_TYPE_LRU_HASH = 9
BPF_MAP_TYPE_LRU_PERCPU_HASH
=
10
stars_max
=
40
log2_index_max
=
65
linear_index_max
=
1025
# helper functions, consider moving these to a utils module
def
_stars
(
val
,
val_max
,
width
):
...
...
@@ -287,6 +289,8 @@ class TableBase(MutableMapping):
If section_print_fn is not None, it will be passed the bucket value
to format into a string as it sees fit. If bucket_fn is not None,
it will be used to produce a bucket value for the histogram keys.
The maximum index allowed is log2_index_max (65), which will
accomodate any 64-bit integer in the histogram.
"""
if
isinstance
(
self
.
Key
(),
ct
.
Structure
):
tmp
=
{}
...
...
@@ -296,7 +300,7 @@ class TableBase(MutableMapping):
bucket
=
getattr
(
k
,
f1
)
if
bucket_fn
:
bucket
=
bucket_fn
(
bucket
)
vals
=
tmp
[
bucket
]
=
tmp
.
get
(
bucket
,
[
0
]
*
65
)
vals
=
tmp
[
bucket
]
=
tmp
.
get
(
bucket
,
[
0
]
*
log2_index_max
)
slot
=
getattr
(
k
,
f2
)
vals
[
slot
]
=
v
.
value
for
bucket
,
vals
in
tmp
.
items
():
...
...
@@ -307,7 +311,7 @@ class TableBase(MutableMapping):
print
(
"
\
n
%s = %r"
%
(
section_header
,
bucket
))
_print_log2_hist
(
vals
,
val_type
)
else
:
vals
=
[
0
]
*
65
vals
=
[
0
]
*
log2_index_max
for
k
,
v
in
self
.
items
():
vals
[
k
.
value
]
=
v
.
value
_print_log2_hist
(
vals
,
val_type
)
...
...
@@ -324,6 +328,8 @@ class TableBase(MutableMapping):
each. If section_print_fn is not None, it will be passed the bucket
value to format into a string as it sees fit. If bucket_fn is not None,
it will be used to produce a bucket value for the histogram keys.
The maximum index allowed is linear_index_max (1025), which is hoped
to be sufficient for integer ranges spanned.
"""
if
isinstance
(
self
.
Key
(),
ct
.
Structure
):
tmp
=
{}
...
...
@@ -333,7 +339,7 @@ class TableBase(MutableMapping):
bucket
=
getattr
(
k
,
f1
)
if
bucket_fn
:
bucket
=
bucket_fn
(
bucket
)
vals
=
tmp
[
bucket
]
=
tmp
.
get
(
bucket
,
[
0
]
*
65
)
vals
=
tmp
[
bucket
]
=
tmp
.
get
(
bucket
,
[
0
]
*
linear_index_max
)
slot
=
getattr
(
k
,
f2
)
vals
[
slot
]
=
v
.
value
for
bucket
,
vals
in
tmp
.
items
():
...
...
@@ -344,9 +350,15 @@ class TableBase(MutableMapping):
print
(
"
\
n
%s = %r"
%
(
section_header
,
bucket
))
_print_linear_hist
(
vals
,
val_type
)
else
:
vals
=
[
0
]
*
65
vals
=
[
0
]
*
linear_index_max
for
k
,
v
in
self
.
items
():
try
:
vals
[
k
.
value
]
=
v
.
value
except
IndexError
:
# Improve error text. If the limit proves a nusiance, this
# function be rewritten to avoid having one.
raise
IndexError
((
"Index in print_linear_hist() of %d "
+
"exceeds max of %d."
)
%
(
k
.
value
,
linear_index_max
))
_print_linear_hist
(
vals
,
val_type
)
...
...
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