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

Performance optimizations rebased #1461

Closed
wants to merge 19 commits into from
Closed

Conversation

wmertens
Copy link
Contributor

@wmertens wmertens commented Feb 1, 2021

Rebase of #1277

Seems to work nicely :)

@wmertens
Copy link
Contributor Author

wmertens commented Feb 1, 2021

@jung-kim Could you check if this rebase is correct? Feel free to copy this to your PR.

@wmertens wmertens mentioned this pull request Feb 1, 2021
@wmertens
Copy link
Contributor Author

wmertens commented Feb 1, 2021

@jung-kim it's a bunch faster, but when I'm switching branches, I see commits that shouldn't be there. Known issue or wrong rebase?

@wmertens
Copy link
Contributor Author

wmertens commented Feb 2, 2021

I changed the render debounce to trailing and now it seems to work fine.

@wmertens
Copy link
Contributor Author

wmertens commented Feb 2, 2021

@jung-kim It seems that the git api changes were already merged, so now it looks like it's mostly some optimizations on rendering. I'll add comments for the things I don't understand.

@@ -95,7 +95,7 @@ class Reset extends ActionBase {
context &&
context.node() &&
remoteRef.node() != context.node() &&
remoteRef.node().date < context.node().date
remoteRef.node().timestamp < context.node().timestamp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use timestamps? Is it because numeric comparison will be a little faster?

@@ -141,22 +145,28 @@ class GitNodeViewModel extends Animateable {
} else {
this.r(15);
this.cx(610 + 90 * this.branchOrder());
this.cy(this.aboveNode ? this.aboveNode.cy() + 60 : 120);
this.cy(this.aboveNode && !isNaN(this.aboveNode.cy()) ? this.aboveNode.cy() + 60 : 120);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What case does this handle?

// push this nodes into the graph's node list to be rendered if first time.
// if been pushed before, no need to add to nodes.
this.hasBeenRenderedBefore = true;
this.graph.nodes.push(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this can push here when it wasn't rendered before and there's no removal of a push elsewhere.

When I amend the latest commit, the current branch no longer shows up and I need to reload the page. Is that due to this?

Comment on lines -178 to -208
const textBox = event.currentTarget.parentElement.querySelector('input[type="search"]');
const $textBox = $(textBox);

if (!$textBox.autocomplete('instance')) {
const renderItem = (ul, item) => $(`<li><a>${item.displayHtml()}</a></li>`).appendTo(ul);
$textBox.autocomplete({
classes: {
'ui-autocomplete': 'dropdown-menu',
},
const textBox = event.currentTarget.nextElementSibling.firstElementChild; // this may not be the best idea...
$(textBox)
.autocomplete({
source: this.refs().filter((ref) => !ref.isHEAD),
minLength: 0,
create: (event) => {
$(event.target).data('ui-autocomplete')._renderItem = renderItem;
},
select: (_event, ui) => {
select: (event, ui) => {
const ref = ui.item;
const ray = ref.isTag ? this.tagsToDisplay : this.branchesToDisplay;

// if ref is in display, remove it, else remove last in array.
ray.splice(ray.indexOf(ref), 1);
ray.unshift(ref);
this.refSearchFormVisible(false);

// Clear search input on selection
return false;
},
});
$textBox.focus((event) => {
$(event.target).autocomplete('search', event.target.value);
});
$textBox.autocomplete('search', '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code seems unrelated to optimization, not sure if this is an improvement or an accidental revert

if (!r.node()) return;
if (!r.node().timestamp) return;
if (refNodeMap[r.node().sha1]) return;
refNodeMap[r.node().sha1] = r;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually speed up things? Are there that many duplicates that the overhead of deduplicating is worth it?

@wmertens
Copy link
Contributor Author

Closing this, #1315 is much faster

@wmertens wmertens closed this Feb 21, 2021
@wmertens
Copy link
Contributor Author

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.

2 participants