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

Website issue tracker link and better search performance #6483

Merged
merged 2 commits into from
Dec 23, 2020

Conversation

xFrednet
Copy link
Member

This PR implements some improvements to the website:

  1. Added a "Search on Github" link to the "Known problems" section (Closes idea: put link to github ticket search into "known problems" field #5386)
    example_3

    Another mock up I created with the GitHub logo

    example_2

  2. Only starting the search after three letters and improving the search performance in general. (Followup Adapted the website search for better matching #6477)

Testing

These changes can be tested locally by:

  1. Clone this branch
  2. Download the current lint index from the gh-pages branch
  3. Put it next to the util/gh-pages/index.html and open the html file. Make sure that it can load the lint data. (Browsers can be a bit iffy when opening a local html page and loading data)

Sources for search performance:

  1. A stackoverflow about angular filter performance
    • I selected a search debounce of 50ms that's fast enough to catch fast deletion and typing but responsive enough to not bother the user
  2. A stackoverflow about string comparison speeds
  3. JS benchmarks for string search performance (indexOf seams to be the best)

Note: The performance is still a bit poor when going from a specific lint to no search filter. I suspect that angular is recreating all lint items when the filter is cleared causing a major lag spike. The filter functions is at least optimized for little to no search.


changelog: Added a "Search on GitHub" link to the website

@rust-highfive
Copy link

r? @Manishearth

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 20, 2020
@Manishearth
Copy link
Member

r? @killercup since you wrote the lint listing page

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

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

Thanks for the ping Manish!

This looks solid -- the only question I have before approving: Is the " "->"_" thing I commented on on purpose?

Also I can't belive there are enough lints an docs now to make the naive solution slow. Great work everyone! This is an amazing problem to have!

@@ -216,40 +233,31 @@ <h4 class="list-group-item-heading">
};

$scope.bySearch = function (lint, index, array) {
let search_str = $scope.search;
let searchStr = $scope.search;
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for js-ifying this!


// Search by id
let id_search = search_str.trim().replace(/(\-| )/g, "_");
if (lint.id.includes(id_search)) {
if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
Copy link
Member

Choose a reason for hiding this comment

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

The previous code also replaced spaces with underscores. Not sure if this is still desired but I at least wanted to point it out :)

Copy link
Member Author

@xFrednet xFrednet Dec 22, 2020

Choose a reason for hiding this comment

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

Jup this is on purpose. The space search is now covered by line 252 if (lint.id.indexOf(therms[index]) !== -1) this allows the words to be out of order which is likely when somebody just types them in. It could also reduce performance since we are not using a regex in the replace function, but I'm not sure about that :)

Copy link
Member

Choose a reason for hiding this comment

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

Ah of course, that makes sense!

(I would expect any decent JS enngine to optimize the simple regex to a byte match so it's probably as fast as the literal replace.)

@@ -180,6 +181,22 @@ <h4 class="list-group-item-heading">
}
}

function searchLint(lint, therm) {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for pulling this out. As an aside, I think therm should be term here and below?

Copy link
Member Author

Choose a reason for hiding this comment

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

Spelling is not always my strong suite 😅 thanks for pointing that out. It should be fixed now 🙃

Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

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

Thanks for the quick reply, looks good to me!


// Search by id
let id_search = search_str.trim().replace(/(\-| )/g, "_");
if (lint.id.includes(id_search)) {
if (lint.id.indexOf(searchStr.replace("-", "_")) !== -1) {
Copy link
Member

Choose a reason for hiding this comment

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

Ah of course, that makes sense!

(I would expect any decent JS enngine to optimize the simple regex to a byte match so it's probably as fast as the literal replace.)

@killercup
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 23, 2020

📌 Commit f055e7f has been approved by killercup

@bors
Copy link
Collaborator

bors commented Dec 23, 2020

⌛ Testing commit f055e7f with merge 5c98135...

@bors
Copy link
Collaborator

bors commented Dec 23, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: killercup
Pushing 5c98135 to master...

@bors bors merged commit 5c98135 into rust-lang:master Dec 23, 2020
@xFrednet xFrednet deleted the 5386-github-ticket-search branch July 28, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

idea: put link to github ticket search into "known problems" field
5 participants