Skip to content

Commit 674babc

Browse files
ZalatharMuscraft
authored andcommitted
Rollup merge of rust-lang#146484 - notriddle:stringdex-js-opt, r=GuillaumeGomez
rustdoc-search: JavaScript optimization based on Firefox Profiler output Part of rust-lang#146048 Preview: https://notriddle.com/rustdoc-html-demo-12/stringdex-js-opt/std/index.html These commits are based on some profiler readings, and should reduce CPU usage for name-based searching. - The first commit improves warm searches by allocating less garbage when data is already loaded: Before: https://profiler.firefox.com/public/wvzd88m8r70p8frvz1z628tv3htwna0b9c0ef10/calltree/?globalTrackOrder=0w2&implementation=js&thread=3&v=11 After: https://profiler.firefox.com/public/yfe9aq6ep3kacw3zmr7jqn6gv7ckfq86rg89568/calltree/?globalTrackOrder=0w2&implementation=js&thread=3&v=11 - The second commit improves cold searches by delaying load for special type names until type-based search runs Before: 5.86s (throttled to "Good 2G" in Dev Tools) <https://doc.rust-lang.org/nightly/std/index.html?search=> <img width="2524" height="919" alt="image" src="https://github.com/user-attachments/assets/8dbbbd46-b7ab-4e3c-9e8c-f1e41cfaa968" /> After: 5.77s (throttled to "Good 2G" in Dev Tools) <https://notriddle.com/rustdoc-html-demo-12/stringdex-js-opt/std/index.html?search=> <img width="2524" height="912" alt="image" src="https://github.com/user-attachments/assets/6976a584-24f4-4d47-8118-7a81b22d411e" /> For comparison's sake, the same test takes 12.17s on stable <https://doc.rust-lang.org/1.89.0/std/index.html?search=> <img width="2525" height="916" alt="image" src="https://github.com/user-attachments/assets/eb6df2e8-6632-4bef-a6d0-5179c6288fd0" />
2 parents 41a5f94 + 277e845 commit 674babc

File tree

4 files changed

+290
-140
lines changed

4 files changed

+290
-140
lines changed

src/librustdoc/html/static/js/rustdoc.d.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ declare namespace rustdoc {
348348
returned: rustdoc.QueryElement[],
349349
is_alias: boolean,
350350
alias?: string,
351-
original?: rustdoc.Rlow,
351+
item: rustdoc.Row,
352352
}
353353

354354
/**
@@ -533,4 +533,27 @@ declare namespace rustdoc {
533533
* Generated by `render_call_locations` in `render/mod.rs`.
534534
*/
535535
type ScrapedLoc = [[number, number], string, string]
536+
537+
/**
538+
* Each of these identifiers are used specially by
539+
* type-driven search. Most of them are lang items
540+
* in the compiler.
541+
*/
542+
type TypeNameIds = {
543+
"typeNameIdOfOutput": number,
544+
"typeNameIdOfFnPtr": number,
545+
"typeNameIdOfFn": number,
546+
"typeNameIdOfFnMut": number,
547+
"typeNameIdOfFnOnce": number,
548+
"typeNameIdOfArray": number,
549+
"typeNameIdOfSlice": number,
550+
"typeNameIdOfArrayOrSlice": number,
551+
"typeNameIdOfTuple": number,
552+
"typeNameIdOfUnit": number,
553+
"typeNameIdOfTupleOrUnit": number,
554+
"typeNameIdOfReference": number,
555+
"typeNameIdOfPointer": number,
556+
"typeNameIdOfHof": number,
557+
"typeNameIdOfNever": number,
558+
};
536559
}

0 commit comments

Comments
 (0)