Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CELEBORN-1787] Fix netty memory metrics was not registered when enable memory allocator share #3007

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.celeborn.common.network.util;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -124,19 +123,11 @@ private static PooledByteBufAllocator createPooledByteBufAllocator(
* parameter value.
*/
public static synchronized PooledByteBufAllocator getSharedPooledByteBufAllocator(
CelebornConf conf, AbstractSource source, boolean allowCache) {
CelebornConf conf, boolean allowCache) {
final int index = allowCache ? 0 : 1;
if (_sharedPooledByteBufAllocator[index] == null) {
_sharedPooledByteBufAllocator[index] =
createPooledByteBufAllocator(true, allowCache, conf.networkAllocatorArenas());
if (source != null) {
new NettyMemoryMetrics(
_sharedPooledByteBufAllocator[index],
"shared-pool-" + index,
conf.networkAllocatorVerboseMetric(),
source,
Collections.emptyMap());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should remove create NettyMemoryMetrics here

}
return _sharedPooledByteBufAllocator[index];
}
Expand All @@ -148,27 +139,29 @@ public static PooledByteBufAllocator getPooledByteBufAllocator(

public static PooledByteBufAllocator getPooledByteBufAllocator(
TransportConf conf, AbstractSource source, boolean allowCache, int coreNum) {
PooledByteBufAllocator allocator;
if (conf.getCelebornConf().networkShareMemoryAllocator()) {
return getSharedPooledByteBufAllocator(
conf.getCelebornConf(),
source,
allowCache && conf.getCelebornConf().networkMemoryAllocatorAllowCache());
}
int arenas;
if (coreNum != 0) {
arenas = coreNum;
allocator =
getSharedPooledByteBufAllocator(
conf.getCelebornConf(),
allowCache && conf.getCelebornConf().networkMemoryAllocatorAllowCache());
} else {
arenas = conf.getCelebornConf().networkAllocatorArenas();
int arenas;
if (coreNum != 0) {
arenas = coreNum;
} else {
arenas = conf.getCelebornConf().networkAllocatorArenas();
}
allocator = createPooledByteBufAllocator(conf.preferDirectBufs(), allowCache, arenas);
}
PooledByteBufAllocator allocator =
createPooledByteBufAllocator(conf.preferDirectBufs(), allowCache, arenas);
if (source != null) {
String poolName = "default-netty-pool";
String poolName;
Map<String, String> labels = new HashMap<>();
String moduleName = conf.getModuleName();
if (!moduleName.isEmpty()) {
poolName = moduleName;
int index = allocatorsIndex.compute(moduleName, (k, v) -> v == null ? 0 : v + 1);
if (conf.getCelebornConf().networkMemoryAllocatorAllowCache()) {
poolName = allowCache ? "netty-shared-cache-pool" : "netty-shared-non-cache-pool";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given it also could be used on the client side, we'd better have celeborn- prefix in the name to distinguish with netty pools created by other components

Suggested change
poolName = allowCache ? "netty-shared-cache-pool" : "netty-shared-non-cache-pool";
poolName = allowCache ? "celeborn-netty-shared-cache-pool" : "celeborn-netty-shared-pool";

} else {
poolName = conf.getModuleName();
int index = allocatorsIndex.compute(poolName, (k, v) -> v == null ? 0 : v + 1);
labels.put("allocatorIndex", String.valueOf(index));
}
new NettyMemoryMetrics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ final private[worker] class StorageManager(conf: CelebornConf, workerSource: Abs
DeviceMonitor.createDeviceMonitor(conf, this, deviceInfos, tmpDiskInfos, workerSource)

val storageBufferAllocator: PooledByteBufAllocator =
NettyUtils.getPooledByteBufAllocator(new TransportConf("StorageManager", conf), null, true)
NettyUtils.getPooledByteBufAllocator(
new TransportConf("StorageManager", conf),
workerSource,
true)

// (mountPoint -> LocalFlusher)
private val (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.celeborn.common.meta.FileInfo;
import org.apache.celeborn.common.meta.MemoryFileInfo;
import org.apache.celeborn.common.meta.ReduceFileMeta;
import org.apache.celeborn.common.metrics.source.AbstractSource;
import org.apache.celeborn.common.network.util.NettyUtils;
import org.apache.celeborn.common.unsafe.Platform;
import org.apache.celeborn.service.deploy.worker.WorkerSource;
Expand All @@ -59,9 +58,8 @@ public long[] prepare(int mapCount) {
byte[] batchHeader = new byte[16];
fileInfo = new MemoryFileInfo(userIdentifier, true, new ReduceFileMeta(8 * 1024 * 1024));

AbstractSource source = Mockito.mock(AbstractSource.class);
PooledByteBufAllocator allocator =
NettyUtils.getSharedPooledByteBufAllocator(new CelebornConf(), source, false);
NettyUtils.getSharedPooledByteBufAllocator(new CelebornConf(), false);
CompositeByteBuf buffer = allocator.compositeBuffer();
fileInfo.setBuffer(buffer);

Expand Down
Loading