Skip to content

Commit e83c9da

Browse files
Prashant Palmeta-codesync[bot]
authored andcommitted
Plumb WeightTracker through push path for memory tracking
Summary: Pass a WeightObserver through receive_pack → parse_pack for future push memory tracking. The observer is created via a new JustKnob scm/mononoke:git_server_enable_push_memory_tracking (separate from the existing fetch tracking JK which is already enabled for all repos). This diff only adds the plumbing — the observer is passed but not yet used in the processing loop. The actual weight tracking will be added in a follow-up diff. landed-with-radar-review Differential Revision: D100177592 fbshipit-source-id: f4430bc0dbffcbf7ca06190840544c1d25159c80
1 parent 0d20c81 commit e83c9da

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

eden/mononoke/git/protocol/src/pack_processor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use scuba_ext::FutureStatsScubaExt;
4848
use sha1::Digest;
4949
use sha1::Sha1;
5050
use tempfile::Builder;
51+
use weight_observer::WeightObserver;
5152

5253
use crate::PACKFILE_SUFFIX;
5354

@@ -200,6 +201,7 @@ pub async fn parse_pack(
200201
ctx: &CoreContext,
201202
blobstore: Arc<RepoBlobstore>,
202203
concurrency: usize,
204+
_weight_observer: Option<Arc<dyn WeightObserver>>,
203205
) -> Result<FxHashMap<ObjectId, ObjectContent>> {
204206
// If the packfile is empty, return an empty object map. This can happen when the push only has ref create/update
205207
// pointing to existing commit or just ref deletes

eden/mononoke/servers/git/git_server/src/write/receive_pack.rs

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ use packetline::encode::write_text_packetline;
3131
use protocol::pack_processor::parse_pack;
3232
use repo_blobstore::RepoBlobstoreArc;
3333
use scuba_ext::FutureStatsScubaExt;
34+
use sharding_observability::WeightTracker;
3435
use tracing::info;
36+
use weight_observer::WeightObserver;
3537

3638
use crate::command::Command;
3739
use crate::command::PushArgs;
@@ -126,15 +128,45 @@ async fn push(
126128
}
127129
let concurrency = request_context.pushvars.concurrency();
128130

131+
// Create a WeightTracker for push operations so ShardManager can see
132+
// push memory pressure via estimated_memory_bytes counter.
133+
let weight_observer: Option<Arc<dyn WeightObserver>> = if justknobs::eval(
134+
"scm/mononoke:git_server_enable_push_memory_tracking",
135+
None,
136+
Some(repo_name.as_str()),
137+
)
138+
.unwrap_or(false)
139+
{
140+
let main_client_id = request_context
141+
.ctx
142+
.metadata()
143+
.client_info()
144+
.and_then(|ci| ci.request_info.as_ref())
145+
.and_then(|ri| ri.main_id.clone());
146+
Some(WeightTracker::new(
147+
request_context.ctx.fb,
148+
repo_name.clone(),
149+
main_client_id.as_deref(),
150+
))
151+
} else {
152+
None
153+
};
154+
129155
// Parse the packfile provided as part of the push and verify that its valid
130-
let parsed_objects = parse_pack(pack_file.split().1, ctx, blobstore.clone(), concurrency)
131-
.try_timed()
132-
.await?
133-
.log_future_stats(
134-
scuba.clone(),
135-
"Parsed complete Packfile",
136-
"Push".to_string(),
137-
);
156+
let parsed_objects = parse_pack(
157+
pack_file.split().1,
158+
ctx,
159+
blobstore.clone(),
160+
concurrency,
161+
weight_observer,
162+
)
163+
.try_timed()
164+
.await?
165+
.log_future_stats(
166+
scuba.clone(),
167+
"Parsed complete Packfile",
168+
"Push".to_string(),
169+
);
138170
drop(pack_file);
139171

140172
// Generate the GitObjectStore using the parsed objects

0 commit comments

Comments
 (0)