<div dir="ltr">Thanks a lot, these are indeed reasonable advices! I&#39;ll try them later.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 9, 2015 at 3:06 AM, Timothy Roscoe <span dir="ltr">&lt;<a href="mailto:troscoe@inf.ethz.ch" target="_blank">troscoe@inf.ethz.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
So here&#39;s a few other ideas:<br>
<br>
 - Measure the cost of gettimeofday().   I suspect this is pretty fast<br>
   on Linux, but is no highly optimized on Barrelfish and quite<br>
   possibly results in a system call, potentially followed by a<br>
   reschedule.  I have no idea what QEMU would use to implement this<br>
   either.<br>
<br>
 - Perhaps I&#39;m missing something, but it looks like you have a printf<br>
   inside your timing loop.  On bare metal, this is going to go to the<br>
   UART, which will mean you are limited by the rate at which<br>
   Barrelfish can pump characters down a serial line.  I suggest you<br>
   remove the printf from your timing loop and only print the<br>
   values at the end.<br>
<br>
 - Use rdtsc to get cycle counts, both for gettimeofday() (see above)<br>
   and for iterations of your function.<br>
<br>
 - Look at the machine code being generated for Linux and Barrelfish -<br>
   it&#39;s possible the compiler flags are different and result in<br>
   different optimizations being applied.<br>
<br>
Hopefully some of this is helpful.<br>
<span class="HOEnZb"><font color="#888888"><br>
 -- Timothy Roscoe<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
