<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>( vs. r1.1) ImprovingPerformance &lt; Cinelerra &lt; TWiki</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="robots" content="noindex" />
<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="http://www.ftconsult.com/twiki/bin/view/Cinelerra/WebRss?skin=rss&contenttype=text/xml" />
<!-- <base href="../../view/Cinelerra/ImprovingPerformance" /> -->
<style type="text/css" media="all">
	/* Default TWiki layout */
	@import url('../../../pub/TWiki/PatternSkin/layout.css');
	/* Default TWiki style */
	@import url('../../../pub/TWiki/PatternSkin/style.css');
	/* Custom overriding layout per web or per topic */
	@import url('http://www.ftconsult.com/twiki/bin/view/Cinelerra/%USERLAYOUTURL%');
	/* Custom overriding style per web or per topic */
	@import url('http://www.ftconsult.com/twiki/bin/view/Cinelerra/%USERSTYLEURL%');
	.twikiToc li {
		list-style-image:url('../../../pub/TWiki/PatternSkin/i_arrow_down.gif');
	}	        
	.twikiWebIndicator {
		background-color:#D0D0D0;
	}
</style>
<style type="text/css" media="all"></style>
<script type="text/javascript">
<!-- HIDE
	function initPage() { }
-->
</script>
</head>
<body class="twikiNoViewPage twikiDiffPage"><a name="PageTop"></a>
<div class="twikiMiddleContainer"><div class="twikiMain"><div class="twikiSearchResults"><div class="twikiSearchResultsHeader">&nbsp;<tt><b>&lt;&lt;O&gt;&gt;</b></tt>&nbsp; Difference Topic
		<b><a href="../../view/Cinelerra/ImprovingPerformance">ImprovingPerformance</a></b>
		(<a href="http://www.ftconsult.com/twiki/bin/view/Cinelerra/ImprovingPerformance?rev=r1.1">r1.1</a> - 18&nbsp;Dec&nbsp;2003 - <a class="twikiLink" href="../../view/Main/AlexFerrer">AlexFerrer</a>)</div>
<table class="twikiDiffTable" width="100%" cellspacing="0">
<tr bgcolor="#eeeeee" class="twikiDiffLineNumberHeader"><th align="left" colspan="9">Line: 1 to 1</th></tr>
<tr><td bgcolor="#D0FFD0" class="twikiDiffAddedHeader" colspan ="9"><b> Added:   </b>
</td></tr>
<tr><td bgcolor="#ccccff" class="twikiDiffAddedMarker" valign="top" width="1%">&gt;<br />&gt;</td>
<td class="twikiDiffAddedText">
<h3><a name="Improving_Performance"> </a><a name="_Improving_Performance_"> </a> <a class="twikiLink" href="../../view/Cinelerra/ImprovingPerformance">Improving Performance</a> </h3>
<p />
There are a number of parameters on Linux, which ordinary people can adjust to improve it's performance.
<p />
<div class="twikiToc">
<ul>
<li> <a href="#Improving_Performance">Improving Performance</a>
<ul>
<li> <a href="#DISABLING_SWAP_SPACE">DISABLING SWAP SPACE:</a>
</li>
<li> <a href="#ENLARGING_SOUND_BUFFERS">ENLARGING SOUND BUFFERS:</a>
</li>
<li> <a href="#FREEING_MORE_SHARED_MEMORY">FREEING MORE SHARED MEMORY</a>
</li>
<li> <a href="#SPEEDING_UP_THE_HARD_DRIVE">SPEEDING UP THE HARD DRIVE</a>
</li>
<li> <a href="#DISABLING_CRON">DISABLING CRON</a>
</li>
<li> <a href="#REDUCING_USB_MOUSE_SENSITIVITY">REDUCING USB MOUSE SENSITIVITY</a>
</li>
<li> <a href="#ASSORTED_X_TWEEKS">ASSORTED X TWEEKS</a>
</li>
<li> <a href="#SPEEDING_UP_THE_FILE_SYSTEM">SPEEDING UP THE FILE SYSTEM</a>
</li>
<li> <a href="#IMPROVING_ZORAN_VIDEO">IMPROVING ZORAN VIDEO</a>
</li>
</ul>
</li>
</ul>
</div>
<p />
<p />
<h4><a name="DISABLING_SWAP_SPACE"> </a><a name="DISABLING_SWAP_SPACE_"> </a> DISABLING SWAP SPACE: </h4>
On systems with lots of memory, Cinelerra sometimes runs better without a swap space. If you have 4 GB of RAM, you're probably better off without a swap space. If you have 512MB of RAM, you should keep the swap. If you want to do recording, you should probably disable swap space in any case. There's a reason for this. Linux only allows half the available memory to be used. Beyond that, it starts searching for free pages to swap, in order to cache more disk access. In a 4 GB system, you start waiting for page swaps after using only 2 GB.
<p />
The question then is how to make Linux run without a swap space. Theoretically it should be a matter of running
<p />
     swapoff -a
