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

Speed up how node names are processed on initialization #462

Closed
fedarko opened this issue Dec 11, 2020 · 0 comments · Fixed by #466
Closed

Speed up how node names are processed on initialization #462

fedarko opened this issue Dec 11, 2020 · 0 comments · Fixed by #466

Comments

@fedarko
Copy link
Collaborator

fedarko commented Dec 11, 2020

Just making a record of this here so we don't forget it. (@kwcantrell and @ElDeveloper did all the work of finding this!!!)

Relates to the tree shown in this twitter thread. Basically, when there are a ton of node names, this block of code:

var nodeNames = this._tree.getAllNames();
// Don't include nodes with the name null (i.e. nodes without a
// specified name in the Newick file) in the auto-complete.
nodeNames = nodeNames.filter((n) => n !== null);
// Sort node names case insensitively
nodeNames.sort(function (a, b) {
return a.localeCompare(b, "en", { sensitivity: "base" });
});
nodeNames = _.uniq(nodeNames);

... slows things down a lot, because string comparisons are slow.

There are many possible ways we could handle this (better algorithms / data structures in JS, preprocessing stuff in Python, etc.) -- it's probably most important right now just to implement something that fixes this, since this is a pretty significant bottleneck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant