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

Don't assume compiler memoization #3

Open
tcsullivan opened this issue Dec 31, 2020 · 1 comment
Open

Don't assume compiler memoization #3

tcsullivan opened this issue Dec 31, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@tcsullivan
Copy link
Owner

See here.

Code like below (taken from the link) calls build_node_list three times, and there's a chance this causes the compile to recompute the list with every call. There is significant compilation overhead in this project, so I wouldn't be surprised if this is the case.

auto list = build_node_list();
auto tree = std::span(new node[tree_count()] {}, tree_count());

Need to minimize recomputation, or find ways to avoid it altogether.

@tcsullivan tcsullivan added the enhancement New feature or request label Dec 31, 2020
@tcsullivan
Copy link
Owner Author

Forced memoization for the node list, tree count, and compressed size. The JSON example now compiles ~30% faster on my desktop. The sizes are stored in constexpr static variables, while the node list became a constexpr static object with a consteval constructor.

My attempt at memoization for the node tree failed terribly (>100% increase in compile time). I did it in the same way I did for the node list, maybe I messed something up; I'll continue to look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant