Commit 2e07d771 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parents
/t_syspread_c
/t_syspread_go
/t_copy_c
/t_copy_go
all : t_syspread_c t_syspread_go t_copy_c t_copy_go
CFLAGS = -g -O2 -Wall
XDAT = /dev/shm/x.dat
$(XDAT) :
dd if=/dev/urandom of=$(XDAT) bs=4K count=1
bench : bench_c bench_go
bench_c : t_syspread_c $(XDAT) t_copy_c
./t_syspread_c $(XDAT) >t_syspread_c.csv
./t_copy_c >t_copy_c.csv
bench_go : t_syspread_go $(XDAT) t_copy_go
./t_syspread_go $(XDAT) >t_syspread_go.csv
./t_copy_go >t_copy_go.csv
t_syspread_go: t_syspread_go.go
go build $<
t_copy_go: t_copy_go.go
go build $<
File added
#!/usr/bin/env python
import matplotlib.pyplot as plt
import csv
import numpy as np
# loadxy loads (x int; y float) vectors from a csv file
def loadxy(path):
x = []
y = []
with open(path, 'r') as f:
csvf = csv.reader(f, delimiter='\t')
for row in csvf:
x.append(int(row[0]))
y.append(float(row[1]))
return x, y
def plotxy(xy, **kw):
x, y = xy
plt.plot(x, y, **kw)
pread_c = loadxy("t_syspread_c.csv")
pread_go = loadxy("t_syspread_go.csv")
copy_c = loadxy("t_copy_c.csv")
copy_go = loadxy("t_copy_go.csv")
plt.title("Timing for syspread & memcopy")
plotxy(pread_c, label="syspread/c")
plotxy(pread_go, label="syspread/go")
plotxy(copy_c, label="copy/c")
plotxy(copy_go, label="copy/go")
assert pread_c[0] == copy_c[0]
plotxy((pread_c[0], np.array(pread_c[1]) - np.array(copy_c[1])), label="syspread/c - copy/c")
plt.legend()
plt.ylabel('time (ns)')
plt.xlabel('buffer size (bytes)')
#plt.show()
plt.savefig('syspread.png')
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
-->
<!-- Title: t_syspread_go Pages: 1 -->
<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<script type="text/ecmascript"><![CDATA[
/**
* SVGPan library 1.2.1
* ======================
*
* Given an unique existing element with id "viewport" (or when missing, the first g
* element), including the the library into any SVG adds the following capabilities:
*
* - Mouse panning
* - Mouse zooming (using the wheel)
* - Object dragging
*
* You can configure the behaviour of the pan/zoom/drag with the variables
* listed in the CONFIGURATION section of this file.
*
* Known issues:
*
* - Zooming (while panning) on Safari has still some issues
*
* Releases:
*
* 1.2.1, Mon Jul 4 00:33:18 CEST 2011, Andrea Leofreddi
* - Fixed a regression with mouse wheel (now working on Firefox 5)
* - Working with viewBox attribute (#4)
* - Added "use strict;" and fixed resulting warnings (#5)
* - Added configuration variables, dragging is disabled by default (#3)
*
* 1.2, Sat Mar 20 08:42:50 GMT 2010, Zeng Xiaohui
* Fixed a bug with browser mouse handler interaction
*
* 1.1, Wed Feb 3 17:39:33 GMT 2010, Zeng Xiaohui
* Updated the zoom code to support the mouse wheel on Safari/Chrome
*
* 1.0, Andrea Leofreddi
* First release
*
* This code is licensed under the following BSD license:
*
* Copyright 2009-2010 Andrea Leofreddi <a.leofreddi@itcharm.com>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Andrea Leofreddi ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Andrea Leofreddi OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of Andrea Leofreddi.
*/
"use strict";
/// CONFIGURATION
/// ====>
var enablePan = 1; // 1 or 0: enable or disable panning (default enabled)
var enableZoom = 1; // 1 or 0: enable or disable zooming (default enabled)
var enableDrag = 0; // 1 or 0: enable or disable dragging (default disabled)
/// <====
/// END OF CONFIGURATION
var root = document.documentElement;
var state = 'none', svgRoot, stateTarget, stateOrigin, stateTf;
setupHandlers(root);
/**
* Register handlers
*/
function setupHandlers(root){
setAttributes(root, {
"onmouseup" : "handleMouseUp(evt)",
"onmousedown" : "handleMouseDown(evt)",
"onmousemove" : "handleMouseMove(evt)",
//"onmouseout" : "handleMouseUp(evt)", // Decomment this to stop the pan functionality when dragging out of the SVG element
});
if(navigator.userAgent.toLowerCase().indexOf('webkit') >= 0)
window.addEventListener('mousewheel', handleMouseWheel, false); // Chrome/Safari
else
window.addEventListener('DOMMouseScroll', handleMouseWheel, false); // Others
}
/**
* Retrieves the root element for SVG manipulation. The element is then cached into the svgRoot global variable.
*/
function getRoot(root) {
if(typeof(svgRoot) == "undefined") {
var g = null;
g = root.getElementById("viewport");
if(g == null)
g = root.getElementsByTagName('g')[0];
if(g == null)
alert('Unable to obtain SVG root element');
setCTM(g, g.getCTM());
g.removeAttribute("viewBox");
svgRoot = g;
}
return svgRoot;
}
/**
* Instance an SVGPoint object with given event coordinates.
*/
function getEventPoint(evt) {
var p = root.createSVGPoint();
p.x = evt.clientX;
p.y = evt.clientY;
return p;
}
/**
* Sets the current transform matrix of an element.
*/
function setCTM(element, matrix) {
var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
element.setAttribute("transform", s);
}
/**
* Dumps a matrix to a string (useful for debug).
*/
function dumpMatrix(matrix) {
var s = "[ " + matrix.a + ", " + matrix.c + ", " + matrix.e + "\n " + matrix.b + ", " + matrix.d + ", " + matrix.f + "\n 0, 0, 1 ]";
return s;
}
/**
* Sets attributes of an element.
*/
function setAttributes(element, attributes){
for (var i in attributes)
element.setAttributeNS(null, i, attributes[i]);
}
/**
* Handle mouse wheel event.
*/
function handleMouseWheel(evt) {
if(!enableZoom)
return;
if(evt.preventDefault)
evt.preventDefault();
evt.returnValue = false;
var svgDoc = evt.target.ownerDocument;
var delta;
if(evt.wheelDelta)
delta = evt.wheelDelta / 3600; // Chrome/Safari
else
delta = evt.detail / -90; // Mozilla
var z = 1 + delta; // Zoom factor: 0.9/1.1
var g = getRoot(svgDoc);
var p = getEventPoint(evt);
p = p.matrixTransform(g.getCTM().inverse());
// Compute new scale matrix in current mouse position
var k = root.createSVGMatrix().translate(p.x, p.y).scale(z).translate(-p.x, -p.y);
setCTM(g, g.getCTM().multiply(k));
if(typeof(stateTf) == "undefined")
stateTf = g.getCTM().inverse();
stateTf = stateTf.multiply(k.inverse());
}
/**
* Handle mouse move event.
*/
function handleMouseMove(evt) {
if(evt.preventDefault)
evt.preventDefault();
evt.returnValue = false;
var svgDoc = evt.target.ownerDocument;
var g = getRoot(svgDoc);
if(state == 'pan' && enablePan) {
// Pan mode
var p = getEventPoint(evt).matrixTransform(stateTf);
setCTM(g, stateTf.inverse().translate(p.x - stateOrigin.x, p.y - stateOrigin.y));
} else if(state == 'drag' && enableDrag) {
// Drag mode
var p = getEventPoint(evt).matrixTransform(g.getCTM().inverse());
setCTM(stateTarget, root.createSVGMatrix().translate(p.x - stateOrigin.x, p.y - stateOrigin.y).multiply(g.getCTM().inverse()).multiply(stateTarget.getCTM()));
stateOrigin = p;
}
}
/**
* Handle click event.
*/
function handleMouseDown(evt) {
if(evt.preventDefault)
evt.preventDefault();
evt.returnValue = false;
var svgDoc = evt.target.ownerDocument;
var g = getRoot(svgDoc);
if(
evt.target.tagName == "svg"
|| !enableDrag // Pan anyway when drag is disabled and the user clicked on an element
) {
// Pan mode
state = 'pan';
stateTf = g.getCTM().inverse();
stateOrigin = getEventPoint(evt).matrixTransform(stateTf);
} else {
// Drag mode
state = 'drag';
stateTarget = evt.target;
stateTf = g.getCTM().inverse();
stateOrigin = getEventPoint(evt).matrixTransform(stateTf);
}
}
/**
* Handle mouse button release event.
*/
function handleMouseUp(evt) {
if(evt.preventDefault)
evt.preventDefault();
evt.returnValue = false;
var svgDoc = evt.target.ownerDocument;
if(state == 'pan' || state == 'drag') {
// Quit pan mode
state = '';
}
}
]]></script><g id="viewport" transform="scale(0.5,0.5) translate(0,0)"><g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 1434)">
<title>t_syspread_go</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-1434 1016,-1434 1016,4 -4,4"/>
<g id="clust1" class="cluster"><title>cluster_L</title>
<polygon fill="none" stroke="black" points="8,-1290 8,-1422 458,-1422 458,-1290 8,-1290"/>
</g>
<!-- File: t_syspread_go -->
<g id="node1" class="node"><title>File: t_syspread_go</title>
<polygon fill="#f8f8f8" stroke="black" points="450,-1414 16,-1414 16,-1298 450,-1298 450,-1414"/>
<text text-anchor="start" x="24" y="-1397.2" font-family="Times,serif" font-size="16.00">File: t_syspread_go</text>
<text text-anchor="start" x="24" y="-1379.2" font-family="Times,serif" font-size="16.00">Type: cpu</text>
<text text-anchor="start" x="24" y="-1361.2" font-family="Times,serif" font-size="16.00">Time: Mar 15, 2017 at 10:11pm (MSK)</text>
<text text-anchor="start" x="24" y="-1343.2" font-family="Times,serif" font-size="16.00">Duration: 18.42s, Total samples = 183.20ms ( 0.99%)</text>
<text text-anchor="start" x="24" y="-1325.2" font-family="Times,serif" font-size="16.00">Showing nodes accounting for 180ms, 98.25% of 183.20ms total</text>
<text text-anchor="start" x="24" y="-1307.2" font-family="Times,serif" font-size="16.00">Dropped 8 nodes (cum &lt;= 0.92ms)</text>
</g>
<!-- N1 -->
<g id="node2" class="node"><title>N1</title>
<g id="a_node2"><a xlink:title="syscall.Syscall6 /home/kirr/src/tools/go/go/src/syscall/asm_linux_amd64.s (141.70ms)">
<polygon fill="#edd7d5" stroke="#b20d00" points="628.5,-496 395.5,-496 395.5,-358 628.5,-358 628.5,-496"/>
<text text-anchor="middle" x="512" y="-472.8" font-family="Times,serif" font-size="24.00">syscall</text>
<text text-anchor="middle" x="512" y="-446.8" font-family="Times,serif" font-size="24.00">Syscall6</text>
<text text-anchor="middle" x="512" y="-420.8" font-family="Times,serif" font-size="24.00">asm_linux_amd64.s</text>
<text text-anchor="middle" x="512" y="-394.8" font-family="Times,serif" font-size="24.00">112.80ms (61.57%)</text>
<text text-anchor="middle" x="512" y="-368.8" font-family="Times,serif" font-size="24.00">of 141.70ms (77.35%)</text>
</a>
</g>
</g>
<!-- N6 -->
<g id="node7" class="node"><title>N6</title>
<g id="a_node7"><a xlink:title="runtime.exitsyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (12.80ms)">
<polygon fill="#ede9e4" stroke="#b29674" points="682,-307 578,-307 578,-239 682,-239 682,-307"/>
<text text-anchor="middle" x="630" y="-294.2" font-family="Times,serif" font-size="11.00">runtime</text>
<text text-anchor="middle" x="630" y="-282.2" font-family="Times,serif" font-size="11.00">exitsyscall</text>
<text text-anchor="middle" x="630" y="-270.2" font-family="Times,serif" font-size="11.00">proc.go</text>
<text text-anchor="middle" x="630" y="-258.2" font-family="Times,serif" font-size="11.00">3.80ms (2.07%)</text>
<text text-anchor="middle" x="630" y="-246.2" font-family="Times,serif" font-size="11.00">of 12.80ms (6.99%)</text>
</a>
</g>
</g>
<!-- N1&#45;&gt;N6 -->
<g id="edge10" class="edge"><title>N1&#45;&gt;N6</title>
<g id="a_edge10"><a xlink:title="syscall.Syscall6 /home/kirr/src/tools/go/go/src/syscall/asm_linux_amd64.s &#45;&gt; runtime.exitsyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (12.80ms)">
<path fill="none" stroke="#b29674" d="M565.132,-357.559C576.378,-343.073 587.911,-328.216 598.076,-315.123"/>
<polygon fill="#b29674" stroke="#b29674" points="600.845,-317.263 604.213,-307.218 595.316,-312.97 600.845,-317.263"/>
</a>
</g>
<g id="a_edge10&#45;label"><a xlink:title="syscall.Syscall6 /home/kirr/src/tools/go/go/src/syscall/asm_linux_amd64.s &#45;&gt; runtime.exitsyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (12.80ms)">
<text text-anchor="middle" x="615" y="-328.8" font-family="Times,serif" font-size="14.00"> 12.80ms</text>
</a>
</g>
</g>
<!-- N11 -->
<g id="node12" class="node"><title>N11</title>
<g id="a_node12"><a xlink:title="runtime.entersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (16.10ms)">
<polygon fill="#ede8e2" stroke="#b28c64" points="560,-304.5 464,-304.5 464,-241.5 560,-241.5 560,-304.5"/>
<text text-anchor="middle" x="512" y="-292.5" font-family="Times,serif" font-size="10.00">runtime</text>
<text text-anchor="middle" x="512" y="-281.5" font-family="Times,serif" font-size="10.00">entersyscall</text>
<text text-anchor="middle" x="512" y="-270.5" font-family="Times,serif" font-size="10.00">proc.go</text>
<text text-anchor="middle" x="512" y="-259.5" font-family="Times,serif" font-size="10.00">1.60ms (0.87%)</text>
<text text-anchor="middle" x="512" y="-248.5" font-family="Times,serif" font-size="10.00">of 16.10ms (8.79%)</text>
</a>
</g>
</g>
<!-- N1&#45;&gt;N11 -->
<g id="edge8" class="edge"><title>N1&#45;&gt;N11</title>
<g id="a_edge8"><a xlink:title="syscall.Syscall6 /home/kirr/src/tools/go/go/src/syscall/asm_linux_amd64.s &#45;&gt; runtime.entersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (16.10ms)">
<path fill="none" stroke="#b28c64" d="M512,-357.559C512,-343.01 512,-328.087 512,-314.953"/>
<polygon fill="#b28c64" stroke="#b28c64" points="515.5,-314.844 512,-304.844 508.5,-314.844 515.5,-314.844"/>
</a>
</g>
<g id="a_edge8&#45;label"><a xlink:title="syscall.Syscall6 /home/kirr/src/tools/go/go/src/syscall/asm_linux_amd64.s &#45;&gt; runtime.entersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (16.10ms)">
<text text-anchor="middle" x="538" y="-328.8" font-family="Times,serif" font-size="14.00"> 16.10ms</text>
</a>
</g>
</g>
<!-- N2 -->
<g id="node3" class="node"><title>N2</title>
<g id="a_node3"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go (173.60ms)">
<polygon fill="#edd5d5" stroke="#b20200" points="569,-752 455,-752 455,-672 569,-672 569,-752"/>
<text text-anchor="middle" x="512" y="-739.2" font-family="Times,serif" font-size="11.00">internal/poll</text>
<text text-anchor="middle" x="512" y="-727.2" font-family="Times,serif" font-size="11.00">(*FD)</text>
<text text-anchor="middle" x="512" y="-715.2" font-family="Times,serif" font-size="11.00">Pread</text>
<text text-anchor="middle" x="512" y="-703.2" font-family="Times,serif" font-size="11.00">fd_unix.go</text>
<text text-anchor="middle" x="512" y="-691.2" font-family="Times,serif" font-size="11.00">2ms (1.09%)</text>
<text text-anchor="middle" x="512" y="-679.2" font-family="Times,serif" font-size="11.00">of 173.60ms (94.76%)</text>
</a>
</g>
</g>
<!-- N7 -->
<g id="node8" class="node"><title>N7</title>
<g id="a_node8"><a xlink:title="syscall.Pread /home/kirr/src/tools/go/go/src/syscall/zsyscall_linux_amd64.go (144.20ms)">
<polygon fill="#edd7d5" stroke="#b20c00" points="576,-618 448,-618 448,-550 576,-550 576,-618"/>
<text text-anchor="middle" x="512" y="-605.2" font-family="Times,serif" font-size="11.00">syscall</text>
<text text-anchor="middle" x="512" y="-593.2" font-family="Times,serif" font-size="11.00">Pread</text>
<text text-anchor="middle" x="512" y="-581.2" font-family="Times,serif" font-size="11.00">zsyscall_linux_amd64.go</text>
<text text-anchor="middle" x="512" y="-569.2" font-family="Times,serif" font-size="11.00">2.50ms (1.36%)</text>
<text text-anchor="middle" x="512" y="-557.2" font-family="Times,serif" font-size="11.00">of 144.20ms (78.71%)</text>
</a>
</g>
</g>
<!-- N2&#45;&gt;N7 -->
<g id="edge6" class="edge"><title>N2&#45;&gt;N7</title>
<g id="a_edge6"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; syscall.Pread /home/kirr/src/tools/go/go/src/syscall/zsyscall_linux_amd64.go (144.20ms)">
<path fill="none" stroke="#b20c00" stroke-width="4" d="M512,-671.823C512,-658.122 512,-642.658 512,-628.618"/>
<polygon fill="#b20c00" stroke="#b20c00" stroke-width="4" points="515.5,-628.211 512,-618.211 508.5,-628.211 515.5,-628.211"/>
</a>
</g>
<g id="a_edge6&#45;label"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; syscall.Pread /home/kirr/src/tools/go/go/src/syscall/zsyscall_linux_amd64.go (144.20ms)">
<text text-anchor="middle" x="541" y="-642.8" font-family="Times,serif" font-size="14.00"> 144.20ms</text>
</a>
</g>
</g>
<!-- N12 -->
<g id="node13" class="node"><title>N12</title>
<g id="a_node13"><a xlink:title="runtime.deferproc /home/kirr/src/tools/go/go/src/runtime/panic.go (7ms)">
<polygon fill="#edebe8" stroke="#b2a590" points="403,-618 317,-618 317,-550 403,-550 403,-618"/>
<text text-anchor="middle" x="360" y="-605.2" font-family="Times,serif" font-size="11.00">runtime</text>
<text text-anchor="middle" x="360" y="-593.2" font-family="Times,serif" font-size="11.00">deferproc</text>
<text text-anchor="middle" x="360" y="-581.2" font-family="Times,serif" font-size="11.00">panic.go</text>
<text text-anchor="middle" x="360" y="-569.2" font-family="Times,serif" font-size="11.00">2.30ms (1.26%)</text>
<text text-anchor="middle" x="360" y="-557.2" font-family="Times,serif" font-size="11.00">of 7ms (3.82%)</text>
</a>
</g>
</g>
<!-- N2&#45;&gt;N12 -->
<g id="edge11" class="edge"><title>N2&#45;&gt;N12</title>
<g id="a_edge11"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; runtime.deferproc /home/kirr/src/tools/go/go/src/runtime/panic.go (7ms)">
<path fill="none" stroke="#b2a590" d="M464.739,-671.823C446.677,-656.851 426.075,-639.773 407.949,-624.748"/>
<polygon fill="#b2a590" stroke="#b2a590" points="409.746,-621.691 399.814,-618.003 405.279,-627.08 409.746,-621.691"/>
</a>
</g>
<g id="a_edge11&#45;label"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; runtime.deferproc /home/kirr/src/tools/go/go/src/runtime/panic.go (7ms)">
<text text-anchor="middle" x="455" y="-642.8" font-family="Times,serif" font-size="14.00"> 7ms</text>
</a>
</g>
</g>
<!-- N16 -->
<g id="node17" class="node"><title>N16</title>
<g id="a_node17"><a xlink:title="runtime.deferreturn /home/kirr/src/tools/go/go/src/runtime/panic.go (6.30ms)">
<polygon fill="#edebe9" stroke="#b2a793" points="692,-618 594,-618 594,-550 692,-550 692,-618"/>
<text text-anchor="middle" x="643" y="-605.2" font-family="Times,serif" font-size="11.00">runtime</text>
<text text-anchor="middle" x="643" y="-593.2" font-family="Times,serif" font-size="11.00">deferreturn</text>
<text text-anchor="middle" x="643" y="-581.2" font-family="Times,serif" font-size="11.00">panic.go</text>
<text text-anchor="middle" x="643" y="-569.2" font-family="Times,serif" font-size="11.00">3.30ms (1.80%)</text>
<text text-anchor="middle" x="643" y="-557.2" font-family="Times,serif" font-size="11.00">of 6.30ms (3.44%)</text>
</a>
</g>
</g>
<!-- N2&#45;&gt;N16 -->
<g id="edge12" class="edge"><title>N2&#45;&gt;N16</title>
<g id="a_edge12"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; runtime.deferreturn /home/kirr/src/tools/go/go/src/runtime/panic.go (6.30ms)">
<path fill="none" stroke="#b2a793" d="M554.909,-671.985C561.349,-666.005 567.879,-659.869 574,-654 583.549,-644.843 593.694,-634.852 603.181,-625.388"/>
<polygon fill="#b2a793" stroke="#b2a793" points="605.695,-627.824 610.287,-618.276 600.743,-622.876 605.695,-627.824"/>
</a>
</g>
<g id="a_edge12&#45;label"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; runtime.deferreturn /home/kirr/src/tools/go/go/src/runtime/panic.go (6.30ms)">
<text text-anchor="middle" x="612.5" y="-642.8" font-family="Times,serif" font-size="14.00"> 6.30ms</text>
</a>
</g>
</g>
<!-- N20 -->
<g id="node21" class="node"><title>N20</title>
<g id="a_node21"><a xlink:title="internal/poll.(*FD).readLock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (6ms)">
<polygon fill="#edebe9" stroke="#b2a895" points="788,-621 710,-621 710,-547 788,-547 788,-621"/>
<text text-anchor="middle" x="749" y="-609" font-family="Times,serif" font-size="10.00">internal/poll</text>
<text text-anchor="middle" x="749" y="-598" font-family="Times,serif" font-size="10.00">(*FD)</text>
<text text-anchor="middle" x="749" y="-587" font-family="Times,serif" font-size="10.00">readLock</text>
<text text-anchor="middle" x="749" y="-576" font-family="Times,serif" font-size="10.00">fd_mutex.go</text>
<text text-anchor="middle" x="749" y="-565" font-family="Times,serif" font-size="10.00">1.10ms (0.6%)</text>
<text text-anchor="middle" x="749" y="-554" font-family="Times,serif" font-size="10.00">of 6ms (3.28%)</text>
</a>
</g>
</g>
<!-- N2&#45;&gt;N20 -->
<g id="edge13" class="edge"><title>N2&#45;&gt;N20</title>
<g id="a_edge13"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; internal/poll.(*FD).readLock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (6ms)">
<path fill="none" stroke="#b2a895" d="M569.313,-688.055C607.809,-671.61 658.983,-647.713 701,-621 701.091,-620.942 701.181,-620.885 701.272,-620.827"/>
<polygon fill="#b2a895" stroke="#b2a895" points="703.402,-623.613 709.791,-615.161 699.526,-617.785 703.402,-623.613"/>
</a>
</g>
<g id="a_edge13&#45;label"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; internal/poll.(*FD).readLock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (6ms)">
<text text-anchor="middle" x="681" y="-642.8" font-family="Times,serif" font-size="14.00"> 6ms</text>
</a>
</g>
</g>
<!-- N21 -->
<g id="node22" class="node"><title>N21</title>
<g id="a_node22"><a xlink:title="internal/poll.(*FD).readUnlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (5.90ms)">
<polygon fill="#edebe9" stroke="#b2a895" points="897.5,-621 806.5,-621 806.5,-547 897.5,-547 897.5,-621"/>
<text text-anchor="middle" x="852" y="-609" font-family="Times,serif" font-size="10.00">internal/poll</text>
<text text-anchor="middle" x="852" y="-598" font-family="Times,serif" font-size="10.00">(*FD)</text>
<text text-anchor="middle" x="852" y="-587" font-family="Times,serif" font-size="10.00">readUnlock</text>
<text text-anchor="middle" x="852" y="-576" font-family="Times,serif" font-size="10.00">fd_mutex.go</text>
<text text-anchor="middle" x="852" y="-565" font-family="Times,serif" font-size="10.00">1.10ms (0.6%)</text>
<text text-anchor="middle" x="852" y="-554" font-family="Times,serif" font-size="10.00">of 5.90ms (3.22%)</text>
</a>
</g>
</g>
<!-- N2&#45;&gt;N21 -->
<g id="edge14" class="edge"><title>N2&#45;&gt;N21</title>
<g id="a_edge14"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; internal/poll.(*FD).readUnlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (5.90ms)">
<path fill="none" stroke="#b2a895" d="M569.021,-698.23C627.926,-683.85 721.624,-657.614 797,-621 797.096,-620.953 797.193,-620.906 797.289,-620.859"/>
<polygon fill="#b2a895" stroke="#b2a895" points="799.061,-623.882 806.289,-616.135 795.808,-617.684 799.061,-623.882"/>
</a>
</g>
<g id="a_edge14&#45;label"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; internal/poll.(*FD).readUnlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (5.90ms)">
<text text-anchor="middle" x="775.5" y="-642.8" font-family="Times,serif" font-size="14.00"> 5.90ms</text>
</a>
</g>
</g>
<!-- N23 -->
<g id="node24" class="node"><title>N23</title>
<g id="a_node24"><a xlink:title="internal/poll.(*pollDesc).prepareRead /home/kirr/src/tools/go/go/src/internal/poll/fd_poll_runtime.go (2ms)">
<polygon fill="#edeceb" stroke="#b2afa8" points="1012,-621 916,-621 916,-547 1012,-547 1012,-621"/>
<text text-anchor="middle" x="964" y="-609" font-family="Times,serif" font-size="10.00">internal/poll</text>
<text text-anchor="middle" x="964" y="-598" font-family="Times,serif" font-size="10.00">(*pollDesc)</text>
<text text-anchor="middle" x="964" y="-587" font-family="Times,serif" font-size="10.00">prepareRead</text>
<text text-anchor="middle" x="964" y="-576" font-family="Times,serif" font-size="10.00">fd_poll_runtime.go</text>
<text text-anchor="middle" x="964" y="-565" font-family="Times,serif" font-size="10.00">1.40ms (0.76%)</text>
<text text-anchor="middle" x="964" y="-554" font-family="Times,serif" font-size="10.00">of 2ms (1.09%)</text>
</a>
</g>
</g>
<!-- N2&#45;&gt;N23 -->
<g id="edge22" class="edge"><title>N2&#45;&gt;N23</title>
<g id="a_edge22"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; internal/poll.(*pollDesc).prepareRead /home/kirr/src/tools/go/go/src/internal/poll/fd_poll_runtime.go (2ms)">
<path fill="none" stroke="#b2afa8" d="M569.027,-705.569C648.048,-696.392 793.886,-673.413 907,-621 907.093,-620.957 907.186,-620.914 907.279,-620.87"/>
<polygon fill="#b2afa8" stroke="#b2afa8" points="908.593,-624.126 915.972,-616.524 905.463,-617.865 908.593,-624.126"/>
</a>
</g>
<g id="a_edge22&#45;label"><a xlink:title="internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go &#45;&gt; internal/poll.(*pollDesc).prepareRead /home/kirr/src/tools/go/go/src/internal/poll/fd_poll_runtime.go (2ms)">
<text text-anchor="middle" x="870" y="-642.8" font-family="Times,serif" font-size="14.00"> 2ms</text>
</a>
</g>
</g>
<!-- N3 -->
<g id="node4" class="node"><title>N3</title>
<g id="a_node4"><a xlink:title="runtime.main /home/kirr/src/tools/go/go/src/runtime/proc.go (183.20ms)">
<polygon fill="#edd5d5" stroke="#b20000" points="556,-1378 468,-1378 468,-1334 556,-1334 556,-1378"/>
<text text-anchor="middle" x="512" y="-1367.6" font-family="Times,serif" font-size="8.00">runtime</text>
<text text-anchor="middle" x="512" y="-1358.6" font-family="Times,serif" font-size="8.00">main</text>
<text text-anchor="middle" x="512" y="-1349.6" font-family="Times,serif" font-size="8.00">proc.go</text>
<text text-anchor="middle" x="512" y="-1340.6" font-family="Times,serif" font-size="8.00">0 of 183.20ms (100%)</text>
</a>
</g>
</g>
<!-- N13 -->
<g id="node14" class="node"><title>N13</title>
<g id="a_node14"><a xlink:title="main.main /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go (183.20ms)">
<polygon fill="#edd5d5" stroke="#b20000" points="561.5,-1247 462.5,-1247 462.5,-1184 561.5,-1184 561.5,-1247"/>
<text text-anchor="middle" x="512" y="-1235" font-family="Times,serif" font-size="10.00">main</text>
<text text-anchor="middle" x="512" y="-1224" font-family="Times,serif" font-size="10.00">main</text>
<text text-anchor="middle" x="512" y="-1213" font-family="Times,serif" font-size="10.00">t_syspread_go.go</text>
<text text-anchor="middle" x="512" y="-1202" font-family="Times,serif" font-size="10.00">1ms (0.55%)</text>
<text text-anchor="middle" x="512" y="-1191" font-family="Times,serif" font-size="10.00">of 183.20ms (100%)</text>
</a>
</g>
</g>
<!-- N3&#45;&gt;N13 -->
<g id="edge1" class="edge"><title>N3&#45;&gt;N13</title>
<g id="a_edge1"><a xlink:title="runtime.main /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; main.main /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go (183.20ms)">
<path fill="none" stroke="#b20000" stroke-width="6" d="M512,-1333.96C512,-1313.68 512,-1282.44 512,-1257.27"/>
<polygon fill="#b20000" stroke="#b20000" stroke-width="6" points="517.25,-1257.26 512,-1247.26 506.75,-1257.26 517.25,-1257.26"/>
</a>
</g>
<g id="a_edge1&#45;label"><a xlink:title="runtime.main /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; main.main /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go (183.20ms)">
<text text-anchor="middle" x="541" y="-1268.8" font-family="Times,serif" font-size="14.00"> 183.20ms</text>
</a>
</g>
</g>
<!-- N4 -->
<g id="node5" class="node"><title>N4</title>
<g id="a_node5"><a xlink:title="os.(*File).ReadAt /home/kirr/src/tools/go/go/src/os/file.go (179.80ms)">
<polygon fill="#edd5d5" stroke="#b20100" points="569,-1014 455,-1014 455,-934 569,-934 569,-1014"/>
<text text-anchor="middle" x="512" y="-1001.2" font-family="Times,serif" font-size="11.00">os</text>
<text text-anchor="middle" x="512" y="-989.2" font-family="Times,serif" font-size="11.00">(*File)</text>
<text text-anchor="middle" x="512" y="-977.2" font-family="Times,serif" font-size="11.00">ReadAt</text>
<text text-anchor="middle" x="512" y="-965.2" font-family="Times,serif" font-size="11.00">file.go</text>
<text text-anchor="middle" x="512" y="-953.2" font-family="Times,serif" font-size="11.00">3.60ms (1.97%)</text>
<text text-anchor="middle" x="512" y="-941.2" font-family="Times,serif" font-size="11.00">of 179.80ms (98.14%)</text>
</a>
</g>
</g>
<!-- N8 -->
<g id="node9" class="node"><title>N8</title>
<g id="a_node9"><a xlink:title="os.(*File).pread /home/kirr/src/tools/go/go/src/os/file_unix.go (176.20ms)">
<polygon fill="#edd5d5" stroke="#b20200" points="569,-883 455,-883 455,-803 569,-803 569,-883"/>
<text text-anchor="middle" x="512" y="-870.2" font-family="Times,serif" font-size="11.00">os</text>
<text text-anchor="middle" x="512" y="-858.2" font-family="Times,serif" font-size="11.00">(*File)</text>
<text text-anchor="middle" x="512" y="-846.2" font-family="Times,serif" font-size="11.00">pread</text>
<text text-anchor="middle" x="512" y="-834.2" font-family="Times,serif" font-size="11.00">file_unix.go</text>
<text text-anchor="middle" x="512" y="-822.2" font-family="Times,serif" font-size="11.00">2.30ms (1.26%)</text>
<text text-anchor="middle" x="512" y="-810.2" font-family="Times,serif" font-size="11.00">of 176.20ms (96.18%)</text>
</a>
</g>
</g>
<!-- N4&#45;&gt;N8 -->
<g id="edge4" class="edge"><title>N4&#45;&gt;N8</title>
<g id="a_edge4"><a xlink:title="os.(*File).ReadAt /home/kirr/src/tools/go/go/src/os/file.go &#45;&gt; os.(*File).pread /home/kirr/src/tools/go/go/src/os/file_unix.go (176.20ms)">
<path fill="none" stroke="#b20200" stroke-width="5" d="M512,-933.946C512,-921.182 512,-906.834 512,-893.41"/>
<polygon fill="#b20200" stroke="#b20200" stroke-width="5" points="516.375,-893.367 512,-883.367 507.625,-893.367 516.375,-893.367"/>
</a>
</g>
<g id="a_edge4&#45;label"><a xlink:title="os.(*File).ReadAt /home/kirr/src/tools/go/go/src/os/file.go &#45;&gt; os.(*File).pread /home/kirr/src/tools/go/go/src/os/file_unix.go (176.20ms)">
<text text-anchor="middle" x="541" y="-904.8" font-family="Times,serif" font-size="14.00"> 176.20ms</text>
</a>
</g>
</g>
<!-- N5 -->
<g id="node6" class="node"><title>N5</title>
<g id="a_node6"><a xlink:title="runtime.casgstatus /home/kirr/src/tools/go/go/src/runtime/proc.go (9.20ms)">
<polygon fill="#edeae7" stroke="#b2a085" points="562.5,-64 461.5,-64 461.5,-0 562.5,-0 562.5,-64"/>
<text text-anchor="middle" x="512" y="-49.6" font-family="Times,serif" font-size="13.00">runtime</text>
<text text-anchor="middle" x="512" y="-35.6" font-family="Times,serif" font-size="13.00">casgstatus</text>
<text text-anchor="middle" x="512" y="-21.6" font-family="Times,serif" font-size="13.00">proc.go</text>
<text text-anchor="middle" x="512" y="-7.6" font-family="Times,serif" font-size="13.00">9.20ms (5.02%)</text>
</a>
</g>
</g>
<!-- N6&#45;&gt;N5 -->
<g id="edge20" class="edge"><title>N6&#45;&gt;N5</title>
<g id="a_edge20"><a xlink:title="runtime.exitsyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.casgstatus /home/kirr/src/tools/go/go/src/runtime/proc.go (3.40ms)">
<path fill="none" stroke="#b2ada1" d="M668.861,-238.876C674.325,-233.237 679.578,-227.191 684,-221 719.943,-170.684 736.162,-123.142 690,-82 650.396,-46.7026 622.455,-80.3924 572,-64 571.902,-63.9683 571.805,-63.9365 571.707,-63.9045"/>
<polygon fill="#b2ada1" stroke="#b2ada1" points="573.167,-60.7121 562.574,-60.5546 570.757,-67.284 573.167,-60.7121"/>
</a>
</g>
<g id="a_edge20&#45;label"><a xlink:title="runtime.exitsyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.casgstatus /home/kirr/src/tools/go/go/src/runtime/proc.go (3.40ms)">
<text text-anchor="middle" x="741.5" y="-147.8" font-family="Times,serif" font-size="14.00"> 3.40ms</text>
</a>
</g>
</g>
<!-- N17 -->
<g id="node18" class="node"><title>N17</title>
<g id="a_node18"><a xlink:title="runtime.exitsyscallfast /home/kirr/src/tools/go/go/src/runtime/proc.go (5.60ms)">
<polygon fill="#edebe9" stroke="#b2a897" points="690.5,-188 585.5,-188 585.5,-115 690.5,-115 690.5,-188"/>
<text text-anchor="middle" x="638" y="-174.4" font-family="Times,serif" font-size="12.00">runtime</text>
<text text-anchor="middle" x="638" y="-161.4" font-family="Times,serif" font-size="12.00">exitsyscallfast</text>
<text text-anchor="middle" x="638" y="-148.4" font-family="Times,serif" font-size="12.00">proc.go</text>
<text text-anchor="middle" x="638" y="-135.4" font-family="Times,serif" font-size="12.00">4.10ms (2.24%)</text>
<text text-anchor="middle" x="638" y="-122.4" font-family="Times,serif" font-size="12.00">of 5.60ms (3.06%)</text>
</a>
</g>
</g>
<!-- N6&#45;&gt;N17 -->
<g id="edge16" class="edge"><title>N6&#45;&gt;N17</title>
<g id="a_edge16"><a xlink:title="runtime.exitsyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.exitsyscallfast /home/kirr/src/tools/go/go/src/runtime/proc.go (5.60ms)">
<path fill="none" stroke="#b2a897" d="M632.228,-238.713C633.068,-226.165 634.039,-211.667 634.942,-198.182"/>
<polygon fill="#b2a897" stroke="#b2a897" points="638.44,-198.328 635.616,-188.116 631.455,-197.86 638.44,-198.328"/>
</a>
</g>
<g id="a_edge16&#45;label"><a xlink:title="runtime.exitsyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.exitsyscallfast /home/kirr/src/tools/go/go/src/runtime/proc.go (5.60ms)">
<text text-anchor="middle" x="657.5" y="-209.8" font-family="Times,serif" font-size="14.00"> 5.60ms</text>
</a>
</g>
</g>
<!-- N7&#45;&gt;N1 -->
<g id="edge7" class="edge"><title>N7&#45;&gt;N1</title>
<g id="a_edge7"><a xlink:title="syscall.Pread /home/kirr/src/tools/go/go/src/syscall/zsyscall_linux_amd64.go &#45;&gt; syscall.Syscall6 /home/kirr/src/tools/go/go/src/syscall/asm_linux_amd64.s (141.70ms)">
<path fill="none" stroke="#b20d00" stroke-width="4" d="M512,-549.749C512,-536.906 512,-521.625 512,-506.303"/>
<polygon fill="#b20d00" stroke="#b20d00" stroke-width="4" points="515.5,-506.253 512,-496.253 508.5,-506.253 515.5,-506.253"/>
</a>
</g>
<g id="a_edge7&#45;label"><a xlink:title="syscall.Pread /home/kirr/src/tools/go/go/src/syscall/zsyscall_linux_amd64.go &#45;&gt; syscall.Syscall6 /home/kirr/src/tools/go/go/src/syscall/asm_linux_amd64.s (141.70ms)">
<text text-anchor="middle" x="541" y="-517.8" font-family="Times,serif" font-size="14.00"> 141.70ms</text>
</a>
</g>
</g>
<!-- N8&#45;&gt;N2 -->
<g id="edge5" class="edge"><title>N8&#45;&gt;N2</title>
<g id="a_edge5"><a xlink:title="os.(*File).pread /home/kirr/src/tools/go/go/src/os/file_unix.go &#45;&gt; internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go (173.60ms)">
<path fill="none" stroke="#b20200" stroke-width="5" d="M512,-802.946C512,-790.182 512,-775.834 512,-762.41"/>
<polygon fill="#b20200" stroke="#b20200" stroke-width="5" points="516.375,-762.367 512,-752.367 507.625,-762.367 516.375,-762.367"/>
</a>
</g>
<g id="a_edge5&#45;label"><a xlink:title="os.(*File).pread /home/kirr/src/tools/go/go/src/os/file_unix.go &#45;&gt; internal/poll.(*FD).Pread /home/kirr/src/tools/go/go/src/internal/poll/fd_unix.go (173.60ms)">
<text text-anchor="middle" x="541" y="-773.8" font-family="Times,serif" font-size="14.00"> 173.60ms</text>
</a>
</g>
</g>
<!-- N9 -->
<g id="node10" class="node"><title>N9</title>
<g id="a_node10"><a xlink:title="runtime.reentersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (12.90ms)">
<polygon fill="#ede9e4" stroke="#b29673" points="567.5,-188 456.5,-188 456.5,-115 567.5,-115 567.5,-188"/>
<text text-anchor="middle" x="512" y="-174.4" font-family="Times,serif" font-size="12.00">runtime</text>
<text text-anchor="middle" x="512" y="-161.4" font-family="Times,serif" font-size="12.00">reentersyscall</text>
<text text-anchor="middle" x="512" y="-148.4" font-family="Times,serif" font-size="12.00">proc.go</text>
<text text-anchor="middle" x="512" y="-135.4" font-family="Times,serif" font-size="12.00">6.30ms (3.44%)</text>
<text text-anchor="middle" x="512" y="-122.4" font-family="Times,serif" font-size="12.00">of 12.90ms (7.04%)</text>
</a>
</g>
</g>
<!-- N9&#45;&gt;N5 -->
<g id="edge15" class="edge"><title>N9&#45;&gt;N5</title>
<g id="a_edge15"><a xlink:title="runtime.reentersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.casgstatus /home/kirr/src/tools/go/go/src/runtime/proc.go (5.80ms)">
<path fill="none" stroke="#b2a896" d="M512,-114.927C512,-102.136 512,-87.5987 512,-74.3571"/>
<polygon fill="#b2a896" stroke="#b2a896" points="515.5,-74.0735 512,-64.0735 508.5,-74.0735 515.5,-74.0735"/>
</a>
</g>
<g id="a_edge15&#45;label"><a xlink:title="runtime.reentersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.casgstatus /home/kirr/src/tools/go/go/src/runtime/proc.go (5.80ms)">
<text text-anchor="middle" x="534.5" y="-85.8" font-family="Times,serif" font-size="14.00"> 5.80ms</text>
</a>
</g>
</g>
<!-- N10 -->
<g id="node11" class="node"><title>N10</title>
<g id="a_node11"><a xlink:title="main.xpread /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go (182.20ms)">
<polygon fill="#edd5d5" stroke="#b20000" points="569,-1133 455,-1133 455,-1065 569,-1065 569,-1133"/>
<text text-anchor="middle" x="512" y="-1120.2" font-family="Times,serif" font-size="11.00">main</text>
<text text-anchor="middle" x="512" y="-1108.2" font-family="Times,serif" font-size="11.00">xpread</text>
<text text-anchor="middle" x="512" y="-1096.2" font-family="Times,serif" font-size="11.00">t_syspread_go.go</text>
<text text-anchor="middle" x="512" y="-1084.2" font-family="Times,serif" font-size="11.00">1.90ms (1.04%)</text>
<text text-anchor="middle" x="512" y="-1072.2" font-family="Times,serif" font-size="11.00">of 182.20ms (99.45%)</text>
</a>
</g>
</g>
<!-- N10&#45;&gt;N4 -->
<g id="edge3" class="edge"><title>N10&#45;&gt;N4</title>
<g id="a_edge3"><a xlink:title="main.xpread /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go &#45;&gt; os.(*File).ReadAt /home/kirr/src/tools/go/go/src/os/file.go (179.80ms)">
<path fill="none" stroke="#b20100" stroke-width="5" d="M512,-1064.71C512,-1052.35 512,-1038.05 512,-1024.55"/>
<polygon fill="#b20100" stroke="#b20100" stroke-width="5" points="516.375,-1024.43 512,-1014.43 507.625,-1024.43 516.375,-1024.43"/>
</a>
</g>
<g id="a_edge3&#45;label"><a xlink:title="main.xpread /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go &#45;&gt; os.(*File).ReadAt /home/kirr/src/tools/go/go/src/os/file.go (179.80ms)">
<text text-anchor="middle" x="541" y="-1035.8" font-family="Times,serif" font-size="14.00"> 179.80ms</text>
</a>
</g>
</g>
<!-- N11&#45;&gt;N9 -->
<g id="edge9" class="edge"><title>N11&#45;&gt;N9</title>
<g id="a_edge9"><a xlink:title="runtime.entersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.reentersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (12.90ms)">
<path fill="none" stroke="#b29673" d="M512,-241.226C512,-228.204 512,-212.76 512,-198.436"/>
<polygon fill="#b29673" stroke="#b29673" points="515.5,-198.255 512,-188.255 508.5,-198.255 515.5,-198.255"/>
</a>
</g>
<g id="a_edge9&#45;label"><a xlink:title="runtime.entersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.reentersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go (12.90ms)">
<text text-anchor="middle" x="538" y="-209.8" font-family="Times,serif" font-size="14.00"> 12.90ms</text>
</a>
</g>
</g>
<!-- N22 -->
<g id="node23" class="node"><title>N22</title>
<g id="a_node23"><a xlink:title="runtime.getcallerpc /home/kirr/src/tools/go/go/src/runtime/asm_amd64.s (1.90ms)">
<polygon fill="#edeceb" stroke="#b2b0a9" points="372,-179.5 286,-179.5 286,-123.5 372,-123.5 372,-179.5"/>
<text text-anchor="middle" x="329" y="-166.7" font-family="Times,serif" font-size="11.00">runtime</text>
<text text-anchor="middle" x="329" y="-154.7" font-family="Times,serif" font-size="11.00">getcallerpc</text>
<text text-anchor="middle" x="329" y="-142.7" font-family="Times,serif" font-size="11.00">asm_amd64.s</text>
<text text-anchor="middle" x="329" y="-130.7" font-family="Times,serif" font-size="11.00">1.90ms (1.04%)</text>
</a>
</g>
</g>
<!-- N11&#45;&gt;N22 -->
<g id="edge23" class="edge"><title>N11&#45;&gt;N22</title>
<g id="a_edge23"><a xlink:title="runtime.entersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.getcallerpc /home/kirr/src/tools/go/go/src/runtime/asm_amd64.s (1.60ms)">
<path fill="none" stroke="#b2b0aa" d="M464.873,-241.226C438.498,-224.003 405.634,-202.542 378.834,-185.042"/>
<polygon fill="#b2b0aa" stroke="#b2b0aa" points="380.648,-182.046 370.361,-179.509 376.82,-187.907 380.648,-182.046"/>
</a>
</g>
<g id="a_edge23&#45;label"><a xlink:title="runtime.entersyscall /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.getcallerpc /home/kirr/src/tools/go/go/src/runtime/asm_amd64.s (1.60ms)">
<text text-anchor="middle" x="454.5" y="-209.8" font-family="Times,serif" font-size="14.00"> 1.60ms</text>
</a>
</g>
</g>
<!-- N18 -->
<g id="node19" class="node"><title>N18</title>
<g id="a_node19"><a xlink:title="runtime.newdefer /home/kirr/src/tools/go/go/src/runtime/panic.go (3.90ms)">
<polygon fill="#edecea" stroke="#b2ac9f" points="377,-455 291,-455 291,-399 377,-399 377,-455"/>
<text text-anchor="middle" x="334" y="-442.2" font-family="Times,serif" font-size="11.00">runtime</text>
<text text-anchor="middle" x="334" y="-430.2" font-family="Times,serif" font-size="11.00">newdefer</text>
<text text-anchor="middle" x="334" y="-418.2" font-family="Times,serif" font-size="11.00">panic.go</text>
<text text-anchor="middle" x="334" y="-406.2" font-family="Times,serif" font-size="11.00">3.90ms (2.13%)</text>
</a>
</g>
</g>
<!-- N12&#45;&gt;N18 -->
<g id="edge19" class="edge"><title>N12&#45;&gt;N18</title>
<g id="a_edge19"><a xlink:title="runtime.deferproc /home/kirr/src/tools/go/go/src/runtime/panic.go &#45;&gt; runtime.newdefer /home/kirr/src/tools/go/go/src/runtime/panic.go (3.90ms)">
<path fill="none" stroke="#b2ac9f" d="M354.422,-549.749C350.252,-524.887 344.549,-490.889 340.229,-465.137"/>
<polygon fill="#b2ac9f" stroke="#b2ac9f" points="343.637,-464.292 338.53,-455.009 336.733,-465.45 343.637,-464.292"/>
</a>
</g>
<g id="a_edge19&#45;label"><a xlink:title="runtime.deferproc /home/kirr/src/tools/go/go/src/runtime/panic.go &#45;&gt; runtime.newdefer /home/kirr/src/tools/go/go/src/runtime/panic.go (3.90ms)">
<text text-anchor="middle" x="373.5" y="-517.8" font-family="Times,serif" font-size="14.00"> 3.90ms</text>
</a>
</g>
</g>
<!-- N12&#45;&gt;N22 -->
<g id="edge25" class="edge"><title>N12&#45;&gt;N22</title>
<g id="a_edge25"><a xlink:title="runtime.deferproc /home/kirr/src/tools/go/go/src/runtime/panic.go &#45;&gt; runtime.getcallerpc /home/kirr/src/tools/go/go/src/runtime/asm_amd64.s (0.30ms)">
<path fill="none" stroke="#b2b2b1" d="M319.784,-549.904C304.935,-535.143 289.83,-516.462 282,-496 241.386,-389.86 286.246,-253.436 312.592,-189.133"/>
<polygon fill="#b2b2b1" stroke="#b2b2b1" points="315.86,-190.391 316.489,-179.815 309.402,-187.69 315.86,-190.391"/>
</a>
</g>
<g id="a_edge25&#45;label"><a xlink:title="runtime.deferproc /home/kirr/src/tools/go/go/src/runtime/panic.go &#45;&gt; runtime.getcallerpc /home/kirr/src/tools/go/go/src/runtime/asm_amd64.s (0.30ms)">
<text text-anchor="middle" x="295.5" y="-328.8" font-family="Times,serif" font-size="14.00"> 0.30ms</text>
</a>
</g>
</g>
<!-- N13&#45;&gt;N10 -->
<g id="edge2" class="edge"><title>N13&#45;&gt;N10</title>
<g id="a_edge2"><a xlink:title="main.main /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go &#45;&gt; main.xpread /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go (182.20ms)">
<path fill="none" stroke="#b20000" stroke-width="5" d="M512,-1183.82C512,-1171.36 512,-1156.74 512,-1143.24"/>
<polygon fill="#b20000" stroke="#b20000" stroke-width="5" points="516.375,-1143.18 512,-1133.18 507.625,-1143.18 516.375,-1143.18"/>
</a>
</g>
<g id="a_edge2&#45;label"><a xlink:title="main.main /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go &#45;&gt; main.xpread /home/kirr/src/wendelin/z/rust/bench/t_syspread_go.go (182.20ms)">
<text text-anchor="middle" x="541" y="-1154.8" font-family="Times,serif" font-size="14.00"> 182.20ms</text>
</a>
</g>
</g>
<!-- N14 -->
<g id="node15" class="node"><title>N14</title>
<g id="a_node15"><a xlink:title="internal/poll.(*fdMutex).rwlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (4.90ms)">
<polygon fill="#edece9" stroke="#b2aa9a" points="855,-463.5 763,-463.5 763,-390.5 855,-390.5 855,-463.5"/>
<text text-anchor="middle" x="809" y="-449.9" font-family="Times,serif" font-size="12.00">internal/poll</text>
<text text-anchor="middle" x="809" y="-436.9" font-family="Times,serif" font-size="12.00">(*fdMutex)</text>
<text text-anchor="middle" x="809" y="-423.9" font-family="Times,serif" font-size="12.00">rwlock</text>
<text text-anchor="middle" x="809" y="-410.9" font-family="Times,serif" font-size="12.00">fd_mutex.go</text>
<text text-anchor="middle" x="809" y="-397.9" font-family="Times,serif" font-size="12.00">4.90ms (2.67%)</text>
</a>
</g>
</g>
<!-- N15 -->
<g id="node16" class="node"><title>N15</title>
<g id="a_node16"><a xlink:title="internal/poll.(*fdMutex).rwunlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (4.80ms)">
<polygon fill="#edecea" stroke="#b2aa9b" points="965,-463.5 873,-463.5 873,-390.5 965,-390.5 965,-463.5"/>
<text text-anchor="middle" x="919" y="-449.9" font-family="Times,serif" font-size="12.00">internal/poll</text>
<text text-anchor="middle" x="919" y="-436.9" font-family="Times,serif" font-size="12.00">(*fdMutex)</text>
<text text-anchor="middle" x="919" y="-423.9" font-family="Times,serif" font-size="12.00">rwunlock</text>
<text text-anchor="middle" x="919" y="-410.9" font-family="Times,serif" font-size="12.00">fd_mutex.go</text>
<text text-anchor="middle" x="919" y="-397.9" font-family="Times,serif" font-size="12.00">4.80ms (2.62%)</text>
</a>
</g>
</g>
<!-- N19 -->
<g id="node20" class="node"><title>N19</title>
<g id="a_node20"><a xlink:title="runtime.freedefer /home/kirr/src/tools/go/go/src/runtime/panic.go (2.90ms)">
<polygon fill="#edeceb" stroke="#b2aea4" points="745,-461 647,-461 647,-393 745,-393 745,-461"/>
<text text-anchor="middle" x="696" y="-448.2" font-family="Times,serif" font-size="11.00">runtime</text>
<text text-anchor="middle" x="696" y="-436.2" font-family="Times,serif" font-size="11.00">freedefer</text>
<text text-anchor="middle" x="696" y="-424.2" font-family="Times,serif" font-size="11.00">panic.go</text>
<text text-anchor="middle" x="696" y="-412.2" font-family="Times,serif" font-size="11.00">2.70ms (1.47%)</text>
<text text-anchor="middle" x="696" y="-400.2" font-family="Times,serif" font-size="11.00">of 2.90ms (1.58%)</text>
</a>
</g>
</g>
<!-- N16&#45;&gt;N19 -->
<g id="edge21" class="edge"><title>N16&#45;&gt;N19</title>
<g id="a_edge21"><a xlink:title="runtime.deferreturn /home/kirr/src/tools/go/go/src/runtime/panic.go &#45;&gt; runtime.freedefer /home/kirr/src/tools/go/go/src/runtime/panic.go (2.90ms)">
<path fill="none" stroke="#b2aea4" d="M654.37,-549.749C662.264,-526.661 672.853,-495.695 681.375,-470.77"/>
<polygon fill="#b2aea4" stroke="#b2aea4" points="684.725,-471.791 684.649,-461.196 678.102,-469.526 684.725,-471.791"/>
</a>
</g>
<g id="a_edge21&#45;label"><a xlink:title="runtime.deferreturn /home/kirr/src/tools/go/go/src/runtime/panic.go &#45;&gt; runtime.freedefer /home/kirr/src/tools/go/go/src/runtime/panic.go (2.90ms)">
<text text-anchor="middle" x="689.5" y="-517.8" font-family="Times,serif" font-size="14.00"> 2.90ms</text>
</a>
</g>
</g>
<!-- N24 -->
<g id="node25" class="node"><title>N24</title>
<g id="a_node25"><a xlink:title="runtime.exitsyscallfast_reacquired /home/kirr/src/tools/go/go/src/runtime/proc.go (1.50ms)">
<polygon fill="#edecec" stroke="#b2b0ab" points="703,-58 581,-58 581,-6 703,-6 703,-58"/>
<text text-anchor="middle" x="642" y="-46" font-family="Times,serif" font-size="10.00">runtime</text>
<text text-anchor="middle" x="642" y="-35" font-family="Times,serif" font-size="10.00">exitsyscallfast_reacquired</text>
<text text-anchor="middle" x="642" y="-24" font-family="Times,serif" font-size="10.00">proc.go</text>
<text text-anchor="middle" x="642" y="-13" font-family="Times,serif" font-size="10.00">1.50ms (0.82%)</text>
</a>
</g>
</g>
<!-- N17&#45;&gt;N24 -->
<g id="edge24" class="edge"><title>N17&#45;&gt;N24</title>
<g id="a_edge24"><a xlink:title="runtime.exitsyscallfast /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.exitsyscallfast_reacquired /home/kirr/src/tools/go/go/src/runtime/proc.go (1.50ms)">
<path fill="none" stroke="#b2b0ab" d="M639.211,-114.927C639.714,-100.143 640.297,-83.0272 640.799,-68.2748"/>
<polygon fill="#b2b0ab" stroke="#b2b0ab" points="644.306,-68.1309 641.148,-58.0176 637.31,-67.8927 644.306,-68.1309"/>
</a>
</g>
<g id="a_edge24&#45;label"><a xlink:title="runtime.exitsyscallfast /home/kirr/src/tools/go/go/src/runtime/proc.go &#45;&gt; runtime.exitsyscallfast_reacquired /home/kirr/src/tools/go/go/src/runtime/proc.go (1.50ms)">
<text text-anchor="middle" x="663.5" y="-85.8" font-family="Times,serif" font-size="14.00"> 1.50ms</text>
</a>
</g>
</g>
<!-- N20&#45;&gt;N14 -->
<g id="edge17" class="edge"><title>N20&#45;&gt;N14</title>
<g id="a_edge17"><a xlink:title="internal/poll.(*FD).readLock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go &#45;&gt; internal/poll.(*fdMutex).rwlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (4.90ms)">
<path fill="none" stroke="#b2aa9a" d="M763.067,-546.659C771.591,-524.639 782.533,-496.374 791.599,-472.954"/>
<polygon fill="#b2aa9a" stroke="#b2aa9a" points="794.882,-474.168 795.228,-463.578 788.354,-471.641 794.882,-474.168"/>
</a>
</g>
<g id="a_edge17&#45;label"><a xlink:title="internal/poll.(*FD).readLock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go &#45;&gt; internal/poll.(*fdMutex).rwlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (4.90ms)">
<text text-anchor="middle" x="798.5" y="-517.8" font-family="Times,serif" font-size="14.00"> 4.90ms</text>
</a>
</g>
</g>
<!-- N21&#45;&gt;N15 -->
<g id="edge18" class="edge"><title>N21&#45;&gt;N15</title>
<g id="a_edge18"><a xlink:title="internal/poll.(*FD).readUnlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go &#45;&gt; internal/poll.(*fdMutex).rwunlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (4.80ms)">
<path fill="none" stroke="#b2aa9b" d="M867.709,-546.659C877.227,-524.639 889.445,-496.374 899.568,-472.954"/>
<polygon fill="#b2aa9b" stroke="#b2aa9b" points="902.866,-474.146 903.621,-463.578 896.44,-471.369 902.866,-474.146"/>
</a>
</g>
<g id="a_edge18&#45;label"><a xlink:title="internal/poll.(*FD).readUnlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go &#45;&gt; internal/poll.(*fdMutex).rwunlock /home/kirr/src/tools/go/go/src/internal/poll/fd_mutex.go (4.80ms)">
<text text-anchor="middle" x="903.5" y="-517.8" font-family="Times,serif" font-size="14.00"> 4.80ms</text>
</a>
</g>
</g>
</g>
</g></svg>
Tsyspread/c 0..4K
Tsyspread/go 0..4K
Tcopy 0..4K
C(copy) = ~ 0.01ns / byte <- β (= ~ 40ns for 4K)
C(syscall/c) = ~ 175ns <- α
C(syscall/go) = ~ 325ns <- α
C(sysread(n)) = α + β⋅n
C(copy(n)) = β⋅n
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
// microtime returns current time as double
double microtime() {
int err;
struct timeval tv;
err = gettimeofday(&tv, NULL);
if (err == -1) {
perror("gettimeofday");
abort();
}
return tv.tv_sec + 1E-6 * tv.tv_usec;
}
// 12345678
#define NITER 1000000
#define BUFSIZE 4096
static char buf[BUFSIZE];
static char buf2[BUFSIZE];
int main() {
int i;
size_t size;
for (size = 0; size <= BUFSIZE;) {
// warmup
memcpy(buf2, buf, size);
double Tstart, Tend;
Tstart = microtime();
for (i = 0; i < NITER; i++) {
memcpy(buf2, buf, size);
}
Tend = microtime();
printf("%ld\t%.1f\n", size, (Tend - Tstart) / NITER / 1E-9);
if (size < 16) {
size += 1; // detailed start
} else if (size < 128) {
size += 16;
} else {
size += 128;
}
}
}
0 2.8
1 2.4
2 2.7
3 2.7
4 3.0
5 2.9
6 3.0
7 3.0
8 2.4
9 2.5
10 2.5
11 2.5
12 2.6
13 2.6
14 2.5
15 2.5
16 2.4
32 2.5
48 2.5
64 2.1
80 4.3
96 2.7
112 3.5
128 4.6
256 3.5
384 5.3
512 6.8
640 7.6
768 8.7
896 10.0
1024 11.2
1152 12.1
1280 13.0
1408 14.2
1536 15.4
1664 16.7
1792 17.8
1920 18.9
2048 20.1
2176 22.4
2304 24.2
2432 25.8
2560 26.6
2688 27.6
2816 28.4
2944 29.6
3072 30.9
3200 32.1
3328 33.4
3456 34.4
3584 35.9
3712 36.6
3840 38.1
3968 38.9
4096 41.0
0 2.0
1 3.8
2 3.1
3 3.2
4 2.4
5 3.5
6 3.5
7 3.5
8 2.4
9 3.5
10 3.5
11 3.5
12 3.5
13 3.5
14 3.4
15 3.4
16 2.9
32 3.0
48 4.5
64 4.0
80 6.6
96 6.6
112 7.1
128 6.9
256 10.4
384 10.8
512 12.2
640 13.2
768 14.5
896 15.7
1024 16.8
1152 18.3
1280 19.3
1408 20.5
1536 21.4
1664 22.8
1792 24.1
1920 25.1
2048 26.0
2176 27.5
2304 28.9
2432 29.6
2560 31.3
2688 32.7
2816 33.5
2944 34.6
3072 35.5
3200 37.0
3328 38.2
3456 39.2
3584 40.8
3712 41.8
3840 43.0
3968 44.0
4096 45.3
package main
import (
"fmt"
"time"
)
// 12345678
const Niter = 1000000
const BufSize = 4096
var buf [BufSize]byte
var buf2 [BufSize]byte
func main() {
for size := 0; size <= BufSize; {
src := buf[:size]
dst := buf2[:size]
// warmup
copy(dst, src)
Tstart := time.Now()
for i := 0; i < Niter; i++ {
copy(dst, src)
}
Tend := time.Now()
fmt.Printf("%v\t%.1f\n", size, float64(Tend.Sub(Tstart).Nanoseconds()) / Niter)
switch {
case size < 16:
size += 1 // detailed start
case size < 128:
size += 16
default:
size += 128
}
}
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
// 12345678
#define NITER 1000000
// microtime returns current time as double
double microtime() {
int err;
struct timeval tv;
err = gettimeofday(&tv, NULL);
if (err == -1) {
perror("gettimeofday");
abort();
}
return tv.tv_sec + 1E-6 * tv.tv_usec;
}
#define BUFSIZE 4096
static char buf[BUFSIZE];
// xpread is pread(2) but aborts on an error or when fewer bytes was read
void xpread(int fd, void *buf, size_t count, off_t offset) {
ssize_t n;
n = pread(fd, buf, count, offset);
if (n == -1) {
perror("pread");
abort();
}
if (n != count) {
fprintf(stderr, "pread(%ld) -> %ld\n", count, n);
abort();
}
}
int main(int argc, char *argv[]) {
int fd, i;
size_t size;
if (argc < 2) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
exit(1);
}
fd = open(argv[1], O_RDONLY);
if (fd == -1) {
perror("open");
abort();
}
for (size = 0; size <= BUFSIZE;) {
// warmup
xpread(fd, &buf, size, /*offset=*/0);
double Tstart, Tend;
Tstart = microtime();
for (i = 0; i < NITER; i++) {
xpread(fd, buf, size, /*offset=*/0);
}
Tend = microtime();
printf("%ld\t%.1f\n", size, (Tend - Tstart) / NITER / 1E-9);
if (size < 16) {
size += 1; // detailed start
} else if (size < 128) {
size += 16;
} else {
size += 128;
}
}
}
0 159.5
1 186.2
2 178.3
3 177.6
4 178.9
5 177.2
6 177.3
7 177.9
8 178.0
9 177.8
10 177.7
11 177.3
12 177.4
13 178.4
14 177.2
15 178.0
16 177.3
32 177.2
48 177.5
64 177.6
80 177.9
96 180.1
112 180.8
128 179.9
256 184.0
384 186.2
512 187.2
640 188.2
768 189.4
896 191.0
1024 192.4
1152 193.9
1280 195.0
1408 195.6
1536 197.9
1664 198.9
1792 199.4
1920 201.0
2048 201.6
2176 203.8
2304 204.5
2432 205.8
2560 207.1
2688 207.5
2816 210.1
2944 210.0
3072 214.4
3200 215.2
3328 216.3
3456 220.7
3584 219.0
3712 222.0
3840 221.2
3968 222.8
4096 224.3
0 14.4
1 335.7
2 325.8
3 325.2
4 325.8
5 325.7
6 325.3
7 325.4
8 326.7
9 325.7
10 325.3
11 326.4
12 325.7
13 325.8
14 328.9
15 325.5
16 326.4
32 325.9
48 325.4
64 325.8
80 326.5
96 328.5
112 329.4
128 328.6
256 329.4
384 330.4
512 332.3
640 333.9
768 334.0
896 335.8
1024 336.9
1152 338.6
1280 339.5
1408 340.6
1536 342.0
1664 342.8
1792 343.7
1920 345.7
2048 347.2
2176 347.2
2304 348.3
2432 350.2
2560 351.2
2688 352.3
2816 354.0
2944 355.0
3072 358.9
3200 360.2
3328 361.3
3456 362.0
3584 363.7
3712 365.0
3840 366.4
3968 367.0
4096 368.0
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime/pprof"
"time"
)
// 12345678
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)
if err != nil {
panic(err)
}
if n != len(buf) {
panic(fmt.Errorf("pread(%v) -> %v", len(buf), n))
}
}
const BufSize = 4096
var buf [BufSize]byte
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`")
func main() {
flag.Parse()
if len(flag.Args()) < 1 {
log.Fatalf("Usage: %s <file>", os.Args[0])
}
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal("could not create CPU profile: ", err)
}
if err := pprof.StartCPUProfile(f); err != nil {
log.Fatal("could not start CPU profile: ", err)
}
defer pprof.StopCPUProfile()
}
f, err := os.Open(flag.Args()[0])
if err != nil {
log.Fatal(err)
}
for size := 0; size <= BufSize; {
sbuf := buf[:size]
// warmup
xpread(f, sbuf, /*offset=*/0)
Tstart := time.Now()
for i := 0; i < Niter; i++ {
xpread(f, sbuf, /*offset=*/0)
}
Tend := time.Now()
fmt.Printf("%v\t%.1f\n", size, float64(Tend.Sub(Tstart).Nanoseconds()) / Niter)
switch {
case size < 16:
size += 1 // detailed start
case size < 128:
size += 16
default:
size += 128
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment