Skip to contentSkip to conversation

gettext: --no-hash in msgmft

PATCH Carles Pina i Estany 4 participants 7 messages Nov 25, 2009 – Nov 29, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello,

I'm thinking to disable the hash table in the .mo files. It's not used in Grub Kernel and it makes the size 10% bigger:

In a 473 sentences po file with hash it's 30633 bytes and without 28109, so it 's not a big difference.

Do we want to disable or it's just some KB in /boot/grub and we don't really mind?

Explanation: the .mo files has a hash table (by default) but gettext grub module is not using the hash table (it does search by bisection).

Why?
a) code simpler and smaller
b) for the number of strings the speed is not a big difference*
c) less space used in /boot/grub/locale

*: I haven't bencharmked

Find attached a patch and below the changelog, if we want to apply you can give the ok. If we don't want we forget about it :-)

-----
2009-11-25 Carles Pina i Estany <[email protected]>

* Makefile.in ($MSGFMT): add option --no-hash.
-----

I have a set of solutions if grub gettext module is slow and one would be to implement the hash table if needed.

Signature · 2 lines
Carles Pina i Estany
	http://pinux.info

=== modified file 'Makefile.in'

Makefile.in +1 -1
@@ -483,7 +483,7 @@ $(foreach lang, $(LINGUAS), $(srcdir)/po
 
 po/%.mo: po/%.po
 	$(MKDIR_P) $$(dirname $@)
-	$(MSGFMT) -c --statistics -o $@ $^
+	$(MSGFMT) -c --statistics --no-hash -o $@ $^
 
 .PHONY: all install install-strip uninstall clean mostlyclean distclean
 .PHONY: maintainer-clean info dvi dist check
#1 lore raw
Quoted 12 lines · Carles Pina i Estany

Hello,

I'm thinking to disable the hash table in the .mo files. It's not used in Grub Kernel and it makes the size 10% bigger:

In a 473 sentences po file with hash it's 30633 bytes and without 28109, so it 's not a big difference.

Do we want to disable or it's just some KB in /boot/grub and we don't really mind?

Quoted 7 lines

Explanation: the .mo files has a hash table (by default) but gettext grub module is not using the hash table (it does search by bisection).

Why?
a) code simpler and smaller
b) for the number of strings the speed is not a big difference*
c) less space used in /boot/grub/locale

Makes sense for .mo files that we use in GRUB, but what about the system-wide .mo file, which is used by GRUB utilities? I assume gettext takes advantage of this hash table.

Is it possible to strip the hash table when installing .mo files to /boot/grub ? (Btw, our scripts don't install .mo files to /boot yet, currently user has to do this manually)

Signature · 5 lines
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."
#2 lore raw
Quoted 2 lines · Robert Millan

Is it possible to strip the hash table when installing .mo files to /boot/grub ?

If nothing else, one could use something like 'msgunfmt - | msgfmt --no-hash -'; but I'd expect that we'd want to generate separate .mo files for /boot/grub anyway, since we don't need strings from util/ in there.

Signature · 1 line
Colin Watson                                       [[email protected]]
#3 lore raw
Quoted 4 lines · Colin Watson

If nothing else, one could use something like 'msgunfmt - | msgfmt --no-hash -'; but I'd expect that we'd want to generate separate .mo files for /boot/grub anyway, since we don't need strings from util/ in there.

Yes, we'd probably want to make two domains: grub and grub-kernel or whatever.

To avoid having two domains, we could try to have the strings for both utils and kernel in just one po file (like now) but generate a temporary pot file with just the kernel strings. Merging the full pos against this pot would discard many strings, and compiling those temporary po files (w/o a hash) would get rid of the unused strings.

Signature · 3 lines
Jordi Mallach Pérez  --  Debian developer     http://www.debian.org/
[email protected]     [email protected]     http://www.sindominio.net/
GnuPG public key information available at http://oskuro.net/
#6 lore raw
In reply to Robert Millan

Hi,

Quoted 16 lines · Robert Millan
Quoted 15 lines · Carles Pina i Estany

Hello,

I'm thinking to disable the hash table in the .mo files. It's not used in Grub Kernel and it makes the size 10% bigger:

In a 473 sentences po file with hash it's 30633 bytes and without 28109, so it 's not a big difference.

Do we want to disable or it's just some KB in /boot/grub and we don't really mind?

Explanation: the .mo files has a hash table (by default) but gettext grub module is not using the hash table (it does search by bisection).

Quoted 8 lines
Quoted 4 lines

Why?
a) code simpler and smaller
b) for the number of strings the speed is not a big difference*
c) less space used in /boot/grub/locale

Makes sense for .mo files that we use in GRUB, but what about the system-wide .mo file, which is used by GRUB utilities? I assume gettext takes advantage of this hash table.

Jordi already answered with some ideas and others as well. Just one
note: I haven't measured but I'm very sure that the speed for the user is mainly the same with and without hash. It's Grub, not OpenOffice or a big project with more strings (even thought we have more strings that I guessed)

Quoted 3 lines

Is it possible to strip the hash table when installing .mo files to /boot/grub ? (Btw, our scripts don't install .mo files to /boot yet, currently user has to do this manually)

As has been said: msguunfmt, I don't see any option to strip the hash.

Signature · 2 lines
Carles Pina i Estany
	http://pinux.info
#4 lore raw
In reply to Jordi Mallach
Quoted 8 lines · Jordi Mallach
Quoted 4 lines · Colin Watson

If nothing else, one could use something like 'msgunfmt - | msgfmt --no-hash -'; but I'd expect that we'd want to generate separate .mo files for /boot/grub anyway, since we don't need strings from util/ in there.

Yes, we'd probably want to make two domains: grub and grub-kernel or whatever.

Are you sure we want that? Some strings are shared.

(Btw, don't confuse non-util part with kernel part; the GRUB kernel is just a small part of the whole runtime)

Signature · 5 lines
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."
#5 lore raw
Quoted 11 lines · Robert Millan
Quoted 8 lines · Jordi Mallach
Quoted 4 lines · Colin Watson

If nothing else, one could use something like 'msgunfmt - | msgfmt --no-hash -'; but I'd expect that we'd want to generate separate .mo files for /boot/grub anyway, since we don't need strings from util/ in there.

Yes, we'd probably want to make two domains: grub and grub-kernel or whatever.

Are you sure we want that? Some strings are shared.

Having two domains for the output .mo files doesn't necessarily mean that you have to have separate .po files. I agree that we ought to have a single domain for the .po files.

Signature · 1 line
Colin Watson                                       [[email protected]]