<p />
<p />
Unfortunately, without a swap space the kswapd tasklet normally spins at 100%. To eliminate this problem, edit linux/mm/vmscan.c. In this file, put a line saying return 0; before it says
<pre>
        /*
         * Kswapd main loop.
         */   
</pre>
Then recompile the kernel.
<p />
<h4><a name="ENLARGING_SOUND_BUFFERS"> </a><a name="ENLARGING_SOUND_BUFFERS_"> </a> ENLARGING SOUND BUFFERS: </h4>
<p />
In order to improve realtime performance, the audio buffers for all the Linux sound drivers were limited from 128k to 64k. For recording audio and video simultaneously and for most audio recording this causes dropouts. Application of low latency and preemtible kernel patches make it possible to record more audio recordings but it doesn't improve recording video with audio. This is where you need to hack the kernel.
<p />
To see if your sound buffers are suitable, run the included soundtest program with nothing playing or recording. This allocates the largest possible buffers and displays them. If the TOTAL BYTES AVAILABLE is under 131072, you need to see about getting the buffers enlarged in the driver. While many drivers differ, we have a hack for at least one driver.
<p />
This only applies to the OSS version of the Soundblaster Live driver. Since every sound card and every sound driver derivative has a different implementation you'll need to do some searching for other sound cards. Edit linux/drivers/sound/emu10k1/audio.c
<p />
Where is says
<p />
     if (bufsize &gt;= 0x10000)
<p />
<p />
change it to say
<p />
     if (bufsize &gt; 0x40000)
<p />
<p />
Where is says
<pre>
           for (i = 0; i &lt; 8; i++)
              for (j = 0; j &lt; 4; j++)
</pre>
<p />
change it to say
<pre>
           for (i = 0; i &lt; 16; i++)
              for (j = 0; j &lt; 4; j++)
</pre>
<p />
In linux/drivers/sound/emu10k1/hwaccess.h
<p />
Change
<p />
#define MAXBUFSIZE 65536
<p />
to
<p />
#define MAXBUFSIZE 262144
<p />
Finally, in linux/drivers/sound/emu10k1/cardwi.h
<p />
#define WAVEIN_MAXBUFSIZE 65536
<p />
to
<p />
#define WAVEIN_MAXBUFSIZE 262144
<p />
Then recompile the kernel modules.
<p />
<h4><a name="FREEING_MORE_SHARED_MEMORY"> </a> FREEING MORE SHARED MEMORY </h4>
<p />
The Linux kernel only allows 32MB of shared memory to be allocated by default. This needs to be increased to do anything useful. Run the following command:
<p />
echo "0x7fffffff" &gt; /proc/sys/kernel/shmmax
<p />
<h4><a name="SPEEDING_UP_THE_HARD_DRIVE"> </a> SPEEDING UP THE HARD DRIVE </h4>
<p />
This is a very popular command sequence among Linux gurus, which is not done by default on Linux distributions.
<p />
hdparm -c3 -d1 -u1 -k1 /dev/hda
<p />
   *-c3 puts the hard drive into 32 bit I/O with sync. This normally doesn't work due to inept kernel support for most IDE controllers. If you get lost interrupt or <span class="twikiNewLink" style="background : #FFFFCE;"><font color="#0000FF">SeekComplete</font><a href="http://www.ftconsult.com/twiki/bin/edit/Cinelerra/SeekComplete?topicparent=Cinelerra.ImprovingPerformance"><sup>?</sup></a></span> errors, quickly use -c0 instead of -c3 in your command.
