Thanks to visit codestin.com
Credit goes to github.com

Skip to content

std.typecons: Make Nullable.toString always a template #10767

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VPanteleev-S7
Copy link
Contributor

Because some overloads of Nullable!T.toString are not templates, instantiating a Nullable!T also always instantiates formatValue!T, and all of its dependencies.

For large type hierarchies, this can add a significant amount of compilation overhead.

We can avoid this by making remaining overloads of Nullable!T.toString templates as well, similar to Tuple.

Timings from internal motivating use case:

Before:

9.00user 1.38system 0:10.57elapsed 98%CPU (0avgtext+0avgdata 5851516maxresident)k
21968inputs+48144outputs (0major+1468687minor)pagefaults 0swaps

After:

5.11user 0.61system 0:05.75elapsed 99%CPU (0avgtext+0avgdata 2762392maxresident)k
0inputs+34528outputs (0major+685900minor)pagefaults 0swaps

Because some overloads of Nullable!T.toString are not templates,
instantiating a Nullable!T also always instantiates formatValue!T, and
all of its dependencies.

For large type hierarchies, this can add a significant amount of
compilation overhead.

We can avoid this by making remaining overloads of Nullable!T.toString
templates as well, similar to Tuple.

Timings from internal motivating use case:

Before:

9.00user 1.38system 0:10.57elapsed 98%CPU (0avgtext+0avgdata 5851516maxresident)k
21968inputs+48144outputs (0major+1468687minor)pagefaults 0swaps

After:

5.11user 0.61system 0:05.75elapsed 99%CPU (0avgtext+0avgdata 2762392maxresident)k
0inputs+34528outputs (0major+685900minor)pagefaults 0swaps
@VPanteleev-S7 VPanteleev-S7 marked this pull request as ready for review April 29, 2025 19:12
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.

1 participant