-
Notifications
You must be signed in to change notification settings - Fork 20
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
More BLeSS efficiencies #434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, the only suggestion I have is to move the string index sort to StringUtilities so that it can be used more broadly.
@@ -21,6 +23,28 @@ | |||
|
|||
using namespace RevBayesCore; | |||
|
|||
/*! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to add this function to StringUtilities?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point – moved it there!
The requested changes were implemented.
Some additional improvements to the performance of ln(pdf), again following very helpful suggestions by Claudio Kozický (@qak). The main changes are as follows:
(1) The "alignment" of the average distance matrix and the distance matrix of a proposed tree (i.e., the step of ensuring that we are subtracting distances corresponding to the same pair of taxa) is done using
std::sort
rather thanstd::find
, which is up to two orders of magnitude faster for 10,000-by-10,000 matrices;(2) Indexing is done using
uint32_t
rather thansize_t
, which speeds up memory access (and consequently, the matrix subtraction step).In practice, the performance improvement gained by these changes can be difficult to observe, because the total amount of time spent on evaluating the (log) probability density of a proposed tree is now dominated by the time it takes to convert the tree to a distance matrix. However, some experimentation with
std::chrono::steady_clock
will show that the ln(pdf) calculation implemented in this branch is about 12% faster for 10,000-by-10,000 matrices (~0.63 vs. ~0.55 s).