<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: IPC performance, the report</title>
	<atom:link href="http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report/feed" rel="self" type="application/rss+xml" />
	<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report</link>
	<description>From the mind of Philip</description>
	<lastBuildDate>Sun, 28 Aug 2011 12:59:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: Adrien Bustany</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2239</link>
		<dc:creator>Adrien Bustany</dc:creator>
		<pubDate>Thu, 20 May 2010 15:14:40 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2239</guid>
		<description>@Peter Lund: Interesting point, I admit I&#039;m not totally aware of what happens at kernel level. Cachegrind does give some cache hit/miss numbers, I should maybe have a look at them for various buffer sizes.

You might want to read the updated version of the report: http://blogs.gnome.org/abustany/2010/05/20/ipc-performance-the-return-of-the-report/
It does include a new IPC method, and also a report about my vmsplice experiment.</description>
		<content:encoded><![CDATA[<p>@Peter Lund: Interesting point, I admit I&#8217;m not totally aware of what happens at kernel level. Cachegrind does give some cache hit/miss numbers, I should maybe have a look at them for various buffer sizes.</p>
<p>You might want to read the updated version of the report: <a href="http://blogs.gnome.org/abustany/2010/05/20/ipc-performance-the-return-of-the-report/" rel="nofollow">http://blogs.gnome.org/abustany/2010/05/20/ipc-performance-the-return-of-the-report/</a><br />
It does include a new IPC method, and also a report about my vmsplice experiment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Lund</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2235</link>
		<dc:creator>Peter Lund</dc:creator>
		<pubDate>Wed, 19 May 2010 17:36:16 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2235</guid>
		<description>&quot;On Linux, a memory page is (generally) 4096 bytes, as a consequence buffers smaller than 4kB will use a full memory page when sent over the socket and waste memory bandwidth.&quot;

Say what?

Only the parts actually written/read will be copied -- the kernel pretty much just does a memcpy().  The page size is irrelevant.

Btw, copying (with memcpy or similar) is practically free as long as everything stays within the CPU cache(s).  If you are moving big amounts of data around you&#039;d rather not stream through it more than once because if it is big it will /not/ fit in cache.  The CPU might be able to 1) do smart prefetching, 2) have a sensible write allocation policy for its cache(s), 3) not blow the cache(s) entirely but retain most of the non-copied data.  I don&#039;t believe we&#039;re quite there yet ;)

Using vmsplice() (or mmap() tricks) or copying smaller chunks that each fit in the cache ought to be good ideas.  You also don&#039;t have the 2x spike in memory use around the copying (1x for the sender, 1x for the receiver).</description>
		<content:encoded><![CDATA[<p>&#8220;On Linux, a memory page is (generally) 4096 bytes, as a consequence buffers smaller than 4kB will use a full memory page when sent over the socket and waste memory bandwidth.&#8221;</p>
<p>Say what?</p>
<p>Only the parts actually written/read will be copied &#8212; the kernel pretty much just does a memcpy().  The page size is irrelevant.</p>
<p>Btw, copying (with memcpy or similar) is practically free as long as everything stays within the CPU cache(s).  If you are moving big amounts of data around you&#8217;d rather not stream through it more than once because if it is big it will /not/ fit in cache.  The CPU might be able to 1) do smart prefetching, 2) have a sensible write allocation policy for its cache(s), 3) not blow the cache(s) entirely but retain most of the non-copied data.  I don&#8217;t believe we&#8217;re quite there yet ;)</p>
<p>Using vmsplice() (or mmap() tricks) or copying smaller chunks that each fit in the cache ought to be good ideas.  You also don&#8217;t have the 2x spike in memory use around the copying (1x for the sender, 1x for the receiver).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pvanhoof</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2215</link>
		<dc:creator>pvanhoof</dc:creator>
		<pubDate>Sun, 16 May 2010 11:44:28 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2215</guid>
		<description>@Aigars Mahinovs: Apples and oranges: Tokyo Cabinet is a key-value store, not a database with an SQL front end. We translate the SPARQL query into SQL, so we need the expressiveness of such an SQL front end (Tokyo Cabinet&#039;s query expressiveness isn&#039;t sufficient, no). With a key-value store would implementing a SPARQL endpoint be too difficult to do in a well performing way. Note that at some point we considered Tokyo Cabinet for our FTS needs. But because sqlite-fts was already well integrated with SQLite, we opted for this instead. When somebody finds the time to implement a virtual table for Tokyo Cabinet in SQLite, then we might reconsider this indeed (but only for FTS, and note that also for FTS we already have a few specific needs. We would like snippet support, for example).

Keeping all things in RAM also isn&#039;t an option, the target hardware is a mobile device with only a few hundred megabytes of RAM. Not yet gigabytes. But maybe in future this will be an option? BTW, if you have the right indexes in your tables then aren&#039;t on-disk databases going to perform bad either.

In any case, the storage of the data also wasn&#039;t really the point of the experiment. But we did want a realistic measurement, not a sort of &quot;everything-is-in-RAM-dream-come-true&quot;; that&#039;s not useful to measure. Particularly sqlite_value_bytes(), sqlite_value_text() and the memcpy on its results had to be realistic for this experiment.</description>
		<content:encoded><![CDATA[<p>@Aigars Mahinovs: Apples and oranges: Tokyo Cabinet is a key-value store, not a database with an SQL front end. We translate the SPARQL query into SQL, so we need the expressiveness of such an SQL front end (Tokyo Cabinet&#8217;s query expressiveness isn&#8217;t sufficient, no). With a key-value store would implementing a SPARQL endpoint be too difficult to do in a well performing way. Note that at some point we considered Tokyo Cabinet for our FTS needs. But because sqlite-fts was already well integrated with SQLite, we opted for this instead. When somebody finds the time to implement a virtual table for Tokyo Cabinet in SQLite, then we might reconsider this indeed (but only for FTS, and note that also for FTS we already have a few specific needs. We would like snippet support, for example).</p>
<p>Keeping all things in RAM also isn&#8217;t an option, the target hardware is a mobile device with only a few hundred megabytes of RAM. Not yet gigabytes. But maybe in future this will be an option? BTW, if you have the right indexes in your tables then aren&#8217;t on-disk databases going to perform bad either.</p>
<p>In any case, the storage of the data also wasn&#8217;t really the point of the experiment. But we did want a realistic measurement, not a sort of &#8220;everything-is-in-RAM-dream-come-true&#8221;; that&#8217;s not useful to measure. Particularly sqlite_value_bytes(), sqlite_value_text() and the memcpy on its results had to be realistic for this experiment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aigars Mahinovs</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2214</link>
		<dc:creator>Aigars Mahinovs</dc:creator>
		<pubDate>Sun, 16 May 2010 11:17:33 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2214</guid>
		<description>If you want to increase the performance 5-10 times, use Tokyo Cabinet and not SQLite to actually get the data. But if you want maximum performance and don&#039;t care that much about RAM, then keeping the data in RAM can easily be 10-50 times faster than any database.</description>
		<content:encoded><![CDATA[<p>If you want to increase the performance 5-10 times, use Tokyo Cabinet and not SQLite to actually get the data. But if you want maximum performance and don&#8217;t care that much about RAM, then keeping the data in RAM can easily be 10-50 times faster than any database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pvanhoof</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2207</link>
		<dc:creator>pvanhoof</dc:creator>
		<pubDate>Fri, 14 May 2010 11:54:41 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2207</guid>
		<description>@Alexander Larsson: Ah, yes, with a pipe it would be possible to use a FD indeed. You&#039;re right about that. I guess that, at least on Linux, pipe will give similar results as a unix domain socket..? Under the hood I expect that the kernel deals with both the same way. I need to look up how vmsplice works; splicing user pages into a pipe sounds good, yes.</description>
		<content:encoded><![CDATA[<p>@Alexander Larsson: Ah, yes, with a pipe it would be possible to use a FD indeed. You&#8217;re right about that. I guess that, at least on Linux, pipe will give similar results as a unix domain socket..? Under the hood I expect that the kernel deals with both the same way. I need to look up how vmsplice works; splicing user pages into a pipe sounds good, yes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Larsson</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2206</link>
		<dc:creator>Alexander Larsson</dc:creator>
		<pubDate>Fri, 14 May 2010 11:15:45 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2206</guid>
		<description>pvanhoof: 

A file descriptor is only a pipe2() call away. You just create one, send the reading side to the client and then write out the data on the writing side. Additionally it might be possible to get less copying if you use vmsplice() to write to the buffer.

I don&#039;t understand what sqlite3_step overwriting data has to do with anything, this would obviously copy the data just like your custom socket protocol.</description>
		<content:encoded><![CDATA[<p>pvanhoof: </p>
<p>A file descriptor is only a pipe2() call away. You just create one, send the reading side to the client and then write out the data on the writing side. Additionally it might be possible to get less copying if you use vmsplice() to write to the buffer.</p>
<p>I don&#8217;t understand what sqlite3_step overwriting data has to do with anything, this would obviously copy the data just like your custom socket protocol.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pvanhoof</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2204</link>
		<dc:creator>pvanhoof</dc:creator>
		<pubDate>Fri, 14 May 2010 11:09:58 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2204</guid>
		<description>@Andres Freund: That wasn&#039;t the point of this experiment, though. Note that with shared-cache and read_uncommitted mode you can get pretty far with SQLite. Although we&#039;d need a bit more, indeed. SQLite is a design decision for Tracker and we&#039;re of course well aware of SQLite&#039;s limitations. Long term we might consider a database engine like Firebird, but this isn&#039;t being planned at this moment (not for the 0.9 series of Tracker).</description>
		<content:encoded><![CDATA[<p>@Andres Freund: That wasn&#8217;t the point of this experiment, though. Note that with shared-cache and read_uncommitted mode you can get pretty far with SQLite. Although we&#8217;d need a bit more, indeed. SQLite is a design decision for Tracker and we&#8217;re of course well aware of SQLite&#8217;s limitations. Long term we might consider a database engine like Firebird, but this isn&#8217;t being planned at this moment (not for the 0.9 series of Tracker).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andres Freund</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2203</link>
		<dc:creator>Andres Freund</dc:creator>
		<pubDate>Fri, 14 May 2010 10:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2203</guid>
		<description>Perhaps the problems referenced in the beginning are a good indication that it might not be the real thing to make sqlite into a multi-user, multi-client database. Its not exactly intended to be that...</description>
		<content:encoded><![CDATA[<p>Perhaps the problems referenced in the beginning are a good indication that it might not be the real thing to make sqlite into a multi-user, multi-client database. Its not exactly intended to be that&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pvanhoof</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2199</link>
		<dc:creator>pvanhoof</dc:creator>
		<pubDate>Fri, 14 May 2010 09:07:53 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2199</guid>
		<description>@Kall Vahlman: Yes we already knew that D-Bus wasn&#039;t fit for large transfers. The experiment was, however, done to see how well such a custom protocol and Unix domain socket would fit with Tracker&#039;s tracker-store RDF query service, and how fast we could make it given SQLite&#039;s limitations (sqlite_value_bytes is rather slow); not to prove that D-Bus is slow at large transfers, everybody indeed already knows that. If it were files then we&#039;d of course use D-Bus&#039;s FD passing mechanisms. Your so-called *real conclusion* about Prepare() is precisely why we&#039;ve split the experiment&#039;s socket&#039;s protocol up in a Prepare() and Fetch(), so that we could easily adapt the solution to something like this afterward.

@Alexander Larsson: When you have a file descriptor then using D-Bus&#039;s FD passing is of course the preferred way. In our case we have sqlite3_step(), though. When (and if) we do replace D-Bus for the  transfer of query&#039;s result-data we wont replace D-Bus for the other IPC-needs either, of course. sqlite3_step() overwrites the previous pointers to the cell data, so we&#039;d have to copy if we&#039;d wanted to pass info about shared memory, or something. Causing a lot of memory usage in the server. So instead, we opted for sending it over in chunks of 64k.

@Rodrigo Kumpera, Rodrigo Kumpera &amp; tvst (streaming-mode suggestions): Sounds like a good idea to me.</description>
		<content:encoded><![CDATA[<p>@Kall Vahlman: Yes we already knew that D-Bus wasn&#8217;t fit for large transfers. The experiment was, however, done to see how well such a custom protocol and Unix domain socket would fit with Tracker&#8217;s tracker-store RDF query service, and how fast we could make it given SQLite&#8217;s limitations (sqlite_value_bytes is rather slow); not to prove that D-Bus is slow at large transfers, everybody indeed already knows that. If it were files then we&#8217;d of course use D-Bus&#8217;s FD passing mechanisms. Your so-called *real conclusion* about Prepare() is precisely why we&#8217;ve split the experiment&#8217;s socket&#8217;s protocol up in a Prepare() and Fetch(), so that we could easily adapt the solution to something like this afterward.</p>
<p>@Alexander Larsson: When you have a file descriptor then using D-Bus&#8217;s FD passing is of course the preferred way. In our case we have sqlite3_step(), though. When (and if) we do replace D-Bus for the  transfer of query&#8217;s result-data we wont replace D-Bus for the other IPC-needs either, of course. sqlite3_step() overwrites the previous pointers to the cell data, so we&#8217;d have to copy if we&#8217;d wanted to pass info about shared memory, or something. Causing a lot of memory usage in the server. So instead, we opted for sending it over in chunks of 64k.</p>
<p>@Rodrigo Kumpera, Rodrigo Kumpera &#038; tvst (streaming-mode suggestions): Sounds like a good idea to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Larsson</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2198</link>
		<dc:creator>Alexander Larsson</dc:creator>
		<pubDate>Fri, 14 May 2010 08:04:01 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2198</guid>
		<description>This is why gvfs used dbus for everything except for the actual file contents. File contents is instead sent via a custom binary protocol over a pipe that is passed from the gvfs daemon to the client as a result of the open() dbus method.

For gvfs the code handling the fd passing involved is a bit nasty. However, recent versions of dbus has fd passing built in, which should make this very clean and nice.</description>
		<content:encoded><![CDATA[<p>This is why gvfs used dbus for everything except for the actual file contents. File contents is instead sent via a custom binary protocol over a pipe that is passed from the gvfs daemon to the client as a result of the open() dbus method.</p>
<p>For gvfs the code handling the fd passing involved is a bit nasty. However, recent versions of dbus has fd passing built in, which should make this very clean and nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kalle Vahlman</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2197</link>
		<dc:creator>Kalle Vahlman</dc:creator>
		<pubDate>Fri, 14 May 2010 06:30:18 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2197</guid>
		<description>&quot;The real conclusion of this study is: if you have to pass a lot of data between two programs and don’t need a lot of flexibility, then DBus is not the right answer, and never intended to be.&quot;

I&#039;m surprised that someone still needed a study to prove that, I thought it was already common knowledge...

The recommended way to get both the flexibility of D-Bus and the bandwidth of raw sockets is to use the Prepare() call to set up a socket from which the data can can be transferred.

*That* should be the conclusion ;)</description>
		<content:encoded><![CDATA[<p>&#8220;The real conclusion of this study is: if you have to pass a lot of data between two programs and don’t need a lot of flexibility, then DBus is not the right answer, and never intended to be.&#8221;</p>
<p>I&#8217;m surprised that someone still needed a study to prove that, I thought it was already common knowledge&#8230;</p>
<p>The recommended way to get both the flexibility of D-Bus and the bandwidth of raw sockets is to use the Prepare() call to set up a socket from which the data can can be transferred.</p>
<p>*That* should be the conclusion ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rodrigo Kumpera</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2196</link>
		<dc:creator>Rodrigo Kumpera</dc:creator>
		<pubDate>Fri, 14 May 2010 03:30:29 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2196</guid>
		<description>Can&#039;t DBUS be changed to do progressive message decoding? Or even support a streaming mode? This would solve most of your concerns while improving DBUS at the same time.</description>
		<content:encoded><![CDATA[<p>Can&#8217;t DBUS be changed to do progressive message decoding? Or even support a streaming mode? This would solve most of your concerns while improving DBUS at the same time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tvst</title>
		<link>http://pvanhoof.be/blog/index.php/2010/05/13/ipc-performance-the-report#comment-2195</link>
		<dc:creator>tvst</dc:creator>
		<pubDate>Fri, 14 May 2010 00:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://pvanhoof.be/blog/?p=563#comment-2195</guid>
		<description>Great post! 

Maybe it would be a good idea to write a dbus api exactly for these bulk-data transmissions. This api would use dbus for service discovery, then transparently forward the data through unix sockets. 

This is similar to the way &quot;bluetooth over wifi&quot; works. Bluetooth is used for discovery / handshakes, then wifi is used for bulk data transfer.

From ZDNet: 
&quot;Devices will use the regular low-power Bluetooth radios to recognize each other and establish connections,&quot; writes ZDNet&#039;s Rik Fairlie. &quot;If they need to transfer a large file, they will be able to turn on their Wi-Fi radios, then turn them off to save power after finishing the transfer.&quot;
(http://www.zdnet.com/blog/soho-networking/bluetooth-and-wi-fi-combo-could-yield-faster-bulk-data-transfers/139?p=139)

What do you think?</description>
		<content:encoded><![CDATA[<p>Great post! </p>
<p>Maybe it would be a good idea to write a dbus api exactly for these bulk-data transmissions. This api would use dbus for service discovery, then transparently forward the data through unix sockets. </p>
<p>This is similar to the way &#8220;bluetooth over wifi&#8221; works. Bluetooth is used for discovery / handshakes, then wifi is used for bulk data transfer.</p>
<p>From ZDNet:<br />
&#8220;Devices will use the regular low-power Bluetooth radios to recognize each other and establish connections,&#8221; writes ZDNet&#8217;s Rik Fairlie. &#8220;If they need to transfer a large file, they will be able to turn on their Wi-Fi radios, then turn them off to save power after finishing the transfer.&#8221;<br />
(<a href="http://www.zdnet.com/blog/soho-networking/bluetooth-and-wi-fi-combo-could-yield-faster-bulk-data-transfers/139?p=139" rel="nofollow">http://www.zdnet.com/blog/soho-networking/bluetooth-and-wi-fi-combo-could-yield-faster-bulk-data-transfers/139?p=139</a>)</p>
<p>What do you think?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