<p />
   *-d1 enables DMA of course. This frees up the CPU partially during data transfers.
<p />
   *-u1 allows multiple interrupts to be handled during hard drive transactions. This frees up even more CPU time.
<p />
   *-k1 prevents Linux from resetting your settings in case of a glitch.
<p />
<h4><a name="DISABLING_CRON"> </a> DISABLING CRON </h4>
<p />
Linux runs some daily operations like compressing man pages. These may be acceptable background tasks while compiling or word processing but not while playing video. Disable these operations by editing /etc/rc.d/init.d/anacron.
<p />
Put exit before the first line not beginning in #.
<p />
In /etc/rc.d/init.d/crond put exit before the first line not beginning in #. Then make like Win 2000 and reboot.
<p />
You can't use the at command anymore, but who uses that command anyways?
<p />
<h4><a name="REDUCING_USB_MOUSE_SENSITIVITY"> </a> REDUCING USB MOUSE SENSITIVITY </h4>
<p />
Gamers like high resolution mice, but this can be painful for precisely positioning the mouse on a timeline or video screen. XFree86 once allowed you to reduce PS/2 mouse sensitivity using commands like xset m 1 1 but you're out of luck with USB mice or KVM's.
<p />
We have a way to reduce USB mouse sensitivity. Edit /usr/src/linux/drivers/input/mousedev.c.
<p />
After the line saying
<p />
     struct mousedev_list {
<p />
<p />
put
<pre>
     #define DOWNSAMPLE_N 100
     #define DOWNSAMPLE_D 350
     int x_accum, y_accum;
</pre>
<p />
Next, the section which says something like:
<pre>
     case EV_REL:
        switch (code) {
           case REL_X:   list-&gt;dx += value; break;
           case REL_Y:   list-&gt;dy -= value; break;
           case REL_WHEEL:   if (list-&gt;mode) list-&gt;dz -= value; break;
        }
        break;
     
</pre>
must be replaced by
<pre>
     
     case EV_REL:
        switch (code) {
           case REL_X:
              list-&gt;x_accum += value * DOWNSAMPLE_N;
              list-&gt;dx += (int)list-&gt;x_accum / (int)DOWNSAMPLE_D;
              list-&gt;x_accum -= ((int)list-&gt;x_accum / (int)DOWNSAMPLE_D) * (int)DOWNSAMPLE_D;
              break;
           case REL_Y:
              list-&gt;y_accum += value * DOWNSAMPLE_N;
              list-&gt;dy -= (int)list-&gt;y_accum / (int)DOWNSAMPLE_D;
              list-&gt;y_accum -= ((int)list-&gt;y_accum / (int)DOWNSAMPLE_D) * (int)DOWNSAMPLE_D;
              break;
           case REL_WHEEL:   if (list-&gt;mode) list-&gt;dz -= value; break;
        }
        break;
</pre>
<p />
Change the value of DOWNSAMPLE_N to change the mouse sensitivity.
<p />
<h4><a name="ASSORTED_X_TWEEKS"> </a> ASSORTED X TWEEKS </h4>
<p />
XFree86 by default can't display Cinelerra's advanced pixmap rendering very fast. The X server stalls during list box drawing. Fix this by adding a line to your XF86Config* files.
<p />
In the Section "Device" area, add a line saying:
<p />
Option "XaaNoOffscreenPixmaps"
<p />
and restart the X server.
<p />
Screen blanking is really annoying, unless you're fabulously rich and can afford to leave your monitor on 24 hours a day without power saving mode. In /etc/X11/xinit/xinitrc put
<p />
     xset s off
     xset s noblank
<p />
<p />
before the first if statement.
<p />
How about those windows keys which no Linux distribution even thinks to use. You can make the window keys provide ALT functionality by editing /etc/X11/Xmodmap. Append the following to it.
<p />
     keycode 115 = Hyper_L
     keycode 116 = Hyper_R
     add mod4 = Hyper_L
     add mod5 = Hyper_R
<p />
<p />
The actual changes to a window manager to make it recognize window keys for ALT are complex. In FVWM at least, you can edit /etc/X11/fvwm/system.fvwm2rc and put
<p />
     Mouse 0 T A move-and-raise-or-raiselower
     #Mouse 0 W M move
     Mouse 0 W 4 move
     Mouse 0 W 5 move
     Mouse 0 F A resize-or-raiselower
     Mouse 0 S A resize-or-raiselower
<p />
<p />
in place of the default section for moving and resizing. Your best performance is going to be on FVWM. Other window managers seem to slow down video with extra event trapping and aren't as efficient in layout.
<p />
<h4><a name="SPEEDING_UP_THE_FILE_SYSTEM"> </a> SPEEDING UP THE FILE SYSTEM </h4>
<p />
You'll often store video on an expensive, gigantic disk array separate from your boot disk. You'll thus have to manually install an EXT filesystem on this disk array, using the mke2fs command. By far the fastest file system is
<p />
<p />
     mke2fs -i 65536 -b 4096 my_device
     tune2fs -r0 -c10000 my_device
<p />
<p />
<p />
This has no journaling, reserves as few blocks as possible for filenames, and accesses the largest amount of data per block possible. A slightly slower file system, which is easier to recover after power failures is
<p />
<p />
     mke2fs -j -i 65536 -b 4096 my_device
     tune2fs -r0 -c10000 my_device
<p />
<p />
<p />
This adds a journal which slows down the writes but makes us immune to power failures.
<p />
<h4><a name="IMPROVING_ZORAN_VIDEO"> </a> IMPROVING ZORAN VIDEO </h4>
<p />
Video recorded from the ZORAN inputs is normally unaligned or not completely encoded on the right. This can be slightly compensated by adjusting parameters in the driver sourcecode.
<p />
In /usr/src/linux/drivers/media/video/zr36067.c the structures defined near line 623 affect alignment. At least for NTSC, the 2.4.20 version of the driver could be improved by changing
<p />
     static struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 16 };
