Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit e578f0a

Browse files
log small and large digests separately
Summary: Small and large digests have very different perf characteristics (e.g. they use different storages like zippy and manifold), so it would be great to tell them apart in our logging to better understand what storage is used. This is what this diff does. Reviewed By: stepancheg fbshipit-source-id: ecfc75774ae0d027d2a5be7865296a8fa58ae0c8
1 parent 20d29c8 commit e578f0a

8 files changed

+269
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.facebook.buck.remoteexecution.event;
18+
19+
/**
20+
* Class that's used to store info about a batch of blobs upload or downloaded from CAS. This class
21+
* is primarily used for logging
22+
*/
23+
public class CasBlobBatchInfo {
24+
// "Large" and "small" digests go to different backends (e.g. zippy and manifold),
25+
// so it makes sense to split them in two. See https://fburl.com/code/saw12ezj.
26+
private static final int LARGE_DIGEST_THRESHOLD = 2621440; // 2.5mb
27+
28+
private final int smallBlobCount;
29+
private final long smallSizeBytes;
30+
private final int largeBlobCount;
31+
private final long largeSizeBytes;
32+
33+
public CasBlobBatchInfo(long[] digestSizes) {
34+
int smallBlobCount = 0;
35+
long smallSizeBytes = 0;
36+
int largeBlobCount = 0;
37+
long largeSizeBytes = 0;
38+
39+
for (long digestSize : digestSizes) {
40+
if (digestSize <= LARGE_DIGEST_THRESHOLD) {
41+
smallBlobCount += 1;
42+
smallSizeBytes += digestSize;
43+
} else {
44+
largeBlobCount += 1;
45+
largeSizeBytes += digestSize;
46+
}
47+
}
48+
49+
this.smallBlobCount = smallBlobCount;
50+
this.smallSizeBytes = smallSizeBytes;
51+
this.largeBlobCount = largeBlobCount;
52+
this.largeSizeBytes = largeSizeBytes;
53+
}
54+
55+
public int getSmallBlobCount() {
56+
return smallBlobCount;
57+
}
58+
59+
public long getSmallBlobSize() {
60+
return smallSizeBytes;
61+
}
62+
63+
public int getLargeBlobCount() {
64+
return largeBlobCount;
65+
}
66+
67+
public long getLargeBlobSize() {
68+
return largeSizeBytes;
69+
}
70+
71+
public int getBlobCount() {
72+
return getSmallBlobCount() + getLargeBlobCount();
73+
}
74+
75+
public long getBlobSize() {
76+
return getSmallBlobSize() + getLargeBlobSize();
77+
}
78+
}

src/com/facebook/buck/remoteexecution/event/CasBlobDownloadEvent.java

+23-9
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,43 @@ public String getEventName() {
3434
}
3535