At Sun, 8 Feb 2015 19:22:58 +0800, &quot;tomsun.0.7&quot; &lt;<a href="mailto:tomsun.0.7@gmail.com">tomsun.0.7@gmail.com</a>&gt; wrote:<br>
&gt; Hi Timothy,<br>
&gt;<br>
&gt; I don&#39;t know why you didn&#39;t see that reply with code. Anyway, it&#39;s like<br>
&gt; this:<br>
&gt;<br>
&gt; &gt; CPU: Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz<br>
&gt; &gt;<br>
&gt; &gt; QEMU execution time:           5509153 us<br>
&gt; &gt; Bare-metal execution time: 10802345 us<br>
&gt; &gt; w/o hyper-threading:              6065235 us<br>
&gt; &gt;<br>
&gt; &gt; code:<br>
&gt; &gt;<br>
&gt; &gt; #include &lt;stdio.h&gt;<br>
&gt; &gt; #include &lt;sys/time.h&gt;<br>
&gt; &gt; long fib(long a, long b, long depth)<br>
&gt; &gt; {<br>
&gt; &gt;     if (depth &gt; 0) {<br>
&gt; &gt;         return fib(b, a + b, depth - 1);<br>
&gt; &gt;     }<br>
&gt; &gt;     return b;<br>
&gt; &gt; }<br>
&gt; &gt; int main(void)<br>
&gt; &gt; {<br>
&gt; &gt;     struct timeval start;<br>
&gt; &gt;     gettimeofday(&amp;start, NULL);<br>
&gt; &gt;     printf(&quot;fib: %ld\n&quot;, fib(1, 1, 10000000000));<br>
&gt; &gt;     struct timeval end;<br>
&gt; &gt;     gettimeofday(&amp;end, NULL);<br>
&gt; &gt;     printf(&quot;time: %ld us\n&quot;, end.tv_usec - start.tv_usec + (end.tv_sec -<br>
&gt; &gt; start.tv_sec) * 10000\00);<br>
&gt; &gt;     return 0;<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; On Sun, Feb 8, 2015 at 7:10 PM, Timothy Roscoe &lt;<a href="mailto:troscoe@inf.ethz.ch">troscoe@inf.ethz.ch</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt; Dear Tom,<br>
&gt; &gt;<br>
&gt; &gt; Perhaps it would be easier for us to understand your problem if you<br>
&gt; &gt; posted the code you running, and also how you are taking your<br>
&gt; &gt; measurements.   Can you share that with us?<br>
&gt; &gt;<br>
&gt; &gt;  -- Timothy<br>
&gt; &gt;<br>
&gt; &gt; At Sun, 8 Feb 2015 12:37:09 +0800, &quot;tomsun.0.7&quot; &lt;<a href="mailto:tomsun.0.7@gmail.com">tomsun.0.7@gmail.com</a>&gt;<br>
&gt; &gt; wrote:<br>
&gt; &gt; &gt; Really sorry for misunderstanding your reply but I also considered about<br>
&gt; &gt; &gt; QEMU&#39;s imprecise measure of time. I increased the steps of additions by<br>
&gt; &gt; 10<br>
&gt; &gt; &gt; times so that it will take around one minute to finish. Then I started<br>
&gt; &gt; &gt; two Barrelfish (one in QEMU and one on bare-metal) and spawned the same<br>
&gt; &gt; &gt; application at the same time (nearly, no guarantee for submillisecond<br>
&gt; &gt; &gt; difference), but I found there is a obvious gap (about 5 seconds) between<br>
&gt; &gt; &gt; their end time to finish.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; And I have read your SOSP paper, which gives an evaluation with OpenMP.<br>
&gt; &gt; &gt; Indeed, the performance for insert sort is nearly the same with the one<br>
&gt; &gt; on<br>
&gt; &gt; &gt; Linux while running on one core. So, I become more curious about why I<br>
&gt; &gt; got<br>
&gt; &gt; &gt; different performance.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Is there any tools, like profiling tools, I can leverage to find out the<br>
&gt; &gt; &gt; reasons?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; On Sun, Feb 8, 2015 at 3:51 AM, Simon Peter &lt;<a href="mailto:speter@inf.ethz.ch">speter@inf.ethz.ch</a>&gt; wrote:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; What I mean is that in order to measure performance in terms of<br>
&gt; &gt; execution<br>
&gt; &gt; &gt; &gt; time (as I can glance from your previous email that had results in<br>
&gt; &gt; it), you<br>
&gt; &gt; &gt; &gt; first need a notion of time. Barrelfish&#39;s notion of time is off on<br>
&gt; &gt; QEMU.<br>
&gt; &gt; &gt; &gt; Hence, you might be seeing wrong results.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; We have compared Barrelfish to Linux performance on bare-metal<br>
&gt; &gt; hardware in<br>
&gt; &gt; &gt; &gt; various papers, such as our SOSP paper.<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; On 02/06/2015 07:02 PM, tomsun.0.7 wrote:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;&gt; I don&#39;t actually care about the measure of CPU speed, I want to know<br>
&gt; &gt; why<br>
&gt; &gt; &gt; &gt;&gt; Barrelfish performs worse on bare-metal than on QEMU with KVM.<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt; As my second reply demonstrated, I got worse performance while running<br>
&gt; &gt; &gt; &gt;&gt; applications on bare-metal than both QEMU with KVM and native Linux.<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt; I made sure that it doesn&#39;t result from CPU frequency, because I<br>
&gt; &gt; &gt; &gt;&gt; accessed the hardware performance registers directly within kernel and<br>
&gt; &gt; &gt; &gt;&gt; found it did run with full speed.<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt; Now, I&#39;m suspecting that is it possible that the performance is<br>
&gt; &gt; &gt; &gt;&gt; influenced by some other factors like, device interrupts?<br>
&gt; &gt; &gt; &gt;&gt; Have you ever measured the performance of Barrelfish and compared it<br>
&gt; &gt; &gt; &gt;&gt; with Linux or other operating system?<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt; On Sat, Feb 7, 2015 at 3:47 AM, Simon Peter &lt;<a href="mailto:speter@inf.ethz.ch">speter@inf.ethz.ch</a><br>
&gt; &gt; &gt; &gt;&gt; &lt;mailto:<a href="mailto:speter@inf.ethz.ch">speter@inf.ethz.ch</a>&gt;&gt; wrote:<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;     I&#39;m also suspecting that it might just be jittery CPU emulation<br>
&gt; &gt; &gt; &gt;&gt;     speed that&#39;s getting you different results. Barrelfish&#39;s usleep<br>
&gt; &gt; &gt; &gt;&gt;     ultimately uses sys_debug_get_tsc_per_ms, so your 2 ways might<br>
&gt; &gt; &gt; &gt;&gt;     actually be the same. Barrelfish measures CPU speed at bootup, but<br>
&gt; &gt; &gt; &gt;&gt;     it&#39;s very bad at figuring it out correctly on QEMU. I&#39;m not sure<br>
&gt; &gt; &gt; &gt;&gt;     what the best way is to get accurate results on QEMU.<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;     On 15-02-04 09:46 PM, tomsun.0.7 wrote:<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     Hi,<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     I started a network application who is dedicated to produce<br>
&gt; &gt; &gt; &gt;&gt;&gt;     packets all the time. However, when I started it on bare-metal, I<br>
&gt; &gt; &gt; &gt;&gt;&gt;     found the throughput is only a half of running in QEMU (of<br>
&gt; &gt; course,<br>
&gt; &gt; &gt; &gt;&gt;&gt;     with KVM enabled).<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     This application is only CPU-intensive, it just produces a lot of<br>
&gt; &gt; &gt; &gt;&gt;&gt;     packets and then destroys them. So it&#39;s none of the devices&#39;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     business. At first, I think it results from the low frequency of<br>
&gt; &gt; &gt; &gt;&gt;&gt;     cores, so I measured this by two ways: 1. invoking native<br>
&gt; &gt; &gt; &gt;&gt;&gt;     Barrelfish interface, sys_debug_get_tsc_per_ms, directly; 2.<br>
&gt; &gt; &gt; &gt;&gt;&gt;     reading tsc and sleeping for 1 second using POSIX sleep (which is<br>
&gt; &gt; &gt; &gt;&gt;&gt;     implemented by invoking Barrelfish&#39;s usleep as I know). However,<br>
&gt; &gt; I<br>
&gt; &gt; &gt; &gt;&gt;&gt;     got the full-speed results under both conditions.<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     So, I don&#39;t know whether it results from incorrect measure of<br>
&gt; &gt; &gt; &gt;&gt;&gt;     frequency or some other CPU problems because I even tried to<br>
&gt; &gt; start<br>
&gt; &gt; &gt; &gt;&gt;&gt;     it with PXE in QEMU, and got full performance.<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     What can I do to get normal performance on bare-metal? Or, if it<br>
&gt; &gt; &gt; &gt;&gt;&gt;     results from low frequency of CPUs, what can I do to tune up the<br>
&gt; &gt; &gt; &gt;&gt;&gt;     frequency?<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     Tom<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     _______________________________________________<br>
&gt; &gt; &gt; &gt;&gt;&gt;     Barrelfish-users mailing list<br>
&gt; &gt; &gt; &gt;&gt;&gt;     <a href="mailto:Barrelfish-users@lists.inf.ethz.ch">Barrelfish-users@lists.inf.ethz.ch</a>  &lt;mailto:<a href="mailto:Barrelfish-users@">Barrelfish-users@</a><br>
&gt; &gt; &gt; &gt;&gt;&gt; <a href="http://lists.inf.ethz.ch" target="_blank">lists.inf.ethz.ch</a>&gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt;     <a href="https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/barrelfish-users</a><br>
&gt; &gt; &gt; &gt;&gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;&gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>