-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor off heap memory management, clean shuffle writer code, remov…
…e some useless configurations
- Loading branch information
1 parent
a4cafee
commit a4f9ca6
Showing
59 changed files
with
912 additions
and
2,894 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
backends-clickhouse/src/main/java/org/apache/gluten/memory/CHThreadGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.gluten.memory; | ||
|
||
import org.apache.spark.TaskContext; | ||
import org.apache.spark.util.TaskResource; | ||
import org.apache.spark.util.TaskResources; | ||
|
||
public class CHThreadGroup implements TaskResource { | ||
|
||
/** | ||
* Register a new thread group for the current task. This method should be called at beginning of | ||
* the task. | ||
*/ | ||
public static void registerNewThreadGroup() { | ||
if (TaskResources.isResourceRegistered(CHThreadGroup.class.getName())) return; | ||
CHThreadGroup group = new CHThreadGroup(); | ||
TaskResources.addResource(CHThreadGroup.class.getName(), group); | ||
TaskContext.get() | ||
.addTaskCompletionListener( | ||
(context -> { | ||
context.taskMetrics().incPeakExecutionMemory(group.getPeakMemory()); | ||
})); | ||
} | ||
|
||
private long thread_group_id = 0; | ||
private long peak_memory = -1; | ||
|
||
private CHThreadGroup() { | ||
thread_group_id = createThreadGroup(); | ||
} | ||
|
||
public long getPeakMemory() { | ||
if (peak_memory < 0) { | ||
peak_memory = threadGroupPeakMemory(thread_group_id); | ||
} | ||
return peak_memory; | ||
} | ||
|
||
@Override | ||
public void release() throws Exception { | ||
if (peak_memory < 0) { | ||
peak_memory = threadGroupPeakMemory(thread_group_id); | ||
} | ||
releaseThreadGroup(thread_group_id); | ||
} | ||
|
||
@Override | ||
public int priority() { | ||
return TaskResource.super.priority(); | ||
} | ||
|
||
@Override | ||
public String resourceName() { | ||
return "CHThreadGroup"; | ||
} | ||
|
||
private static native long createThreadGroup(); | ||
|
||
private static native long threadGroupPeakMemory(long id); | ||
|
||
private static native void releaseThreadGroup(long id); | ||
} |
152 changes: 0 additions & 152 deletions
152
...ickhouse/src/main/java/org/apache/gluten/memory/alloc/CHManagedCHReservationListener.java
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
...ends-clickhouse/src/main/java/org/apache/gluten/memory/alloc/CHNativeMemoryAllocator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.