Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reading from .mo instead of .po #396

Open
maennchen opened this issue Sep 5, 2024 · 1 comment
Open

Support reading from .mo instead of .po #396

maennchen opened this issue Sep 5, 2024 · 1 comment

Comments

@maennchen
Copy link
Member

maennchen commented Sep 5, 2024

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.

@maennchen
Copy link
Member Author

Updated Numbers from Expo Metadata Stripping (#398)

Expand Details

Expo Parse - .po is 11.7 times slower and uses 8.5 times more memory
Expo Parse - .po with metadata stripping is 5.0 times slower and uses 2.8 times more memory
Gettext Compile - .po is 1.4 times slower and uses 1.3 times more memory

08:37:11.016 [info] Preparing .mo files

08:37:11.068 [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: 3 min 21 s

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

Name                                 ips        average  deviation         median         99th %
expo_mo_parse                      73.26       13.65 ms    ±26.63%       12.86 ms       28.36 ms
expo_po_runtime_only_parse         14.71       67.96 ms    ±18.68%       65.42 ms      108.59 ms
expo_po_parse                       6.24      160.27 ms    ±22.91%      151.16 ms      275.76 ms

Comparison: 
expo_mo_parse                      73.26
expo_po_runtime_only_parse         14.71 - 4.98x slower +54.31 ms
expo_po_parse                       6.24 - 11.74x slower +146.62 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_runtime_only_parse        11.20 MB     ±0.00%       11.20 MB       11.20 MB
expo_po_parse                     33.67 MB     ±0.00%       33.67 MB       33.67 MB

Comparison: 
expo_mo_parse                      3.96 MB
expo_po_runtime_only_parse        11.20 MB - 2.83x memory usage +7.24 MB
expo_po_parse                     33.67 MB - 8.51x memory usage +29.71 MB

08:40:32.577 [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.116         8.66 s     ±3.22%         8.69 s         9.16 s
gettext_po_compile        0.0801        12.48 s     ±4.56%        12.43 s        13.98 s

Comparison: 
gettext_mo_compile         0.116
gettext_po_compile        0.0801 - 1.44x slower +3.83 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       151.73 MB     ±0.00%      151.73 MB      151.73 MB

Comparison: 
gettext_mo_compile       118.33 MB
gettext_po_compile       151.73 MB - 1.28x memory usage +33.39 MB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant