From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NF3DE-00016E-V0 for mharc-grub-devel@gnu.org; Mon, 30 Nov 2009 05:10:33 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NF3DB-00015s-HQ for grub-devel@gnu.org; Mon, 30 Nov 2009 05:10:29 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NF3D5-00015H-Pq for grub-devel@gnu.org; Mon, 30 Nov 2009 05:10:28 -0500 Received: from [199.232.76.173] (port=34534 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NF3D5-00015E-EL for grub-devel@gnu.org; Mon, 30 Nov 2009 05:10:23 -0500 Received: from fg-out-1718.google.com ([72.14.220.158]:26077) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NF3D4-00027K-Vb for grub-devel@gnu.org; Mon, 30 Nov 2009 05:10:23 -0500 Received: by fg-out-1718.google.com with SMTP id l26so1054546fgb.12 for ; Mon, 30 Nov 2009 02:10:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:x-enigmail-version:content-type; bh=WDB0T1PGU30sHOrFXb33nzLAmvKOK6GU1vprV8hNkuQ=; b=VeSpbMStzsgwJYqQiwOwMRbDNDnlWF5gcvtVhedtLbQ0NOGzLOkbs/0TkhnEoV9ycm IlCIgbsK0jMQRDfmV3j3ZiLro0lzOLVeal0v+DKXUtAPer44wpyWLrfHIoebuTfQmAoD 57LDEGLLhkD51pvIboB3vjspR3oC2VCB1kM5M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; b=K00aG4hqORCiPmwgamSyB65azyfNGV9VwIaoSqS9PipJncVA8uhdZD/2lwIO5oeo+W PwHoLW/BZH8w9B1ccoZjgM+SuLoOZYZ91DCCn63eVLK4Zn9HXPaGRqJsHmbjKcZdSYSb mlna92/cweaOxnZq68xu83JdyfFaDHJL2goOo= Received: by 10.86.195.29 with SMTP id s29mr3816543fgf.73.1259575821383; Mon, 30 Nov 2009 02:10:21 -0800 (PST) Received: from debian.bg45.phnet (hpx-public-dock-30-dhcp.ethz.ch [82.130.83.30]) by mx.google.com with ESMTPS id e3sm10046446fga.1.2009.11.30.02.10.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 30 Nov 2009 02:10:20 -0800 (PST) Message-ID: <4B139A02.7040303@gmail.com> Date: Mon, 30 Nov 2009 11:10:10 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) MIME-Version: 1.0 To: The development of GRUB 2 X-Enigmail-Version: 0.95.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig2146A1B5705810E1EB4DE4EA" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] Optimise scrolling by avoiding function calls and aligned memory copy X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2009 10:10:30 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2146A1B5705810E1EB4DE4EA Content-Type: multipart/mixed; boundary="------------050302050702020802000106" This is a multi-part message in MIME format. --------------050302050702020802000106 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Available in experimental. In QEMU benchmark scrolling 1000 lines decreased from 72s to 32s. --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------050302050702020802000106 Content-Type: text/x-diff; name="scrollopt.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="scrollopt.diff" =3D=3D=3D added file 'ChangeLog.scrollopt' --- ChangeLog.scrollopt 1970-01-01 00:00:00 +0000 +++ ChangeLog.scrollopt 2009-11-30 09:26:26 +0000 @@ -0,0 +1,4 @@ +2009-11-30 Vladimir Serbinenko + + * video/fb/video_fb.c (grub_video_fb_scroll): Optimise by avoiding + unnecessary calls. =3D=3D=3D modified file 'video/fb/video_fb.c' --- video/fb/video_fb.c 2009-08-28 13:54:20 +0000 +++ video/fb/video_fb.c 2009-11-30 09:52:10 +0000 @@ -974,32 +974,83 @@ { /* 3. Move data in render target. */ struct grub_video_fbblit_info target; - grub_uint8_t *src; - grub_uint8_t *dst; - int j; + int i, j; + int linedelta, linelen; =20 target.mode_info =3D &render_target->mode_info; target.data =3D render_target->data; =20 - /* Check vertical direction of the move. */ - if (dy <=3D 0) - /* 3a. Move data upwards. */ - for (j =3D 0; j < height; j++) - { - dst =3D grub_video_fb_get_video_ptr (&target, dst_x, dst_y + j); - src =3D grub_video_fb_get_video_ptr (&target, src_x, src_y + j); - grub_memmove (dst, src, - width * target.mode_info->bytes_per_pixel); - } + linedelta =3D target.mode_info->pitch + - width * target.mode_info->bytes_per_pixel; + linelen =3D width * target.mode_info->bytes_per_pixel; +#define DO_SCROLL \ + /* Check vertical direction of the move. */ \ + if (dy < 0 || (dy =3D=3D 0 && dx < 0)) = \ + { \ + dst =3D (void *) grub_video_fb_get_video_ptr (&target, \ + dst_x, dst_y); \ + src =3D (void *) grub_video_fb_get_video_ptr (&target, \ + src_x, src_y); \ + /* 3a. Move data upwards. */ \ + for (j =3D 0; j < height; j++) \ + { \ + for (i =3D 0; i < linelen; i++) \ + *(dst++) =3D *(src++); \ + dst +=3D linedelta; \ + src +=3D linedelta; \ + } \ + } \ + else \ + { \ + /* 3b. Move data downwards. */ \ + dst =3D (void *) grub_video_fb_get_video_ptr (&target, \ + dst_x + width - 1, \ + dst_y + height - 1); \ + src =3D (void *) grub_video_fb_get_video_ptr (&target, \ + src_x + width - 1, \ + src_y + height - 1); \ + for (j =3D 0; j < height; j++) \ + { \ + for (i =3D 0; i < linelen; i++) \ + *(dst--) =3D *(src--); \ + dst -=3D linedelta; \ + src -=3D linedelta; \ + } \ + } + + /* If everything is aligned on 32-bit use 32-bit copy. */ + if ((grub_addr_t) grub_video_fb_get_video_ptr (&target, src_x, src= _y) + % sizeof (grub_uint32_t) =3D=3D 0 + && (grub_addr_t) grub_video_fb_get_video_ptr (&target, dst_x, dst_y) = + % sizeof (grub_uint32_t) =3D=3D 0 + && linelen % sizeof (grub_uint32_t) =3D=3D 0 + && linedelta % sizeof (grub_uint32_t) =3D=3D 0) + { + grub_uint32_t *src, *dst; + linelen /=3D sizeof (grub_uint32_t); + linedelta /=3D sizeof (grub_uint32_t); + DO_SCROLL + } + /* If everything is aligned on 16-bit use 16-bit copy. */ + else if ((grub_addr_t) grub_video_fb_get_video_ptr (&target, src_x= , src_y) + % sizeof (grub_uint16_t) =3D=3D 0 + && (grub_addr_t) grub_video_fb_get_video_ptr (&target, + dst_x, dst_y)=20 + % sizeof (grub_uint16_t) =3D=3D 0 + && linelen % sizeof (grub_uint16_t) =3D=3D 0 + && linedelta % sizeof (grub_uint16_t) =3D=3D 0) + { + grub_uint16_t *src, *dst; + linelen /=3D sizeof (grub_uint16_t); + linedelta /=3D sizeof (grub_uint16_t); + DO_SCROLL + } + /* If not aligned at all use 8-bit copy. */ else - /* 3b. Move data downwards. */ - for (j =3D (height - 1); j >=3D 0; j--) - { - dst =3D grub_video_fb_get_video_ptr (&target, dst_x, dst_y + j); - src =3D grub_video_fb_get_video_ptr (&target, src_x, src_y + j); - grub_memmove (dst, src, - width * target.mode_info->bytes_per_pixel); - } + { + grub_uint8_t *src, *dst; + DO_SCROLL + }=09 } =20 /* 4. Fill empty space with specified color. In this implementation --------------050302050702020802000106-- --------------enig2146A1B5705810E1EB4DE4EA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iF4EAREKAAYFAksTmgsACgkQNak7dOguQgn9+AD/WK7f1QiVTlEKk0T3Y5WreJ8P GIrXD3nMwsHbbov6iP4A/jQKXPBZ2iposXlUpI30rwGaRlcvFvJ/aYuvUWj0et0Y =PWGZ -----END PGP SIGNATURE----- --------------enig2146A1B5705810E1EB4DE4EA--