Skip to content

Support reading from .mo instead of .po #396

Open
@maennchen

Description

@maennchen

Now that we cleaned up the compilation, I thought it would be interesting to compare the .po / .mo performance.

Script

https://github.com/elixir-gettext/gettext/blob/846cac137f7764101d734ff8f8c9ed30c4d64dda/performance_test.exs

Gettext Files

I've used the translation catalog of hygeia, which is one of the largest OS ones I know of.

Output

Expand Details

Expo Parse - .po is 11.3 times slower and uses 8.5 times more memory
Gettext Compile - .po is 1.5 times slower and uses 1.5 times more memory

11:24:34.545 [info] Preparing .mo files

11:24:34.590 [info] Performance Test Expo Parse
Operating System: Linux
CPU Information: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Number of Available Cores: 8
Available memory: 46.76 GB
Elixir 1.17.2
Erlang 27.0.1
JIT enabled: true

Benchmark suite executing with the following configuration:
warmup: 5 s
time: 1 min
memory time: 2 s
reduction time: 0 ns
parallel: 8
inputs: none specified
Estimated total run time: 2 min 14 s

Benchmarking expo_po_parse ...
Benchmarking expo_mo_parse ...
Calculating statistics...
Formatting results...

Name                    ips        average  deviation         median         99th %
expo_mo_parse         84.78       11.79 ms    ±15.96%       11.56 ms       17.48 ms
expo_po_parse          7.52      132.95 ms    ±22.55%      125.54 ms      251.71 ms

Comparison: 
expo_mo_parse         84.78
expo_po_parse          7.52 - 11.27x slower +121.15 ms

Memory usage statistics:

Name                  average  deviation         median         99th %
expo_mo_parse         3.96 MB     ±0.00%        3.96 MB        3.96 MB
expo_po_parse        33.67 MB     ±0.00%       33.67 MB       33.67 MB

Comparison: 
expo_mo_parse         3.96 MB
expo_po_parse        33.67 MB - 8.51x memory usage +29.71 MB

11:26:48.993 [info] Performance Test Gettext Backend Compile
Operating System: Linux
CPU Information: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Number of Available Cores: 8
Available memory: 46.76 GB
Elixir 1.17.2
Erlang 27.0.1
JIT enabled: true

Benchmark suite executing with the following configuration:
warmup: 5 s
time: 1 min
memory time: 2 s
reduction time: 0 ns
parallel: 8
inputs: none specified
Estimated total run time: 2 min 14 s

Benchmarking gettext_po_compile ...
Benchmarking gettext_mo_compile ...
Calculating statistics...
Formatting results...

Name                         ips        average  deviation         median         99th %
gettext_mo_compile         0.123         8.10 s     ±2.45%         8.12 s         8.63 s
gettext_po_compile        0.0818        12.23 s     ±2.29%        12.25 s        12.73 s

Comparison: 
gettext_mo_compile         0.123
gettext_po_compile        0.0818 - 1.51x slower +4.13 s

Memory usage statistics:

Name                       average  deviation         median         99th %
gettext_mo_compile       118.33 MB     ±0.00%      118.33 MB      118.33 MB
gettext_po_compile       173.44 MB     ±0.02%      173.44 MB      173.47 MB

Comparison: 
gettext_mo_compile       118.33 MB
gettext_po_compile       173.44 MB - 1.47x memory usage +55.11 MB

Based on those numbers, we should consider supporting to compile from .mo instead of .po if the user requests it.

EDIT: elixir-gettext/expo#141 will improve it slightly to 1.45 times slower and 1.28 times more memory for the backend compile, but still doesn't come close.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions