From owner-freebsd-x11@FreeBSD.ORG Mon Feb 25 20:11:17 2008 Return-Path: Delivered-To: freebsd-x11@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7639616A404 for ; Mon, 25 Feb 2008 20:11:17 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.delphij.net (delphij-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:2c9::2]) by mx1.freebsd.org (Postfix) with ESMTP id 2845113C4D3 for ; Mon, 25 Feb 2008 20:11:17 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (tarsier.geekcn.org [202.108.54.204]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tarsier.delphij.net (Postfix) with ESMTP id 1601428452 for ; Tue, 26 Feb 2008 04:11:16 +0800 (CST) Received: from localhost (tarsier.geekcn.org [202.108.54.204]) by tarsier.geekcn.org (Postfix) with ESMTP id B66CDEB88EB; Tue, 26 Feb 2008 04:11:15 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([202.108.54.204]) by localhost (mail.geekcn.org [202.108.54.204]) (amavisd-new, port 10024) with ESMTP id lxFoERRy2zsm; Tue, 26 Feb 2008 04:11:10 +0800 (CST) Received: from charlie.delphij.net (71.5.7.139.ptr.us.xo.net [71.5.7.139]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTP id 27B9FEB88E4; Tue, 26 Feb 2008 04:11:09 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:subject:x-enigmail-version:openpgp:content-type:content-transfer-encoding; b=hf5htEWmNfjrkHmxkbjK2hWbnDvjvFXkeXTsG8qs7cX4WcZVLELLXenrQnKkli0px 0bBo1MdXi4WKyQ78Uff1g== Message-ID: <47C320DB.70004@delphij.net> Date: Mon, 25 Feb 2008 12:11:07 -0800 From: Xin LI Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.9 (X11/20080122) MIME-Version: 1.0 To: freebsd-x11@FreeBSD.org X-Enigmail-Version: 0.95.5 OpenPGP: id=18EDEBA0; url=http://www.delphij.net/delphij.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Subject: Xorg vs gettimeofday() and clock_gettime() X-BeenThere: freebsd-x11@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: X11 on FreeBSD -- maintaining and support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Feb 2008 20:11:17 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear colleagues, Recently with the respect of some reports about Xorg with jerky mouse and some "hang"s, I have tried to track down the problem, and it turns out that the culprit was excessive calls of gettimeofday(). As an fast and easy surgery style hack, I have used Robert Watson's wrapper library, as available at: http://www.watson.org/~robert/freebsd/clock/ In order to work around the fact that Xorg server is setuid and therefore will ignore the LD_PRELOAD environment, one has to hack rtld-elf.c at the issetugid() part. With these changes and set the wrapper to work using FAST clocks (which are less expensive), you can see Xorg's CPU consumption will drop sharply, and the hang problems will go away. Shall we make some source-level change to Xorg (either upstream under ifdef FreeBSD or our own port, _FAST clocks are not available on some other operating systems) so that we can override the gettimeofday() direct calls and X_GETTIMEOFDAY's to use clock_gettime with a faster clock? Cheers, - -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFHwyDbi+vbBBjt66ARAl0DAJ4+uu2bMcE8ohB0vW4LgBEedQFSJQCdEQ9G m1T+XkmxyFwruvzjDZx4znI= =iWeL -----END PGP SIGNATURE-----