3636
/** Send the Started and returns a Scoped object that sends the Finished event. */
37-
public static Scope sendEvent(final BuckEventBus eventBus, int blobCount, long sizeBytes) {
38-
final Started startedEvent = new Started(blobCount, sizeBytes);
37+
public static Scope sendEvent(final BuckEventBus eventBus, CasBlobBatchInfo batchInfo) {
38+
final Started startedEvent = new Started(batchInfo);
3939
eventBus.post(startedEvent);
4040
return () -> eventBus.post(new Finished(startedEvent));
4141
}
4242

4343
/** Download to the CAS has started. */
4444
public static final class Started extends CasBlobDownloadEvent {
45-
private final int blobCount;
46-
private final long sizeBytes;
45+
private final CasBlobBatchInfo batchInfo;
4746

48-
public Started(int blobCount, long sizeBytes) {
47+
public Started(CasBlobBatchInfo batchInfo) {
4948
super(EventKey.unique());
50-
this.blobCount = blobCount;
51-
this.sizeBytes = sizeBytes;
49+
this.batchInfo = batchInfo;
5250
}
5351

5452
public int getBlobCount() {
55-
return blobCount;
53+
return batchInfo.getBlobCount();
54+
}
55+
56+
public int getSmallBlobCount() {
57+
return batchInfo.getSmallBlobCount();
58+
}
59+
60+
public int getLargeBlobCount() {
61+
return batchInfo.getLargeBlobCount();
5662
}
5763

5864
public long getSizeBytes() {
59-
return sizeBytes;
65+
return batchInfo.getBlobSize();
66+
}
67+
68+
public long getSmallSizeBytes() {
69+
return batchInfo.getSmallBlobSize();
70+
}
71+
72+
public long getLargeSizeBytes() {
73+
return batchInfo.getLargeBlobSize();
6074
}
6175

6276
@Override

src/com/facebook/buck/remoteexecution/event/CasBlobUploadEvent.java

+23-9
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@ protected CasBlobUploadEvent(EventKey eventKey) {
3030
}
3131

3232
/** Send the Started and returns a Scoped object that sends the Finished event. */
33-
public static Scope sendEvent(final BuckEventBus eventBus, int blobCount, long sizeBytes) {
34-
final Started startedEvent = new Started(blobCount, sizeBytes);
33+
public static Scope sendEvent(final BuckEventBus eventBus, CasBlobBatchInfo info) {
34+
final Started startedEvent = new Started(info);
3535
eventBus.post(startedEvent);
3636
return () -> eventBus.post(new Finished(startedEvent));
3737
}
3838

3939
/** Upload to the CAS has started. */
4040
public static class Started extends CasBlobUploadEvent {
41-
private final int blobCount;
42-
private final long sizeBytes;
41+
private final CasBlobBatchInfo batchInfo;
4342

4443
@VisibleForTesting
45-
Started(int blobCount, long sizeBytes) {
44+
Started(CasBlobBatchInfo info) {
4645
super(EventKey.unique());
47-
this.blobCount = blobCount;
48-
this.sizeBytes = sizeBytes;
46+
this.batchInfo = info;
4947
}
5048

5149
@Override
@@ -54,11 +52,27 @@ protected String getValueString() {
5452
}
5553

5654
public int getBlobCount() {
57-
return blobCount;
55+
return batchInfo.getBlobCount();
56+
}
57+
58+
public int getSmallBlobCount() {
59+
return batchInfo.getSmallBlobCount();
60+
}
61+
62+
public int getLargeBlobCount() {
63+
return batchInfo.getLargeBlobCount();
5864
}
5965

6066
public long getSizeBytes() {
61-
return sizeBytes;
67+
return batchInfo.getBlobSize();
68+
}
69+
70+
public long getSmallSizeBytes() {
71+
return batchInfo.getSmallBlobSize();
72+
}
73+
74+
public long getLargeSizeBytes() {
75+
return batchInfo.getLargeBlobSize();
6276
}
6377
}
6478

src/com/facebook/buck/remoteexecution/event/CasFindMissingEvent.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,31 @@ protected CasFindMissingEvent(EventKey eventKey) {
3030
}
3131

3232
/** Send the Started and returns a Scoped object that sends the Finished event. */
33-
public static Scope sendEvent(final BuckEventBus eventBus, int blobCount) {
34-
final CasFindMissingEvent.Started startedEvent = new CasFindMissingEvent.Started(blobCount);
33+
public static Scope sendEvent(final BuckEventBus eventBus, CasBlobBatchInfo info) {
34+
final CasFindMissingEvent.Started startedEvent = new CasFindMissingEvent.Started(info);
3535
eventBus.post(startedEvent);
3636
return () -> eventBus.post(new CasFindMissingEvent.Finished(startedEvent));
3737
}
3838

3939
/** FindMissing call has started. */
4040
public static final class Started extends CasFindMissingEvent {
41-
private final int blobCount;
41+
private final CasBlobBatchInfo batchInfo;
4242

43-
public Started(int blobCount) {
43+
public Started(CasBlobBatchInfo batchInfo) {
4444
super(EventKey.unique());
45-
this.blobCount = blobCount;
45+
this.batchInfo = batchInfo;
4646
}
4747

4848
public int getBlobCount() {
49-
return blobCount;
49+
return batchInfo.getBlobCount();
50+
}
51+
52+
public int getSmallBlobCount() {
53+
return batchInfo.getSmallBlobCount();
54+
}
55+
56+
public int getLargeBlobCount() {
57+
return batchInfo.getLargeBlobCount();
5058
}
5159

5260
@Override

src/com/facebook/buck/remoteexecution/event/RemoteExecutionStatsProvider.java

+30
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,48 @@ public interface RemoteExecutionStatsProvider {
2828
/** Total number of downloads. */
2929
int getCasDownloads();
3030

31+
/** Number of "small" downloads (usually go to zippy). */
32+
int getCasSmallDownloads();
33+
34+
/** Number of "large" downloads (usually go to manifold). */
35+
int getCasLargeDownloads();
36+
37+
/** Number of "small" downloaded bytes from CAS. */
38+
long getCasSmallDownloadSizeBytes();
39+
40+
/** Number of "large" downloaded bytes from CAS. */
41+
long getCasLargeDownloadSizeBytes();
42+
3143
/** Total number of downloaded bytes from CAS. */
3244
long getCasDownloadSizeBytes();
3345

3446
/** Total number of downloads. */
3547
int getCasUploads();
3648

49+
/** Number of "small" uploads (usually go to zippy). */
50+
int getCasSmallUploads();
51+
52+
/** Number of "large" uploads (usually go to manifold). */
53+
int getCasLargeUploads();
54+
55+
/** Number of "small" uploaded bytes from CAS. */
56+
long getCasSmallUploadSizeBytes();
57+
58+
/** Number of "large" uploaded bytes from CAS. */
59+
long getCasLargeUploadSizeBytes();
60+
3761
/** Total of uploaded bytes to CAS. */
3862
long getCasUploadSizeBytes();
3963

4064
/** Total number of digests that were sent in findMissing calls. */
4165
long getCasFindMissingCount();
4266

67+
/** Number of small digests that were sent in findMissing calls. */
68+
long getCasFindMissingSmallCount();
69+
70+
/** Number of large digests that were sent in findMissing calls. */
71+
long getCasFindMissingLargeCount();
72+
4373
/** Get the total number of BuildRules that are finished. (both local and remote) */
4474
int getTotalRulesBuilt();
4575

0 commit comments

Comments
 (0)