* [PATCH] Faster text rendering by optimizing font glyph lookup
@ 2009-02-08 21:49 Colin D Bennett
2009-02-09 14:11 ` Robert Millan
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Colin D Bennett @ 2009-02-08 21:49 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1.1: Type: text/plain, Size: 860 bytes --]
This patch greatly—*tremendously*, even, if higher-numbered Unicode
characters are used—speeds up retrieving a glyph for a particular
Unicode character. This makes text rendering in general much faster.
My text benchmark shows the new text rendering speed is somewhere from
2.6x to 31x of the previous speed. Basically, PFF2 font files are now
required to have the character index ordered in ascending order of code
point.
Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
created by my old Java 'fonttool' do not, and cannot be used any longer.
The font loader verifies that fonts fulfill the character ordering
requirement, refusing to load invalid fonts, but the primary change is
in the 'find_glyph()' function, which now uses a binary search rather
than a linear search to find the glyph.
Regards,
Colin
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: font-optimization.patch --]
[-- Type: text/x-patch, Size: 2668 bytes --]
=== modified file 'ChangeLog'
--- ChangeLog 2009-02-04 10:52:25 +0000
+++ ChangeLog 2009-02-08 21:46:42 +0000
@@ -1,3 +1,14 @@
+2009-02-08 Colin D Bennett <colin@gibibit.com>
+
+ Optimized font character lookup using binary search instead of linear
+ search. Fonts now are required to have the character index ordered by
+ code point.
+
+ * font/font.c (load_font_index): Verify that fonts have ordered
+ character indices.
+ (find_glyph): Use binary search instead of linear search to find a
+ character in a font.
+
2009-02-04 Felix Zielcke <fzielcke@z-51.de>
util/getroot.c (grub_util_get_grub_dev): Add support for /dev/mdNpN and
=== modified file 'font/font.c'
--- font/font.c 2009-01-19 17:09:53 +0000
+++ font/font.c 2009-02-08 19:50:58 +0000
@@ -249,6 +249,7 @@
grub_font *font)
{
unsigned i;
+ grub_uint32_t last_code;
#if FONT_DEBUG >= 2
grub_printf("load_font_index(sect_length=%d)\n", sect_length);
@@ -277,6 +278,8 @@
grub_printf("num_chars=%d)\n", font->num_chars);
#endif
+ last_code = 0;
+
/* Load the character index data from the file. */
for (i = 0; i < font->num_chars; i++)
{
@@ -287,6 +290,17 @@
return 1;
entry->code = grub_be_to_cpu32 (entry->code);
+ /* Verify that characters are in ascending order. */
+ if (i != 0 && entry->code <= last_code)
+ {
+ grub_error (GRUB_ERR_BAD_FONT,
+ "Font characters not in ascending order: %u <= %u",
+ entry->code, last_code);
+ return 1;
+ }
+
+ last_code = entry->code;
+
/* Read storage flags byte. */
if (grub_file_read (file, (char *) &entry->storage_flags, 1) != 1)
return 1;
@@ -583,15 +597,25 @@
static struct char_index_entry *
find_glyph (const grub_font_t font, grub_uint32_t code)
{
- grub_uint32_t i;
- grub_uint32_t len = font->num_chars;
- struct char_index_entry *table = font->char_index;
-
- /* Do a linear search. */
- for (i = 0; i < len; i++)
+ struct char_index_entry *table;
+ grub_size_t lo;
+ grub_size_t hi;
+ grub_size_t mid;
+
+ /* Do a binary search in `char_index', which is ordered by code point. */
+ table = font->char_index;
+ lo = 0;
+ hi = font->num_chars - 1;
+
+ while (lo <= hi)
{
- if (table[i].code == code)
- return &table[i];
+ mid = lo + (hi - lo) / 2;
+ if (code < table[mid].code)
+ hi = mid - 1;
+ else if (code > table[mid].code)
+ lo = mid + 1;
+ else
+ return &table[mid];
}
return 0;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-02-08 21:49 [PATCH] Faster text rendering by optimizing font glyph lookup Colin D Bennett
@ 2009-02-09 14:11 ` Robert Millan
2009-02-09 16:24 ` Colin D Bennett
2009-04-10 23:39 ` phcoder
2009-05-31 9:41 ` Vladimir 'phcoder' Serbinenko
2 siblings, 1 reply; 15+ messages in thread
From: Robert Millan @ 2009-02-09 14:11 UTC (permalink / raw)
To: The development of GRUB 2
On Sun, Feb 08, 2009 at 01:49:53PM -0800, Colin D Bennett wrote:
> This patch greatly—*tremendously*, even, if higher-numbered Unicode
> characters are used—speeds up retrieving a glyph for a particular
> Unicode character. This makes text rendering in general much faster.
>
> My text benchmark shows the new text rendering speed is somewhere from
> 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
> required to have the character index ordered in ascending order of code
> point.
>
> Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
> created by my old Java 'fonttool' do not, and cannot be used any longer.
>
> The font loader verifies that fonts fulfill the character ordering
> requirement, refusing to load invalid fonts, but the primary change is
> in the 'find_glyph()' function, which now uses a binary search rather
> than a linear search to find the glyph.
Very nice!
With this patch, how does retrieving glyphs from the complete unicode font
compare to retrieving glyphs (without the patch) from the ascii ascii one?
Can we make unicode font the default now?
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-02-09 14:11 ` Robert Millan
@ 2009-02-09 16:24 ` Colin D Bennett
2009-06-11 10:28 ` Felix Zielcke
0 siblings, 1 reply; 15+ messages in thread
From: Colin D Bennett @ 2009-02-09 16:24 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: rmh
[-- Attachment #1: Type: text/plain, Size: 3364 bytes --]
On Mon, 9 Feb 2009 15:11:16 +0100
Robert Millan <rmh@aybabtu.com> wrote:
> On Sun, Feb 08, 2009 at 01:49:53PM -0800, Colin D Bennett wrote:
> > This patch greatly—*tremendously*, even, if higher-numbered Unicode
> > characters are used—speeds up retrieving a glyph for a particular
> > Unicode character. This makes text rendering in general much faster.
> >
> > My text benchmark shows the new text rendering speed is somewhere from
> > 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
> > required to have the character index ordered in ascending order of code
> > point.
> >
> > Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
> > created by my old Java 'fonttool' do not, and cannot be used any longer.
> >
> > The font loader verifies that fonts fulfill the character ordering
> > requirement, refusing to load invalid fonts, but the primary change is
> > in the 'find_glyph()' function, which now uses a binary search rather
> > than a linear search to find the glyph.
>
> Very nice!
>
> With this patch, how does retrieving glyphs from the complete unicode font
> compare to retrieving glyphs (without the patch) from the ascii ascii one?
Here is the result of my benchmark with two kinds of text:
(1) 104 characters of ASCII English text, and
(2) 104 Unicode characters randomly selected from the characters in
unifont, uniformly distributed over all 61050 characters in the
font.
Also, I ran the tests with both the 'ascii.pf2' and 'unicode.pf2' font
files generated by GRUB's Makefile. Here are the results:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
9 February 2009 videotest bench, text rendering
benchmark 640x480 resolution
ASCII Text Unicode Text
Algorithm Unifont used (Chars/s) (Chars/s)
--------------- ------------- ---------- ------------
Linear search ASCII Font 255113 12098 [1]
Linear search Unicode Font 250874 23068 [2]
Binary search ASCII Font 255746 96231 [1]
Binary search Unicode Font 255113 194741 [2]
[1] Note that using the ASCII font for Unicode text results in a
performance hit because the grub_font_draw_string() function will
use font fallback to search for the missing glyphs in another
font. I had other fonts loaded while running the benchmark, so
GRUB had to scan them for the missing characters.
[2] These numbers, for full Unicode text with the full unifont, show
the improvement in worst-case performance when using the binary
search versus linear search.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Note that most of the time is now spent actually rendering the bitmaps
on screen (instead of retrieving glyphs from the font), which actually
takes longer for the Unicode text because many of the glyphs are wider
than the English ASCII characters.
(BTW, is there any way to run GRUB in a profiler? I'd like to know
where the graphics performance bottlenecks are.)
> Can we make unicode font the default now?
I think so. Using the full Unicode font does not seem to have a
significant effect on rendering speed now. I will commit the patch if
it looks OK to you.
Regards,
Colin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-02-09 16:24 ` Colin D Bennett
@ 2009-06-11 10:28 ` Felix Zielcke
2009-06-11 21:31 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 15+ messages in thread
From: Felix Zielcke @ 2009-06-11 10:28 UTC (permalink / raw)
To: The development of GRUB 2
Am Montag, den 09.02.2009, 08:24 -0800 schrieb Colin D Bennett:
> On Mon, 9 Feb 2009 15:11:16 +0100
> Robert Millan <rmh@aybabtu.com> wrote:
>
> > On Sun, Feb 08, 2009 at 01:49:53PM -0800, Colin D Bennett wrote:
> > > This patch greatly—*tremendously*, even, if higher-numbered Unicode
> > > characters are used—speeds up retrieving a glyph for a particular
> > > Unicode character. This makes text rendering in general much faster.
> > >
> > > My text benchmark shows the new text rendering speed is somewhere from
> > > 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
> > > required to have the character index ordered in ascending order of code
> > > point.
> > >
> > > Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
> > > created by my old Java 'fonttool' do not, and cannot be used any longer.
> > >
> > > The font loader verifies that fonts fulfill the character ordering
> > > requirement, refusing to load invalid fonts, but the primary change is
> > > in the 'find_glyph()' function, which now uses a binary search rather
> > > than a linear search to find the glyph.
> >
> > Very nice!
> >
> > With this patch, how does retrieving glyphs from the complete unicode font
> > compare to retrieving glyphs (without the patch) from the ascii ascii one?
>
> Here is the result of my benchmark with two kinds of text:
> (1) 104 characters of ASCII English text, and
> (2) 104 Unicode characters randomly selected from the characters in
> unifont, uniformly distributed over all 61050 characters in the
> font.
>
> Also, I ran the tests with both the 'ascii.pf2' and 'unicode.pf2' font
> files generated by GRUB's Makefile. Here are the results:
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> 9 February 2009 videotest bench, text rendering
> benchmark 640x480 resolution
> ASCII Text Unicode Text
> Algorithm Unifont used (Chars/s) (Chars/s)
> --------------- ------------- ---------- ------------
> Linear search ASCII Font 255113 12098 [1]
> Linear search Unicode Font 250874 23068 [2]
> Binary search ASCII Font 255746 96231 [1]
> Binary search Unicode Font 255113 194741 [2]
>
> [1] Note that using the ASCII font for Unicode text results in a
> performance hit because the grub_font_draw_string() function will
> use font fallback to search for the missing glyphs in another
> font. I had other fonts loaded while running the benchmark, so
> GRUB had to scan them for the missing characters.
>
> [2] These numbers, for full Unicode text with the full unifont, show
> the improvement in worst-case performance when using the binary
> search versus linear search.
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> Note that most of the time is now spent actually rendering the bitmaps
> on screen (instead of retrieving glyphs from the font), which actually
> takes longer for the Unicode text because many of the glyphs are wider
> than the English ASCII characters.
>
> (BTW, is there any way to run GRUB in a profiler? I'd like to know
> where the graphics performance bottlenecks are.)
>
> > Can we make unicode font the default now?
>
> I think so. Using the full Unicode font does not seem to have a
> significant effect on rendering speed now. I will commit the patch if
> it looks OK to you.
>
Now that Vladimir finally commited this, should we make it now the
default or not?
--
Felix Zielcke
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-06-11 10:28 ` Felix Zielcke
@ 2009-06-11 21:31 ` Vladimir 'phcoder' Serbinenko
2009-07-24 21:17 ` Felix Zielcke
0 siblings, 1 reply; 15+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-06-11 21:31 UTC (permalink / raw)
To: The development of GRUB 2
On Thu, Jun 11, 2009 at 12:28 PM, Felix Zielcke<fzielcke@z-51.de> wrote:
> Am Montag, den 09.02.2009, 08:24 -0800 schrieb Colin D Bennett:
>> On Mon, 9 Feb 2009 15:11:16 +0100
>> Robert Millan <rmh@aybabtu.com> wrote:
>>
>> > On Sun, Feb 08, 2009 at 01:49:53PM -0800, Colin D Bennett wrote:
>> > > This patch greatly—*tremendously*, even, if higher-numbered Unicode
>> > > characters are used—speeds up retrieving a glyph for a particular
>> > > Unicode character. This makes text rendering in general much faster.
>> > >
>> > > My text benchmark shows the new text rendering speed is somewhere from
>> > > 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
>> > > required to have the character index ordered in ascending order of code
>> > > point.
>> > >
>> > > Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
>> > > created by my old Java 'fonttool' do not, and cannot be used any longer.
>> > >
>> > > The font loader verifies that fonts fulfill the character ordering
>> > > requirement, refusing to load invalid fonts, but the primary change is
>> > > in the 'find_glyph()' function, which now uses a binary search rather
>> > > than a linear search to find the glyph.
>> >
>> > Very nice!
>> >
>> > With this patch, how does retrieving glyphs from the complete unicode font
>> > compare to retrieving glyphs (without the patch) from the ascii ascii one?
>>
>> Here is the result of my benchmark with two kinds of text:
>> (1) 104 characters of ASCII English text, and
>> (2) 104 Unicode characters randomly selected from the characters in
>> unifont, uniformly distributed over all 61050 characters in the
>> font.
>>
>> Also, I ran the tests with both the 'ascii.pf2' and 'unicode.pf2' font
>> files generated by GRUB's Makefile. Here are the results:
>>
>> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>> 9 February 2009 videotest bench, text rendering
>> benchmark 640x480 resolution
>> ASCII Text Unicode Text
>> Algorithm Unifont used (Chars/s) (Chars/s)
>> --------------- ------------- ---------- ------------
>> Linear search ASCII Font 255113 12098 [1]
>> Linear search Unicode Font 250874 23068 [2]
>> Binary search ASCII Font 255746 96231 [1]
>> Binary search Unicode Font 255113 194741 [2]
>>
>> [1] Note that using the ASCII font for Unicode text results in a
>> performance hit because the grub_font_draw_string() function will
>> use font fallback to search for the missing glyphs in another
>> font. I had other fonts loaded while running the benchmark, so
>> GRUB had to scan them for the missing characters.
>>
>> [2] These numbers, for full Unicode text with the full unifont, show
>> the improvement in worst-case performance when using the binary
>> search versus linear search.
>> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>
>> Note that most of the time is now spent actually rendering the bitmaps
>> on screen (instead of retrieving glyphs from the font), which actually
>> takes longer for the Unicode text because many of the glyphs are wider
>> than the English ASCII characters.
>>
>> (BTW, is there any way to run GRUB in a profiler? I'd like to know
>> where the graphics performance bottlenecks are.)
>>
>> > Can we make unicode font the default now?
>>
>> I think so. Using the full Unicode font does not seem to have a
>> significant effect on rendering speed now. I will commit the patch if
>> it looks OK to you.
>>
>
> Now that Vladimir finally commited this, should we make it now the
> default or not?
I think we can make unicode fonts default now. Don't get too
overexcited though: we still lack ligatures. I don't know if composing
accents work and no bidi.But this subset is already enough to support
all European languages, Chinese, Korean and Japanese as long
characters are precomposed
> --
> Felix Zielcke
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'phcoder' Serbinenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-06-11 21:31 ` Vladimir 'phcoder' Serbinenko
@ 2009-07-24 21:17 ` Felix Zielcke
2009-07-25 16:04 ` Robert Millan
2009-07-26 9:13 ` Felix Zielcke
0 siblings, 2 replies; 15+ messages in thread
From: Felix Zielcke @ 2009-07-24 21:17 UTC (permalink / raw)
To: The development of GRUB 2
Am Donnerstag, den 11.06.2009, 23:31 +0200 schrieb Vladimir 'phcoder'
Serbinenko:
> On Thu, Jun 11, 2009 at 12:28 PM, Felix Zielcke<fzielcke@z-51.de> wrote:
> > Am Montag, den 09.02.2009, 08:24 -0800 schrieb Colin D Bennett:
> >> On Mon, 9 Feb 2009 15:11:16 +0100
> >> Robert Millan <rmh@aybabtu.com> wrote:
> >>
> >> > On Sun, Feb 08, 2009 at 01:49:53PM -0800, Colin D Bennett wrote:
> >> > > This patch greatly—*tremendously*, even, if higher-numbered Unicode
> >> > > characters are used—speeds up retrieving a glyph for a particular
> >> > > Unicode character. This makes text rendering in general much faster.
> >> > >
> >> > > My text benchmark shows the new text rendering speed is somewhere from
> >> > > 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
> >> > > required to have the character index ordered in ascending order of code
> >> > > point.
> >> > >
> >> > > Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
> >> > > created by my old Java 'fonttool' do not, and cannot be used any longer.
> >> > >
> >> > > The font loader verifies that fonts fulfill the character ordering
> >> > > requirement, refusing to load invalid fonts, but the primary change is
> >> > > in the 'find_glyph()' function, which now uses a binary search rather
> >> > > than a linear search to find the glyph.
> >> >
> >> > Very nice!
> >> >
> >> > With this patch, how does retrieving glyphs from the complete unicode font
> >> > compare to retrieving glyphs (without the patch) from the ascii ascii one?
> >>
> >> Here is the result of my benchmark with two kinds of text:
> >> (1) 104 characters of ASCII English text, and
> >> (2) 104 Unicode characters randomly selected from the characters in
> >> unifont, uniformly distributed over all 61050 characters in the
> >> font.
> >>
> >> Also, I ran the tests with both the 'ascii.pf2' and 'unicode.pf2' font
> >> files generated by GRUB's Makefile. Here are the results:
> >>
> >> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> >> 9 February 2009 videotest bench, text rendering
> >> benchmark 640x480 resolution
> >> ASCII Text Unicode Text
> >> Algorithm Unifont used (Chars/s) (Chars/s)
> >> --------------- ------------- ---------- ------------
> >> Linear search ASCII Font 255113 12098 [1]
> >> Linear search Unicode Font 250874 23068 [2]
> >> Binary search ASCII Font 255746 96231 [1]
> >> Binary search Unicode Font 255113 194741 [2]
> >>
> >> [1] Note that using the ASCII font for Unicode text results in a
> >> performance hit because the grub_font_draw_string() function will
> >> use font fallback to search for the missing glyphs in another
> >> font. I had other fonts loaded while running the benchmark, so
> >> GRUB had to scan them for the missing characters.
> >>
> >> [2] These numbers, for full Unicode text with the full unifont, show
> >> the improvement in worst-case performance when using the binary
> >> search versus linear search.
> >> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> >>
> >> Note that most of the time is now spent actually rendering the bitmaps
> >> on screen (instead of retrieving glyphs from the font), which actually
> >> takes longer for the Unicode text because many of the glyphs are wider
> >> than the English ASCII characters.
> >>
> >> (BTW, is there any way to run GRUB in a profiler? I'd like to know
> >> where the graphics performance bottlenecks are.)
> >>
> >> > Can we make unicode font the default now?
> >>
> >> I think so. Using the full Unicode font does not seem to have a
> >> significant effect on rendering speed now. I will commit the patch if
> >> it looks OK to you.
> >>
> >
> > Now that Vladimir finally commited this, should we make it now the
> > default or not?
> I think we can make unicode fonts default now. Don't get too
> overexcited though: we still lack ligatures. I don't know if composing
> accents work and no bidi.But this subset is already enough to support
> all European languages, Chinese, Korean and Japanese as long
> characters are precomposed
So if there still won't come up objections against this, then I'll do
the change, then at least an Ubuntu bug report can be closed.
--
Felix Zielcke
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-07-24 21:17 ` Felix Zielcke
@ 2009-07-25 16:04 ` Robert Millan
2009-07-25 16:22 ` Felix Zielcke
2009-07-26 9:13 ` Felix Zielcke
1 sibling, 1 reply; 15+ messages in thread
From: Robert Millan @ 2009-07-25 16:04 UTC (permalink / raw)
To: The development of GRUB 2
On Fri, Jul 24, 2009 at 11:17:59PM +0200, Felix Zielcke wrote:
>
> So if there still won't come up objections against this, then I'll do
> the change, then at least an Ubuntu bug report can be closed.
I think it's fine, but is this an upstream change or a debian change? IIRC
the default font selection is in grub-mkconfig.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-07-25 16:04 ` Robert Millan
@ 2009-07-25 16:22 ` Felix Zielcke
2009-07-26 8:38 ` Michal Suchanek
0 siblings, 1 reply; 15+ messages in thread
From: Felix Zielcke @ 2009-07-25 16:22 UTC (permalink / raw)
To: The development of GRUB 2
Am Samstag, den 25.07.2009, 18:04 +0200 schrieb Robert Millan:
> On Fri, Jul 24, 2009 at 11:17:59PM +0200, Felix Zielcke wrote:
> >
> > So if there still won't come up objections against this, then I'll do
> > the change, then at least an Ubuntu bug report can be closed.
>
> I think it's fine, but is this an upstream change or a debian change? IIRC
> the default font selection is in grub-mkconfig.
>
Upstream. There you changed the default from unicode.pff to ascii.pff.
--
Felix Zielcke
Proud Debian Maintainer
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-07-25 16:22 ` Felix Zielcke
@ 2009-07-26 8:38 ` Michal Suchanek
2009-07-26 8:56 ` Felix Zielcke
0 siblings, 1 reply; 15+ messages in thread
From: Michal Suchanek @ 2009-07-26 8:38 UTC (permalink / raw)
To: The development of GRUB 2
On 25/07/2009, Felix Zielcke <fzielcke@z-51.de> wrote:
> Am Samstag, den 25.07.2009, 18:04 +0200 schrieb Robert Millan:
>
> > On Fri, Jul 24, 2009 at 11:17:59PM +0200, Felix Zielcke wrote:
> > >
> > > So if there still won't come up objections against this, then I'll do
> > > the change, then at least an Ubuntu bug report can be closed.
> >
> > I think it's fine, but is this an upstream change or a debian change? IIRC
> > the default font selection is in grub-mkconfig.
> >
>
>
> Upstream. There you changed the default from unicode.pff to ascii.pff.
>
The default font for generating a rescue floppy image should be ascii
because the unicode font won't fit.
However, I could not find any font at all on the floppy, and it is
probably not required in any environment that supports floppy booting
so I am not sure if there is any reason for including it except for
easy testing of graphics.
Thanks
Michal
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-07-26 8:38 ` Michal Suchanek
@ 2009-07-26 8:56 ` Felix Zielcke
0 siblings, 0 replies; 15+ messages in thread
From: Felix Zielcke @ 2009-07-26 8:56 UTC (permalink / raw)
To: The development of GRUB 2
Am Sonntag, den 26.07.2009, 10:38 +0200 schrieb Michal Suchanek:
> On 25/07/2009, Felix Zielcke <fzielcke@z-51.de> wrote:
> > Am Samstag, den 25.07.2009, 18:04 +0200 schrieb Robert Millan:
> >
> > > On Fri, Jul 24, 2009 at 11:17:59PM +0200, Felix Zielcke wrote:
> > > >
> > > > So if there still won't come up objections against this, then I'll do
> > > > the change, then at least an Ubuntu bug report can be closed.
> > >
> > > I think it's fine, but is this an upstream change or a debian change? IIRC
> > > the default font selection is in grub-mkconfig.
> > >
> >
> >
> > Upstream. There you changed the default from unicode.pff to ascii.pff.
> >
>
> The default font for generating a rescue floppy image should be ascii
> because the unicode font won't fit.
The change is just for grub-mkconfig, which isn't at all used by
grub-mkrescue.
It would still use ascii.pf2 if there's no unicode.pf2
> However, I could not find any font at all on the floppy, and it is
> probably not required in any environment that supports floppy booting
> so I am not sure if there is any reason for including it except for
> easy testing of graphics.
>
> Thanks
>
> Michal
If anyone wants to have gfxterm on a floppy, he/she could just use
grub-mkrescue with --overlay
A custom grub.cfg would be good anyway in that case and then you could
just copy ascii.pf2 there too.
--
Felix Zielcke
Proud Debian Maintainer
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-07-24 21:17 ` Felix Zielcke
2009-07-25 16:04 ` Robert Millan
@ 2009-07-26 9:13 ` Felix Zielcke
1 sibling, 0 replies; 15+ messages in thread
From: Felix Zielcke @ 2009-07-26 9:13 UTC (permalink / raw)
To: The development of GRUB 2
Am Freitag, den 24.07.2009, 23:17 +0200 schrieb Felix Zielcke:
> Am Donnerstag, den 11.06.2009, 23:31 +0200 schrieb Vladimir 'phcoder'
> Serbinenko:
> > On Thu, Jun 11, 2009 at 12:28 PM, Felix Zielcke<fzielcke@z-51.de> wrote:
> > > Am Montag, den 09.02.2009, 08:24 -0800 schrieb Colin D Bennett:
> > >> On Mon, 9 Feb 2009 15:11:16 +0100
> > >> Robert Millan <rmh@aybabtu.com> wrote:
> > >>
> > >> > On Sun, Feb 08, 2009 at 01:49:53PM -0800, Colin D Bennett wrote:
> > >> > > This patch greatly—*tremendously*, even, if higher-numbered Unicode
> > >> > > characters are used—speeds up retrieving a glyph for a particular
> > >> > > Unicode character. This makes text rendering in general much faster.
> > >> > >
> > >> > > My text benchmark shows the new text rendering speed is somewhere from
> > >> > > 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
> > >> > > required to have the character index ordered in ascending order of code
> > >> > > point.
> > >> > >
> > >> > > Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
> > >> > > created by my old Java 'fonttool' do not, and cannot be used any longer.
> > >> > >
> > >> > > The font loader verifies that fonts fulfill the character ordering
> > >> > > requirement, refusing to load invalid fonts, but the primary change is
> > >> > > in the 'find_glyph()' function, which now uses a binary search rather
> > >> > > than a linear search to find the glyph.
> > >> >
> > >> > Very nice!
> > >> >
> > >> > With this patch, how does retrieving glyphs from the complete unicode font
> > >> > compare to retrieving glyphs (without the patch) from the ascii ascii one?
> > >>
> > >> Here is the result of my benchmark with two kinds of text:
> > >> (1) 104 characters of ASCII English text, and
> > >> (2) 104 Unicode characters randomly selected from the characters in
> > >> unifont, uniformly distributed over all 61050 characters in the
> > >> font.
> > >>
> > >> Also, I ran the tests with both the 'ascii.pf2' and 'unicode.pf2' font
> > >> files generated by GRUB's Makefile. Here are the results:
> > >>
> > >> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > >> 9 February 2009 videotest bench, text rendering
> > >> benchmark 640x480 resolution
> > >> ASCII Text Unicode Text
> > >> Algorithm Unifont used (Chars/s) (Chars/s)
> > >> --------------- ------------- ---------- ------------
> > >> Linear search ASCII Font 255113 12098 [1]
> > >> Linear search Unicode Font 250874 23068 [2]
> > >> Binary search ASCII Font 255746 96231 [1]
> > >> Binary search Unicode Font 255113 194741 [2]
> > >>
> > >> [1] Note that using the ASCII font for Unicode text results in a
> > >> performance hit because the grub_font_draw_string() function will
> > >> use font fallback to search for the missing glyphs in another
> > >> font. I had other fonts loaded while running the benchmark, so
> > >> GRUB had to scan them for the missing characters.
> > >>
> > >> [2] These numbers, for full Unicode text with the full unifont, show
> > >> the improvement in worst-case performance when using the binary
> > >> search versus linear search.
> > >> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> > >>
> > >> Note that most of the time is now spent actually rendering the bitmaps
> > >> on screen (instead of retrieving glyphs from the font), which actually
> > >> takes longer for the Unicode text because many of the glyphs are wider
> > >> than the English ASCII characters.
> > >>
> > >> (BTW, is there any way to run GRUB in a profiler? I'd like to know
> > >> where the graphics performance bottlenecks are.)
> > >>
> > >> > Can we make unicode font the default now?
> > >>
> > >> I think so. Using the full Unicode font does not seem to have a
> > >> significant effect on rendering speed now. I will commit the patch if
> > >> it looks OK to you.
> > >>
> > >
> > > Now that Vladimir finally commited this, should we make it now the
> > > default or not?
> > I think we can make unicode fonts default now. Don't get too
> > overexcited though: we still lack ligatures. I don't know if composing
> > accents work and no bidi.But this subset is already enough to support
> > all European languages, Chinese, Korean and Japanese as long
> > characters are precomposed
>
> So if there still won't come up objections against this, then I'll do
> the change, then at least an Ubuntu bug report can be closed.
>
Ah just read now the comment in grub-mkconfig_lib.in, which complains
about loading speed not rendering.
In qemu there's a very small delay in loading unicode.pf2
ascii.pf2 loads instantly.
But I think that's acceptable or not?
--
Felix Zielcke
Proud Debian Maintainer
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-02-08 21:49 [PATCH] Faster text rendering by optimizing font glyph lookup Colin D Bennett
2009-02-09 14:11 ` Robert Millan
@ 2009-04-10 23:39 ` phcoder
2009-04-13 13:57 ` Robert Millan
2009-05-31 9:41 ` Vladimir 'phcoder' Serbinenko
2 siblings, 1 reply; 15+ messages in thread
From: phcoder @ 2009-04-10 23:39 UTC (permalink / raw)
To: The development of GRUB 2
Any reason not to merge this patch?
Colin D Bennett wrote:
> This patch greatly—*tremendously*, even, if higher-numbered Unicode
> characters are used—speeds up retrieving a glyph for a particular
> Unicode character. This makes text rendering in general much faster.
>
> My text benchmark shows the new text rendering speed is somewhere from
> 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
> required to have the character index ordered in ascending order of code
> point.
>
> Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
> created by my old Java 'fonttool' do not, and cannot be used any longer.
>
> The font loader verifies that fonts fulfill the character ordering
> requirement, refusing to load invalid fonts, but the primary change is
> in the 'find_glyph()' function, which now uses a binary search rather
> than a linear search to find the glyph.
>
> Regards,
> Colin
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
--
Regards
Vladimir 'phcoder' Serbinenko
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] Faster text rendering by optimizing font glyph lookup
2009-02-08 21:49 [PATCH] Faster text rendering by optimizing font glyph lookup Colin D Bennett
2009-02-09 14:11 ` Robert Millan
2009-04-10 23:39 ` phcoder
@ 2009-05-31 9:41 ` Vladimir 'phcoder' Serbinenko
2 siblings, 0 replies; 15+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-05-31 9:41 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: Colin D Bennett
On Sun, Feb 8, 2009 at 11:49 PM, Colin D Bennett <colin@gibibit.com> wrote:
> This patch greatly—*tremendously*, even, if higher-numbered Unicode
> characters are used—speeds up retrieving a glyph for a particular
> Unicode character. This makes text rendering in general much faster.
>
> My text benchmark shows the new text rendering speed is somewhere from
> 2.6x to 31x of the previous speed. Basically, PFF2 font files are now
> required to have the character index ordered in ascending order of code
> point.
>
> Fonts created by 'grub-mkfont' already satisfy this requirement. Fonts
> created by my old Java 'fonttool' do not, and cannot be used any longer.
>
> The font loader verifies that fonts fulfill the character ordering
> requirement, refusing to load invalid fonts, but the primary change is
> in the 'find_glyph()' function, which now uses a binary search rather
> than a linear search to find the glyph.
There were no oppositions to this patch and it still applies cleanly
(except Changelog). If it's ok with you I'll commit this patch
>
> Regards,
> Colin
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
>
--
Regards
Vladimir 'phcoder' Serbinenko
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2009-07-26 9:12 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-08 21:49 [PATCH] Faster text rendering by optimizing font glyph lookup Colin D Bennett
2009-02-09 14:11 ` Robert Millan
2009-02-09 16:24 ` Colin D Bennett
2009-06-11 10:28 ` Felix Zielcke
2009-06-11 21:31 ` Vladimir 'phcoder' Serbinenko
2009-07-24 21:17 ` Felix Zielcke
2009-07-25 16:04 ` Robert Millan
2009-07-25 16:22 ` Felix Zielcke
2009-07-26 8:38 ` Michal Suchanek
2009-07-26 8:56 ` Felix Zielcke
2009-07-26 9:13 ` Felix Zielcke
2009-04-10 23:39 ` phcoder
2009-04-13 13:57 ` Robert Millan
2009-04-13 14:17 ` Felix Zielcke
2009-05-31 9:41 ` Vladimir 'phcoder' Serbinenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.