<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Tiago Vignatti &#187; GUI</title>
	<atom:link href="http://vignatti.wordpress.com/tag/gui/feed/" rel="self" type="application/rss+xml" />
	<link>http://vignatti.wordpress.com</link>
	<description>In The Eyes Of The World</description>
	<lastBuildDate>Mon, 09 Nov 2009 01:47:17 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='vignatti.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/33cb7ca85d43793f113cab97fc6c2cd1?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Tiago Vignatti &#187; GUI</title>
		<link>http://vignatti.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vignatti.wordpress.com/osd.xml" title="Tiago Vignatti" />
		<item>
		<title>Improving input latency</title>
		<link>http://vignatti.wordpress.com/2008/07/29/improving-input-latency/</link>
		<comments>http://vignatti.wordpress.com/2008/07/29/improving-input-latency/#comments</comments>
		<pubDate>Wed, 30 Jul 2008 01:09:31 +0000</pubDate>
		<dc:creator>vignatti</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[SoC2008]]></category>
		<category><![CDATA[evdev]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[latency]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[thread]]></category>
		<category><![CDATA[vignatti]]></category>
		<category><![CDATA[x]]></category>
		<category><![CDATA[x11]]></category>
		<category><![CDATA[xorg]]></category>

		<guid isPermaLink="false">http://vignatti.wordpress.com/?p=33</guid>
		<description><![CDATA[GSoC summary #1 &#8211; July 29
The current implementation of X Window System relies in a signal scheme  to manage the input event coming from hardware devices. This scheme  frequently get blocked when lot of IO is occurring (for instance, when  the process is swapping in/out). Get blocked means for instance a  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vignatti.wordpress.com&blog=769537&post=33&subd=vignatti&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>GSoC summary #1 &#8211; July 29</p>
<p>The current implementation of X Window System relies in a signal scheme  to manage the input event coming from hardware devices. This scheme  frequently get blocked when lot of IO is occurring (for instance, when  the process is swapping in/out). Get blocked means for instance a  jumping cursor on the screen and in GUI is always desirable to  prioritize the system responsiveness for end users. The human/computer  interface should be smooth and this is the most user visible aspect of a  system.</p>
<p>Besides the need for improvement in system responsiveness, the current  design of the event stream has some oddities, probably due historical  reasons, such as the cursor update done in user-space or the huge path  that takes to draw the cursor instead just connect the mouse hardware  directly with the cursor position update in-kernel. Moreover there is no  fundamental reason to input drivers be dependent of DDX part of the X  server. Therefore a design of the input subsystem must be carefully  redone to improve such issues.</p>
<p>Our project try to solve all this problems. In summary the goal is: to  get a path from hardware input event to client delivery that cannot be  blocked by rendering or IO operations, meaning we always have very low  latency on input events. Moreover, a redesign of such event stream could  improve the overall X graphics stack, which must be considered as well.</p>
<p>So far three strategies were explored to achieve the goal:</p>
<p>1. put X input generation stage in a separate thread</p>
<p>2. put X input generation and processing stages others threads</p>
<p>3. shortcut the kernel input layer with drm to decrease the cursor  update latency</p>
<p>Basically 1. and 2. tries to solve the issue of blocking signals and 3.  would be a completely redesign in input infrastructure. Anyway, the 3.  strategy would impact in 1. and 2. but these could be implemented in  parallel with the third strategy. The following sections details each  strategy.</p>
<p>== strategy #1 ==</p>
<p>Strategy 1 does not uses a signal handler anymore to wake up the event generation code. It simply poll for device&#8217;s socket and giving that this  code is under a separate thread this is a win for the CPUs.</p>
<p>With the separate thread taking care only the input code, it was  expected that the cursor footprint always lived on resident memory when  the mouse stills in movement. Unfortunately this was not true. For some  reason it swaps back to disk. Maybe some scheduler adjusts would help  here. A memory lock scheme was tried to do lock the cursor footprint  always in physical memory without success.</p>
<p>This strategy is basically what we&#8217;ve been done is the first GSoC. This  is pretty much implemented. It would not require much trouble to push it  to X server from upstream. The code is here:<br />
<a class="moz-txt-link-freetext" href="http://cgit.freedesktop.org/%7Evignatti/xserver/">http://cgit.freedesktop.org/~vignatti/xserver/</a></p>
<p>== strategy #2 ==</p>
<p>This strategy can be thought as an improvement of #1. It can be  separated in two models of implementation:</p>
<p>Model one:</p>
<p>thread #1 deals with<br />
- injection and processing of input events<br />
thread #2 deals with<br />
- requests from known clients<br />
- new client that tries to connect</p>
<p>It would be very very nice to let both threads totally independents. But  we cannot. The event delivery depends on window structure and the first  thread must always wake up the second. Also, sometimes the processing of  events take a while and the injection of events stays stucked in this  model. So we came with this another:</p>
<p>Model two:</p>
<p>thread #1 deals with<br />
- injection of input events from devices<br />
thread #2 deals with<br />
- processing of input events to clients<br />
thread #3 deals with<br />
- requests from known clients<br />
- new client that tries to connect</p>
<p>With this model the first and the second thread become not so tied and  given that we&#8217;re using non blocking fds to wake up each thread (through  a pipe), CPU &#8220;enjoys&#8221; the effect of threads. For instance, under heavy  drawing primitives only thread #3 would wake up.</p>
<p>We had a proof-of-concept of this last model and it workish  (occasionally seeing some segfaults probably due of some critical  regions we forgot to lock &#8211; now the only mutex that exists is inside the  server queue of events).</p>
<p>It&#8217;s hard to imagine other threaded models mainly because the way X  deals with clients are very tied in every piece of the server and it  would require a lot of mutexes.</p>
<p>== strategy #3 ==</p>
<p>For sure this strategy is the most shocking one :) The idea is to  connect the mouse hardware directly to the cursor position update  function, all inside kernel. We&#8217;d then rewrite the event stream from the  pointer device to an absolute position. Transform the relative mouse  motion into an absolute screen position seems to be not that  complicated, but this strategy would involve acceleration and cursor  limits inside kernel as well (the current implementation of accel deals  with floats, so we would have to adapt it to live in kernel).</p>
<p>It is a <span class="moz-txt-underscore"><span class="moz-txt-tag">_</span>very<span class="moz-txt-tag">_</span></span> <span class="moz-txt-underscore"><span class="moz-txt-tag">_</span>large<span class="moz-txt-tag">_</span></span> amount of codification. It would require changes  to the X server, DDX driver and its corresponding kernel DRM drivers,  drm library and kernel input drivers. A mini-input driver <strong class="moz-txt-star"><span class="moz-txt-tag">*</span>inside<span class="moz-txt-tag">*</span></strong> drm  is also needed. We would add complexities of the connection between  input device and output device to the kernel (in my proof-of-concept  implementation evdev is dependent of drm. Yeah, really weird world).  Moreover, we would have to avoid somehow two differents sets of the  exact same code in different contexts in the case of sw cursors (think  MPX). It&#8217;s a completely redesign. Things would have to go incrementally.</p>
<p>But why this strategy? Well, this would solve all the current issues  with input latency. For instance with the current design of the kernel  modesetting &#8211; which seems the future &#8211; the cursor is jumping a lot, much  more than with current implementation. Try to call a xrandr instance and  move the mouse with kernel modesetting. xrandr will do DDC communication  which will blocked X in the kernel. So with the handling and update of  the cursor inside the kernel all would work fine (and my  proof-of-concept already showed this).</p>
<p>Moreover, I believe the current implementation remained until now due historical reasons. Ultrix systems placed the entire input subsystem in  the kernel. What is the problem to do this in Linux (and others) as well (besides massive codification)?</p>
<p>and non-dri drivers? Should we forget them?</p>
<p>EOF</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/vignatti.wordpress.com/33/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/vignatti.wordpress.com/33/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vignatti.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vignatti.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vignatti.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vignatti.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vignatti.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vignatti.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vignatti.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vignatti.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vignatti.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vignatti.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vignatti.wordpress.com&blog=769537&post=33&subd=vignatti&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://vignatti.wordpress.com/2008/07/29/improving-input-latency/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c80e0b79eb21bbd134add2362d74f4ce?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vignatti</media:title>
		</media:content>
	</item>
	</channel>
</rss>