comp windows x getting more performance out of x faq archive name x faq speedups last modified how to maximize the performance of x monthly posting compiled by art mulder art cs ualberta ca more ram faster cpu s more disk space faster ethernet these are the standard responses you hear when you ask how to improve the performance of your workstation well more hardware isn t always an option and i wonder if more hardware is always even a necessity this faq list is a collection of suggestions and ideas from different people on the net on how you can the best possible performance from x windows on your workstation without purchasing more hardware performance is a highly subjective issue the individual user must balance speed versus features in order to come to a personal decision therefore this document can be be expected to contain many subjective opinions in and amongst the objective facts this document is specifically concerned with x there are of course many other factors that can affect the performance of a workstation however they are outside the scope of this document people seriously interested in the whole area of system performance might want to look at the o reilly nutshell handbook system performance tuning by mike loukides imho it contains a well written comprehensive treatment of system performance i m unaware of any other similar books ed table of contents introduction administrivia what about the other x faq window managers the x server which server locking the server into ram starting your server fonts about the resources file define your display properly clients a better clock for x a better terminal emulator for x tuning your client miscellaneous suggestions pretty pictures a quicker mouse programming thoughts say what other sources of information author notes changed since last issue new since last issue introduction administrivia this document is posted each month on or around the th to the usenet news groups comp windows x news answers and comp answers if you are reading a copy of this faq which is more than a few months old see the last modified date above you should probably locate the latest edition since the information may be outdated if you do not know how to get those newsgroups and or your site does not receive them and or this article has already expired you can retrieve this faq from an archive site there exist several usenet faq archive sites to find out more about them and how to access them please see the introduction to the news answers newsgroup posting in news answers the main faq archive is at rtfm mit edu this document can be found there in pub usenet news answers x faq speedups if you do not have access to anonymous ftp you can retrieve it by sending a mail message to mail server rtfm mit edu with the command send usenet news answers x faq speedups in the message body what about the other x faq david b lewis faq craft uunet uu net maintains the informative and well written comp windows x frequently asked questions document its focus is on general x information while this faq concentrates on performance the comp windows x faq does address the issue of speed but only with regards to the x server the gist of that topic seems to be use x r it is faster than r please see the x faq for complete details window managers there are a lot of window managers out there with lots of different features and abilities the choice of which to use is by necessity a balancing act between performance and useful features at this point most respondents have agreed upon twm as the best candidate for a speedy window manager a couple of generic tricks you can try to soup up your window manger is turning off unnecessary things like zooming and opaque move also if you lay out your windows in a tiled manner you reduce the amount of cpu power spent in raising and lowering overlapping windows joe english joe trystero art com i ve found that a good font for tiling is x aka misc fixed medium r normal c iso it is the biggest font i know of that i can use on my sun x screen and still get two column terminal windows side by side on the display with no overlap other font suggestions will be accepted the x server which server make sure that your server is a proper match for your hardware if you have a monochrome monitor use a monochrome x server on my monochrome sun i haven t noticed much difference between the xsun colour server and xsunmono however it was pointed out to me that xsunmono is about k smaller and therefore should contribute to less paging thanks to jonny farringdon j farringdon psychol ucl ac uk michael salmon michael salmon eos ericsson se how your server was compiled can also make a difference jeff law law schirf cs utah edu advises us that on a sun system x should be compiled with gcc version or with the unbundled sun compiler you can expect to get very large speedups in the server by not using the bundled sunos compiler i assume that similar results would occur if you used one of the other high quality commercial compilers on the market locking the server into ram has anyone tried hacking the x server so that it is locked into ram and does not get paged eg via a call to plock does this help performance at all i ve had one inquiry on this topic and a few pointers to the plock function call but no hard evidence from someone who s tried it i am not in a position to give it a try thanks to eric c claeys ecc eperm att com danny backx db sunbim be juan d martin juando cnm us es starting your server joe english joe trystero art com if you start up a lot of clients in your xsession or whatever sleep for a second or two after launching each one after i changed my xclients script to do this logging in actually took less time we have a heavily loaded system without much core though this sounds crazy but i have confirmed that it works warner losh imp solbourne com provided me with a good explanation of why this works which i have summarized here when you start up an x server it takes a huge amount of time to start accepting connections a lot of initialization is done by the server when it starts this process touches a large number of pages any other process running at the same time would fight the server for use of the cpu and more importantly memory if you put a sleep in there you give the server a chance to get itself sorted out before the clients start up similarly there is also a lot of initialization whenever an x client program starts toolkits registering widgets resources being fetched programs initializing state and databases and so forth all this activity is typically memory intensive once this initialization is done the process has reached a steady state the memory usage typically settles down to using only a few pages by using sleeps to stagger the launching of your clients in your xinitrc you avoid them fighting each other for your workstation s limited resources this is most definitely a your mileage may vary situation as there are so many variables to be considered available ram local swap space load average number of users on your system which clients you are starting etc currently in my xinitrc i have a situation like sleep exec xclock sleep exec xbiff sleep exec xterm sleep exec xterm i ve experimented with sleep exec xclock sleep exec xbiff sleep exec xterm sleep exec xterm i ve even tried sleep exec start x clients script and then in start x clients script i had sleep exec xclock sleep exec xbiff sleep exec xterm sleep exec xterm the idea with this last one was to make sure that xinit had completely finished processing my xinitrc and had settled down into a steady state before the sleep expired and all my clients were launched all of these yielded fairly comparable results and so i just stuck with my current setup for its simplicity you will probably have to experiment a bit to find a setup which suits you fonts loading fonts takes time and ram if you minimize the number of fonts your applications use you ll get speed increases in load up time one simple strategy is to choose a small number of fonts one small one large one roman whatever suits you and configure all your clients or at least all your heavily used clients to use only those few fonts client programs should start up quicker if their font is already loaded into the server this will also conserve server resources since fewer fonts will be loaded by the server farrell mckay fbm ptcburp ptcbu oz au joe english joe trystero art com eg my main xterm font is x so i also have twm set up to use x in all it s menus and icons etc twm s default font is x since i don t normally use x i ve eliminated one font from my server oliver jones oj roadrunner pictel com keep fonts local to the workstation rather than loading them over nfs if you will make extensive use of r scalable fonts use a font server about the resources file keep your xresources xdefaults file small saves ram and saves on server startup time joe english joe trystero art com one suggestion in your xdefaults xresources file try putting only the minimum number of resources that you want to have available to all of your applications for example reversevideo true then separate your resources into individual client specific resource files for example home lib app defaults in your login file set the environment variable xuserfilesearchpath setenv xuserfilesearchpath home lib app defaults n the comp windows x frequently asked questions faq contains an excellent explanation of how these environment variables work ed so when xterm launches it loads its resources from app defaults xterm xdvi finds them in app defaults xdvi and so on and so forth note that not all clients follow the same xxxxx resource file naming pattern you can check in your system app defaults directory often usr x r lib x app defaults to find the proper name and then name your personal resource files with the same name this is all documented in the xt specification pg thanks to kevin samborn samborn mtkgc com michael urban urban cobra jpl nasa gov and mike long mikel ee cornell edu kevin is willing mail his setup files to inquirers this method of organizing your personal resources has the following benefits easier to maintain more usable fewer resources are stored in the x server in the resource manager property as a side benefit your server may start fractionally quicker since it doesn t have to load all your resources applications only process their own resources never have to sort through all of your resources to find the ones that affect them it also has drawbacks the application that you are interested in has to load an additional file every time it starts up this doesn t seem to make that much of a performance difference and you might consider this a huge boon to usability if you are modifying an application s resource database you just need to re run the application without having to xrdb again xrdb will by default run your xdefaults file through cpp when your resources are split out into multiple resource files and then loaded by the individual client programs they will not watch out for this i had c style comments in my xdefaults file which cpp stripped out when i switched to this method of distributed resource files i spent several frustrating days trying to figure out why my clients were not finding their resources xt did not provide any error message when it encountered the c style comments in the resource files it simply silently aborted processing the resource file the loss of preprocessing which can be very handy e g ifdef color is enough to cause some people to dismiss this method of resource management you may also run into some clients which break the rules for example neither emacs nor xvt will find their resources if they are anywhere other than in xdefaults when starting up a client on a machine that does not share files with the machine where your resources are stored your client will not find its resources loading all your resources into the server will guarantee that all of your clients will always find their resources casey leedom casey gauss llnl gov a possible compromise suggestion that i have and am planning on trying is to put resources for all my heavily used clients eg xterm into my xdefaults file and to use the separate resources files method for clients that i seldom use define your display properly client programs are often executed on the same machine as the server in that situation rather than setting your display environment variable to hostname where hostname is the name of your workstation you should set your display variable to unix or by doing this you access optimized routines that know that the server is on the same machine and use a shared memory method of transferring requests thanks to patrick j horgan pjh ras amdahl com see the display names section of the x man page for further explanation of how to properly set your display name i don t think it s stock mit but at least data general and hp have libraries that are smart enough to use local communication even when the display isn t set specially rob sartin opensi sartin uunet uu net jody goldberg jody algorithmics com sent me an xlib patch to change stock r to use local communication even if display is not properly set i don t want to get in the business of distributing or trying to juggle non mit patches and so have elected not to include it here hopefully mit will apply this minor lines patch themselves in the meantime if you want to try it yourself email jody ed clients if you only have a few megabytes of ram then you should think carefully about the number of programs you are running think also about the kind of programs you are running for example is there a smaller clock program than xclock unfortunately i haven t really noticed that programs advertise how large they are so the onus is on us to do the research and spread the word suggestions on better alternatives to the some of the standard clients eg xclock xterm xbiff are welcome ed i ve received some contradictory advice from people on the subject of x client programs some advocate the use of programs that are strictly xlib based since xt xaw and other toolkits are rather large others warn us that other applications which you are using may have already loaded up one or more of these shared libraries in this case using a non xt for example client program may actually increase the amount of ram consumed the upshot of all this seems to be don t mix toolkits that is try and use just athena clients or just xview clients or just motif clients etc if you use more than one then you re dragging in more than one toolkit library know your environment and think carefully about which client programs would work best together in that environment thanks to rob sartin opensi sartin uunet uu net duncan sinclair sinclair dcs gla ac uk sinclair uk ac gla dcs a better clock for x xcuckoo suggested by duncan sinclair sinclair dcs gla ac uk available on export lcs mit edu xcuckoo displays a clock in the title bar of another program saves screen real estate mclock suggested by der mouse mouse lightning mcrcim mcgill edu available larry mcrcim mcgill edu in x mclock shar non xt based extensively configurable it can be made to look very much like mit oclock or mostly like xclock purely by changing resources of course the ultimate clock one that consumes no resources and takes up no screen real estate is the one that hangs on your wall a better terminal emulator for x from the readme file distributed with xterm abandon all hope ye who enter here this is undoubtedly the most ugly program in the distribution ugly maybe but at my site it s still the most used i suspect that xterm is one of the most used clients at many if not most sites laziness isn t there a better terminal emulator available see below if you must use xterm you can try reducing the number of savelines to reduce memory usage oliver jones oj roadrunner pictel com jonny farringdon j farringdon psychol ucl ac uk xvt suggested by richard hesketh rlh ukc ac uk available export lcs mit edu in contrib xvt tar z if you don t need all the esoteric features of xterm then get hold of xvt it was written here just to save swap space as xterm is rather a hog this was written as a partial clone of xterm you don t have to rename your resources as xvt pretends to be xterm in it s current version you cannot bind keys as you can in xterm i ve heard that there are versions of xvt with this feature but i ve not found any yet update march i recently had a few email conversations with brian warkentin brian warkentine eng sun com regarding xvt he questions whether xvt really is at all faster than xterm for instance xvt may initialize slightly faster but compare scrolling speed try this quickie benchmark bin time dd if etc termcap bs and see which program can scroll faster also while xterm may be slightly larger in ram requirements we don t have any hard numbers here does anyone else shared libraries and shared text segments mean that xterm s paging requirements are not that major as an experiment he ripped out all the tek stuff from xterm but it made little difference since if you never use it it never gets brought into memory so here we stand with some conflicting reports on the validity of xvt over xterm in summary caveat emptor your mileage may vary if you can provide some hard data i d like to see it specifically how much ram each occupies how much swap each needs relative speed of each mterm suggested by der mouse mouse lightning mcrcim mcgill edu available larry mcrcim mcgill edu in x mterm src mterm ball o wax i also have my own terminal emulator its major lack is scrollback but some people like it anyway tuning your client suggestions on how you can tune your client programs to work faster from scott barman scott asd com comes a suggestion regarding motif text field widgets i noticed that during data entry into motif text field widgets i was getting a slight lag in response to some keystrokes particularly the initial one in the field examining the what was going on with xscope i found it it seems that when the resource xmnblinkrate is non zero and the focus is on a text field widget or even just a text widget the i beam cursor will blink every time the cursor appears or disappears in those widgets the widget code is making a request to the server copyarea the user can stop this by setting the resource xmnblinkrate to it is not noticeable on a mhz sparc but it does make a little difference on a slower system this specific suggestion can probably be applied in general to lots of areas consider your heavily used clients are there any minor embellishments that can be turned off and thereby save on server requests miscellaneous suggestions pretty pictures don t use large bitmaps gif s etc as root window backgrounds the more complicated your root window bitmap the slower the server is at redrawing your screen when you reposition windows or redraw etc these take up ram and cpu power i work on a sun sparc and i m conscious of performance issues i can t comprehend it when i see people with a mb sun running xphoon as their root window i ll let someone else figure out how much ram would be occupied by having a full screen root image on a colour workstation if you re anything like me you need all the screen real estate that you can get for clients and so rarely see the root window anyway thanks to qiang alex zhao azhao cs arizona edu for reminding me of this one ed a quicker mouse using xset you can adjust how fast your pointer moves on the screen when you move your mouse i use xset m in my xinitrc file which lets me send my pointer across the screen with just a flick of the wrist see the xset man page for further ideas and information hint sometimes you may want to slow down your mouse tracking for fine work to cover my options i have placed a number of different mouse setting commands into a menu in my window manager e g for twm menu mouse settings mouse settings f title very fast xset m normal fast xset m system default un accelerated xset m default glacial xset m programming thoughts joe english joe trystero art com to speed up applications that you re developing there are tons of things you can do some that stick out for motif programs don t set xmfontlist resources for individual buttons labels lists et al use the defaultfontlist or labelfontlist or whatever resource of the highest level manager widget again stick to as few fonts as possible better yet don t use motif at all it s an absolute pig don t create and destroy widgets on the fly try to reuse them this will avoid many problems with buggy toolkits too use a line width of in gcs on some servers this makes a huge difference compress and collapse multiple expose events this can make the difference between a fast application and a completely unusable one francois staes frans kiwi uia ac be just a small remark i once heard that using a better malloc function would greatly increase performance of xt based applications since they use malloc heavily they suggested trying out the gnuy malloc but i didn t find the time yet i did some tests on small programs just doing malloc and free and the differences were indeed very noticeable somewhat times faster any confirmation on this from anyone ed andre beck andre beck irs inf tu dresden de unnecessary noexpose events most people use xcopyarea xcopyplane as fastest blit routines but they forget to reset graphics exposures in the gc used for the blits this will cause a noexpose event every blit that in most cases only puts load onto the connection and forces the client to run through it s event loop again and again thousands of xchangegc requests this gfx context switching is also seen in most handcoded x apps where only one or few gcs are created and then heavily changed again and again xt uses a definitely better mechanism by caching and sharing a lot of gcs with all needed parameters this will remove the load of subsequent xchangegc requests from the connection by moving it toward the client startup phase say what some contributors proposed ideas that seem right off the wall at first david b lewis by day dbl osf org by night david craft uunet uu net how about this swap displays with someone else run all your programs on the other machine and display locally the other user runs off your machine onto the other display goal reduce context switches in the same operation between client and server i m not in a situation where i can easily try this but i have received the following confirmation michael salmon michael salmon eos ericsson se i regularly run programs on other machines and i notice a big difference i try to run on a machine where i will reduce net usage and usually with nice to reduce the impact of my intrusion this helps a lot on my poor little ss with only mb it was essential when i only had mb casey leedom casey gauss llnl gov the x server and the client are competing for the same cpu as your server when you run it on the same machine not really a major problem except that the x client and the server are in absolute synchronicity and are context thrashing timothy h panton thp westhawk uucp firstly it relies on the fact that most cpu s are mostly idle x s cpu usage is bursty so the chances of you and your teammate doing something cpu intensive at the same time is small if they are not then you get twice the cpu memory available for your action the second factor is that context switches are expensive using cpu s halves them you pay a price due to the overhead of going over the network but this is offset in most cases by the improved buffering of a network typically k vs k for a pipe allowing even fewer context switches other sources of information volume in o reilly s x window system series x window system administrator s guide is a book all x administrator s should read adrian nye adrian ora com a lot more tips on performance are in the paper improving x application performance by chris d peterson and sharon chang in issue of the x resource an earlier version of this paper appeared in the xhibition conference proceedings this paper is absolutely essential reading for x programmers author notes this list is currently maintained by art mulder art cs ualberta ca suggestions corrections or submission for inclusion in this list are gladly accepted layout suggestions and comments spelling mistak s too are also welcome currently i have listed all contributors of the various comments and suggestions if you do not want to be credited please tell me speedup x faq is copyright c by arthur e mulder you may copy this document in whole or in part as long as you don t try to make money off it or pretend that you wrote it art mulder art cs ualberta ca do not be conformed to this world department of computing science but be transformed by the renewal university of alberta edmonton canada of your mind romans
