@@ -185,15 +185,17 @@ definitionDependents codebase name nameSearch = do
185185 & Set. mapMaybe dependencyToComponentHash
186186 & Set. toList
187187 -- Check whether the components we're getting dependents of contain multiple elements.
188- containsMultiElementComponent <- any (> 1 ) <$> Codebase. componentSizeOf traversed componentHashes
189- (dependentTerms, dependentTypes) <- fold <$> Codebase. definitionComponentDirectDependentsOf codebase traversed componentHashes
188+ containsMultiElementComponent <- transactionSpan " checking-component-sizes" mempty $ do
189+ any (> 1 ) <$> Codebase. componentSizeOf traversed componentHashes
190+ (dependentTerms, dependentTypes) <- transactionSpan " resolving-dependents" mempty $ do
191+ fold <$> Codebase. definitionComponentDirectDependentsOf codebase traversed componentHashes
190192 -- TODO: If the component we're getting dependents of contains multiple elements then we should really
191193 -- fully load each of the dependents and check whether they depend on the correct component
192194 -- element, but this going to significantly slow things down and the results will be
193195 -- _mostly_ right without it, so we can likely put this off until later.
194196 -- If we end up changing the storage format we may be able to do this check directly in the
195197 -- DB instead.
196- when containsMultiElementComponent do
198+ when containsMultiElementComponent $ transactionSpan " multi-element-queries " mempty do
197199 Logging. logInfoText " Encountered a multi-element component when getting definition dependents. Results may be inaccurate."
198200 (termRefIds, typeRefIds) <- PG. pipelined $ do
199201 termRefIds <- Codebase. expectRefIdsByTermIdsOf traversed (Set. toList dependentTerms)
@@ -232,11 +234,12 @@ definitionDependentResults ::
232234 m [DefinitionSearchResult ]
233235definitionDependentResults codebase codeCache hqName project branchRef np mayWidth = do
234236 let nameSearch = PGNameSearch. nameSearchForPerspective np
235- deps <- definitionDependents codebase hqName nameSearch
236- ppe <- PPED. unsuffixifiedPPE <$> PPEPostgres. ppedForReferences np deps
237+ deps <- transactionSpan " getting dependents" mempty $ do
238+ definitionDependents codebase hqName nameSearch
239+ ppe <- transactionSpan " building-ppe" mempty $ PPED. unsuffixifiedPPE <$> PPEPostgres. ppedForReferences np deps
237240 let allRefs = Set. toList $ dependenciesToReferences deps
238241 let (allTerms, allTypes) = partitionEithers allRefs
239- liftA2 (<>) (doTerms ppe allTerms) (doTypes ppe allTypes)
242+ transactionSpan " building-results " mempty $ liftA2 (<>) (doTerms ppe allTerms) (doTypes ppe allTypes)
240243 where
241244 doTerms :: PPE. PrettyPrintEnv -> [TermReference ] -> m [DefinitionSearchResult ]
242245 doTerms ppe termRefs = do
@@ -246,12 +249,14 @@ definitionDependentResults codebase codeCache hqName project branchRef np mayWid
246249 let v2Referents = CV. referent1to2 <$> referentsMap
247250 let fqns = HQ'. toName <$> hqFqns
248251 typs <-
249- Codebase. loadTypesOfReferentsOf codebase traversed v2Referents
250- <&> catMaybes
252+ transactionSpan " load-types-of-referents" mempty $ do
253+ Codebase. loadTypesOfReferentsOf codebase traversed v2Referents
254+ <&> catMaybes
251255 let combined = Data. zip3 v2Referents typs (Just <$> fqns)
252256 termSummaries <-
253- Summary. termSummariesForReferentsOf np mayWidth traversed combined
254- <&> fmap ToTTermSummary
257+ transactionSpan " load-term-summaries" mempty $ do
258+ Summary. termSummariesForReferentsOf np mayWidth traversed combined
259+ <&> fmap ToTTermSummary
255260 Data. zipWith2 fqns termSummaries (\ fqn summary -> DefinitionSearchResult {fqn, summary, project, branchRef})
256261 & Map. elems
257262 & pure
0 commit comments