Avoid extra shallow class lookups in decl folding
commit6f1915c4bb30c94cad8aecc1c39251c671c092d3
authorJake Bailey <jakebailey@fb.com>
Fri, 15 Jul 2022 17:41:42 +0000 (15 10:41 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 15 Jul 2022 17:41:42 +0000 (15 10:41 -0700)
tree0f99dbbbbdc908c3c5891d1b377a7932e1b92c24
parent406b3c1ccf9dd81436530fa601f8f9fdb823519e
Avoid extra shallow class lookups in decl folding

Summary:
The default implementation of FoldedDeclProvider::get_class [uses the provider's implementation of get_type](https://www.internalfb.com/code/fbsource/%5Baae650dcab88%5D/fbcode/hphp/hack/src/rupro/hackrs/folded_decl_provider.rs?lines=125). The way that LazyFoldedDeclProvider::get_type is currently implemented involves [invoking ShallowDeclProvider::get_type](https://www.internalfb.com/code/fbsource/[aae650dcab88]/fbcode/hphp/hack/src/rupro/hackrs/folded_decl_provider/provider.rs?lines=78). If the decl is a typedef, it is returned. If it is a (shallow) class, we look at our folded classes cache and return that decl if it is present. Otherwise, we fold the class, store it in the cache, and return it.

If it is inexpensive to look up a shallow class, this is fine. But when looking up a shallow class involves deserialization and decompression, this imposes an unnecessary performance overhead in the case that the folded decl is already computed and in the folded decl provider's cache, since we don't need to look up the shallow decl at all.

If we add a get_type_kind method to ShallowDeclProvider (which can be inexpensively implemented using the naming table in the LazyShallowDeclProvider case), then we can avoid this overhead.

Reviewed By: shayne-fletcher

Differential Revision: D37840849

fbshipit-source-id: 319705cc130074b1c5d6df9bdc5e93115f34cbe4
hphp/hack/src/rupro/hackrs/folded_decl_provider/provider.rs
hphp/hack/src/rupro/hackrs/shallow_decl_provider.rs
hphp/hack/src/rupro/hackrs/shallow_decl_provider/provider.rs