Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
misc
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
misc
Commits
8bc6d19a
Commit
8bc6d19a
authored
Mar 17, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3ff8da1e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
633 additions
and
4 deletions
+633
-4
cpu_syspread.prof
cpu_syspread.prof
+0
-0
pprof-syspread002.svg
pprof-syspread002.svg
+615
-0
profile-syspread002.gif
profile-syspread002.gif
+0
-0
t_syspread_go.go
t_syspread_go.go
+18
-4
No files found.
cpu_syspread.prof
0 → 100644
View file @
8bc6d19a
File added
pprof-syspread002.svg
0 → 100644
View file @
8bc6d19a
This diff is collapsed.
Click to expand it.
profile-syspread002.gif
0 → 100644
View file @
8bc6d19a
67.9 KB
t_syspread_go.go
View file @
8bc6d19a
...
...
@@ -6,6 +6,7 @@ import (
"log"
"os"
"runtime/pprof"
"syscall"
"time"
)
...
...
@@ -13,8 +14,8 @@ import (
const
Niter
=
1000000
// xpread is pread(2) but aborts on an error or when fewer bytes was read
func
xpread
(
f
*
os
.
File
,
buf
[]
byte
,
offset
int64
)
{
n
,
err
:=
f
.
ReadAt
(
buf
,
offset
)
func
xpread
(
f
d
int
,
buf
[]
byte
,
offset
int64
)
{
n
,
err
:=
syscall
.
Pread
(
fd
,
buf
,
offset
)
if
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -23,6 +24,18 @@ func xpread(f *os.File, buf []byte, offset int64) {
}
}
// xreadat is ReadAt but aborts on an error or when fewer bytes was read
func
xreadat
(
f
*
os
.
File
,
buf
[]
byte
,
offset
int64
)
{
n
,
err
:=
f
.
ReadAt
(
buf
,
offset
)
if
err
!=
nil
{
panic
(
err
)
}
if
n
!=
len
(
buf
)
{
panic
(
fmt
.
Errorf
(
"readat(%v) -> %v"
,
len
(
buf
),
n
))
}
}
const
BufSize
=
4096
var
buf
[
BufSize
]
byte
...
...
@@ -50,17 +63,18 @@ func main() {
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
fd
:=
int
(
f
.
Fd
())
for
size
:=
0
;
size
<=
BufSize
;
{
sbuf
:=
buf
[
:
size
]
// warmup
xpread
(
f
,
sbuf
,
/*offset=*/
0
)
xpread
(
f
d
,
sbuf
,
/*offset=*/
0
)
Tstart
:=
time
.
Now
()
for
i
:=
0
;
i
<
Niter
;
i
++
{
xpread
(
f
,
sbuf
,
/*offset=*/
0
)
xpread
(
f
d
,
sbuf
,
/*offset=*/
0
)
}
Tend
:=
time
.
Now
()
...
...
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