<p />
<p />
to
<p />
     static struct tvnorm f60ccir601 = { 858, 720, 57, 788, 525, 480, 17 };
<p />
<p />
In /usr/src/linux/drivers/media/video/bt819.c more structures near line 76 affect alignment and encoding.
<p />
For NTSC
<p />
     {858 - 24, 2, 523, 1, 0x00f8, 0x0000},
<p />
<p />
could be changed to
<p />
     {868 - 24, 2, 523, 1, 0x00f8, 0x0000},
<p />
<p />
Adjusting these parameters may or may not improve your picture. More of the time, they'll cause the driver to lock up before capturing the first frame.
<p />
<p />
<p />
-- <a class="twikiLink" href="../../view/Main/AlexFerrer">AlexFerrer</a> - 18 Dec 2003 From <a class="twikiLink" href="../../view/Cinelerra/SecretsOfCinelerra">SecretsOfCinelerra</a>
<hr />
</td></tr>

</table></div><div class="twikiTopicAction"><a href="../../view/Cinelerra/ImprovingPerformance">View topic</a>
 <span class="twikiSeparator">|</span> <a href="ImprovingPerformance">Diffs</a>  | <a href="http://www.ftconsult.com/twiki/bin/view/Cinelerra/ImprovingPerformance?rev=1.1">r1.1</a>
 <span class="twikiSeparator">|</span> <a href="http://www.ftconsult.com/twiki/bin/oops/Cinelerra/ImprovingPerformance?template=oopsmore&param1=1.1&param2=1.1">More</a>
</div><div class="twikiTopicInfo"><span class="twikiRevInfo twikiGrayText">Revision  - <br />
Revision r1.1 - 18 Dec 2003 - 19:33 - <a class="twikiLink" href="../../view/Main/AlexFerrer">AlexFerrer</a></span></div>
<div class="twikiTopicFooter"></div>
<a name="PageBottom"></a> </div></div>
</body></html>