Skip to content

Use optimisation level 2 - #250

Draft
tfpf wants to merge 10 commits into
mainfrom
optimisation-level-2
Draft

Use optimisation level 2#250
tfpf wants to merge 10 commits into
mainfrom
optimisation-level-2

Conversation

@tfpf

@tfpf tfpf commented Jan 21, 2026

Copy link
Copy Markdown
Owner

@tfpf tfpf linked an issue Jan 21, 2026 that may be closed by this pull request
@tfpf

tfpf commented Jan 21, 2026

Copy link
Copy Markdown
Owner Author

Hiding symbols is not required because that is already the default when using Meson. Kudos again to the Meson developers for setting sane (genius) defaults!

@tfpf

tfpf commented Jan 22, 2026

Copy link
Copy Markdown
Owner Author

There is insufficient evidence that optimisation level 2 gives better performance than level 3. The following numbers were obtained using a machine different from the one I usually run benchmarks on.

Membership Check

Optimisation Level 2
  0.00 in d 0.33 in d 0.67 in d 1.00 in d
100000 466.196116 557.165672 450.109114 445.309144
1000000 541.194241 718.284451 603.605544 490.465720
10000000 648.149269 805.398502 748.876120 589.742698
Optimisation Level 3
  0.00 in d 0.33 in d 0.67 in d 1.00 in d
100000 490.693192 565.387975 457.075284 456.654925
1000000 553.142049 719.515105 607.979110 502.855061
10000000 592.341685 810.753989 726.519562 597.176215

Insertion and Deletion

Optimisation Level 2
  set_del(d, keys_33) set_del(d, keys_67) set_del(d, keys_100)
100000 58.211082 131.633938 209.740966
1000000 74.561862 168.646467 302.007536
10000000 89.416885 262.711641 428.468641
Optimisation Level 3
  set_del(d, keys_33) set_del(d, keys_67) set_del(d, keys_100)
100000 56.350561 120.354840 187.630554
1000000 71.076539 169.000136 298.549570
10000000 88.913401 258.136030 453.049115

Iteration

Optimisation Level 2
  for _ in d: pass for _ in reversed(d): pass
100000 0.020122 0.023647
1000000 0.240947 0.300003
10000000 3.068003 3.952579
Optimisation Level 3
  for _ in d: pass for _ in reversed(d): pass
100000 0.018108 0.023875
1000000 0.233428 0.301671
10000000 3.065221 3.997450

@tfpf

tfpf commented Jan 29, 2026

Copy link
Copy Markdown
Owner Author

I see optimisation level 3 giving better performance than level 2.

See the note on Optimize Options (Using the GNU Compiler Collection (GCC)):

If you do not specify an optimization level option -O at link time, then GCC uses the highest optimization level used when compiling the object files.

which means the Meson not supplying only the LTO flag but not the CTO flag to the linker is not a problem.

@tfpf tfpf changed the title Use optimisation level 2 and hide symbols to further improve optimisation Use optimisation level 2 Jan 29, 2026
@tfpf
tfpf marked this pull request as draft January 29, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use optimisation level 2

1 participant