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

Various non productive overhead #482

Closed
pacak opened this issue Mar 11, 2024 · 1 comment · Fixed by #483
Closed

Various non productive overhead #482

pacak opened this issue Mar 11, 2024 · 1 comment · Fixed by #483

Comments

@pacak
Copy link
Contributor

pacak commented Mar 11, 2024

I noticed that argmin collects statistics about how many times functions are called, for example here and in a few other places

fn func_counts<O>(&mut self, problem: &Problem<O>) {
for (k, &v) in problem.counts.iter() {
let count = self.counts.entry(k.to_string()).or_insert(0);
*count = v
}
}

Both allocations and hashing can be expensive compared to solving, in fact I hacked examples/newton to skip console logging and to run the computation a bunch more times taking care of blackboxing the results - counting is responsible for about 20% of all the time.

And if I disable timing (Executor::timer) along with removing counting - newton example is suddenly 30% faster...

Any objections if I try to shove it out of the way? Timing doesn't seem to be used unless there are observers - should probably be disabled unless needed, counting can probably be made optional or made into observer, not 100% sure yet.

@stefan-k
Copy link
Member

That's not great. Thanks for investigating! I agree, both should be disabled if no observers are used. And even if observers are used, it should be possible to turn off function counting. A PR would be highly welcome! The only thing I would object to is turning function counting into an observer, because I plan to add stopping criteria based on the number of function evaluations in the future.

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 a pull request may close this issue.

2 participants