git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH 1/5] gettext: fix bug in git-sh-i18n's eval_gettext() by using envsubst(1)

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 9, 2010, 11:57 UTC
Message-ID
<AANLkTimhbp3AngtJjBYhHpa173=D-XJOg9L2sd6YMCwA@mail.gmail.com>
In-Reply-To
<4CD933BF.6070105@viscovery.net>
On Tue, Nov 9, 2010 at 12:42, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 24 quoted lines
> Am 11/9/2010 11:52, schrieb Ævar Arnfjörð Bjarmason:
>> On Tue, Nov 9, 2010 at 11:36, Johannes Sixt <j.sixt@viscovery.net> wrote:
>>> $ time (for i in {1..100}; do git version; done) > /dev/null
>>>
>>> real    0m5.610s
> ...
>>> $ time (for i in {1..100}; do eval_gettext foobar; done) > /dev/null
>>>
>>> real    0m20.578s
> ...
>>> Note that there are only 100 iterations, so we are talking about 0.2
>>> seconds per eval_gettext call! That's an awful lot of time even for a
>>> single error message.
>>
>> Thanks for elaborating. But just so I understand you correctly it's a
>> cost of invoking *any* program in shellscripts on Windows? So e.g. 10
>> sed calls would cost the same as 10 git-sh-i18n--envsubst calls (but
>> of course 5 eval_gettext() calls, since it calls git-sh-i18n--envsubst
>> twice).
>
> An invocation of sed, cat, etc. (POSIX/MSYS tools) is cheaper by a factor
> of 2 than a git invocation for a reason that I do not understand. (Perhaps
> it has to do with the number of DLLs that are linked; git has 9 static
> dependencies, MSYS tools only 3.)

git-sh-i18n--envsubst doesn't need to be linked to anything but the C library.

If it is that's because I fat-fingered the Makefile part of the patch. So it should be cheaper than cat/sed etc. if anything.

    $ ldd -r git-sh-i18n--envsubst
        linux-vdso.so.1 =>  (0x00007fff163c4000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007f742dea6000)
        libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0x00007f742db05000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007f742d8e8000)
        libc.so.6 => /lib/libc.so.6 (0x00007f742d587000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007f742d383000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f742e0cc000)

That's on Linux, it doesn't need libz, libcrypto etc. It just needs standard C library functions along with its own main().

Show 8 quoted lines
> eval_gettext involves 2 git invocation (git-sh-i18n--envsubst counts as
> much as git) and 1 subshell in practice (some subshells are optimized away).
>
>> So e.g. using eval_gettext once isn't a bigger problem than calling
>> some trivial sed substitution twice?
>
> Look at the timings: In my book, eval_gettext counts like about 8 sed
> substitutions.

How about if you just replace your tests with "cat". That should give a more accurate indication of what speed it *should* be operating at, once I fix those Makefile issues.

Anyway, if it's no more expensive than cat(1) (which it shouldn't be) it probably won't be a problem to use git-sh-i18n--envsubst.

Actually I'd rather keep the current calling semantics (using variables in the strings) than improve performance slightly on Windows for what are mostly non-critical error messages. But that's just my opinion.

Previous: Johannes SixtNext: Johannes Sixt
Message 19 of 27 in “Buglet in i18n?”
  1. Johannes SixtOct 22, 2010
  2. Ævar Arnfjörð BjarmasonOct 22, 2010
  3. Jonathan NiederOct 22, 2010
  4. Ævar Arnfjörð BjarmasonOct 23, 2010
  5. Johannes SixtOct 22, 2010
  6. Ævar Arnfjörð BjarmasonOct 30, 2010
  7. 0/5 ab/i18n: Things I'll add in the next iterationÆvar Arnfjörð Bjarmason, Oct 31, 2010
  8. 1/5 gettext: fix bug in git-sh-i18n's eval_gettext() by using envsubst(1)Ævar Arnfjörð Bjarmason, Oct 31, 2010
  9. Johannes SixtNov 2, 2010
  10. Ævar Arnfjörð BjarmasonNov 8, 2010
  11. Johannes SixtNov 9, 2010
  12. Ævar Arnfjörð BjarmasonNov 9, 2010
  13. Johannes SixtNov 9, 2010
  14. Ævar Arnfjörð BjarmasonNov 9, 2010
  15. Johannes SixtNov 9, 2010
  16. Erik Faye-LundNov 9, 2010
  17. Ævar Arnfjörð BjarmasonNov 9, 2010
  18. Johannes SixtNov 9, 2010
  19. Ævar Arnfjörð BjarmasonNov 9, 2010
  20. Johannes SixtNov 9, 2010
  21. Ævar Arnfjörð BjarmasonNov 9, 2010
  22. Johannes SixtNov 9, 2010
  23. Ævar Arnfjörð BjarmasonNov 9, 2010
  24. 2/5 gettextize: git-clone: !fixup "basic messages"Ævar Arnfjörð Bjarmason, Oct 31, 2010
  25. 3/5 gettextize: git-init: !fixup "basic messages"Ævar Arnfjörð Bjarmason, Oct 31, 2010
  26. 4/5 gettextize: git-revert: !fixup "Your local changes"Ævar Arnfjörð Bjarmason, Oct 31, 2010
  27. 5/5 gettextize: git-merge: !fixup "basic messages"Ævar Arnfjörð Bjarmason, Oct 31, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.