From a95b41e8496809308b3208ffb91b687c0562f731 Mon Sep 17 00:00:00 2001 From: Andrea Campi Date: Fri, 13 Dec 2024 01:18:06 -0800 Subject: [PATCH] Pass the CoreContext down Summary: ## This stack We noticed that the poll time is pretty high on some async methods, and that is affecting other calls as well. Let's try to optimize that. ## This diff Small diff in preparation to keep the next diffs in the stack small. Reviewed By: lmvasquezg Differential Revision: D67136286 fbshipit-source-id: 1e06190750151b30cd9fb8546fd7e47cc11983f2 --- eden/mononoke/mononoke_api/src/sparse_profile.rs | 8 +++++--- .../mononoke/mononoke_api/src/test/test_sparse_profile.rs | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/eden/mononoke/mononoke_api/src/sparse_profile.rs b/eden/mononoke/mononoke_api/src/sparse_profile.rs index abe6145eed964..c9af39817562c 100644 --- a/eden/mononoke/mononoke_api/src/sparse_profile.rs +++ b/eden/mononoke/mononoke_api/src/sparse_profile.rs @@ -215,7 +215,7 @@ impl SparseProfileMonitoring { } }; if paths_to_calculate.is_empty().not() { - let matchers = create_matchers(changeset, paths_to_calculate).await?; + let matchers = create_matchers(ctx, changeset, paths_to_calculate).await?; let other_sizes = calculate_size(ctx, changeset, matchers).await?; let res = self .sql_sparse_profiles @@ -234,6 +234,7 @@ impl SparseProfileMonitoring { } pub(crate) async fn fetch( + _ctx: &CoreContext, path: String, changeset: &ChangesetContext, ) -> Result>> { @@ -252,6 +253,7 @@ pub(crate) async fn fetch( } async fn create_matchers( + ctx: &CoreContext, changeset: &ChangesetContext, paths: Vec, ) -> Result>> { @@ -262,7 +264,7 @@ async fn create_matchers( let profile = sparse::Root::from_bytes(content.as_bytes(), dummy_source) .with_context(|| format!("while constructing Profile for source {path}"))?; let matcher = profile - .matcher(|path| fetch(path, changeset)) + .matcher(|path| fetch(ctx, path, changeset)) .await .with_context(|| format!("While constructing matcher for source {path}"))?; anyhow::Ok(( @@ -448,7 +450,7 @@ pub async fn get_profile_delta_size( other: &ChangesetContext, paths: Vec, ) -> Result, MononokeError> { - let matchers = create_matchers(current, paths).await?; + let matchers = create_matchers(ctx, current, paths).await?; calculate_delta_size(ctx, monitor, current, other, matchers).await } diff --git a/eden/mononoke/mononoke_api/src/test/test_sparse_profile.rs b/eden/mononoke/mononoke_api/src/test/test_sparse_profile.rs index 0db911cff4352..11ed35175f74c 100644 --- a/eden/mononoke/mononoke_api/src/test/test_sparse_profile.rs +++ b/eden/mononoke/mononoke_api/src/test/test_sparse_profile.rs @@ -245,9 +245,11 @@ async fn sparse_profile_parsing(fb: FacebookInit) -> Result<()> { let changeset = ChangesetContext::new(repo_ctx, a); let path = "sparse/include".to_string(); - let content = fetch(path.clone(), &changeset).await?.unwrap(); + let content = fetch(&ctx, path.clone(), &changeset).await?.unwrap(); let profile = sparse::Root::from_bytes(content, path)?; - let matcher = profile.matcher(|path| fetch(path, &changeset)).await?; + let matcher = profile + .matcher(|path| fetch(&ctx, path, &changeset)) + .await?; assert!(!matcher.matches_file(RepoPath::from_str("1")?)?); assert!(!matcher.matches_file(RepoPath::from_str("dir1/file1")?)?);