-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(interactive): Introduce
MetricsTool
to profile memory usage, pe…
…nding tasks and qps (#4332) <!-- Thanks for your contribution! please review https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before opening an issue. --> ## What do these changes do? the `MetricsTool` will print the following metrics periodically (setting of `metrics.tool.interval.ms`, default is 5 mins): 1. `memory.usage`: memory usage of jvm and direct memory 2. `rpc.channels.executor.queue`: pending tasks in each grpc (netty) channel 3. `gremlin.executor.queue`: pending tasks in gremlin executor 4. `gremlin.qps`: gremlin qps These metrics will be logged in a separate file, configured by `PerfMetricLog` in [logback.xml](https://github.com/shirly121/GraphScope/blob/ir_metric_tool/interactive_engine/assembly/src/conf/groot/logback.xml#L37) <!-- Please give a short brief about these changes. --> ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> Fixes
- Loading branch information
Showing
28 changed files
with
761 additions
and
75 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
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
92 changes: 92 additions & 0 deletions
92
...ve_engine/compiler/src/main/java/com/alibaba/graphscope/common/client/RpcInterceptor.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,92 @@ | ||
/* | ||
* | ||
* * Copyright 2020 Alibaba Group Holding Limited. | ||
* * | ||
* * Licensed 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 com.alibaba.graphscope.common.client; | ||
|
||
import com.alibaba.graphscope.gremlin.plugin.QueryLogger; | ||
|
||
import io.grpc.*; | ||
|
||
import java.time.Instant; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public class RpcInterceptor implements ClientInterceptor { | ||
public static final CallOptions.Key<QueryLogger> QUERY_LOGGER_OPTION = | ||
CallOptions.Key.create("query-logger"); | ||
|
||
@Override | ||
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( | ||
MethodDescriptor<ReqT, RespT> methodDescriptor, | ||
CallOptions callOptions, | ||
Channel channel) { | ||
return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>( | ||
channel.newCall(methodDescriptor, callOptions)) { | ||
private Instant requestStartTime; | ||
|
||
@Override | ||
public void start(Listener<RespT> responseListener, Metadata headers) { | ||
requestStartTime = Instant.now(); | ||
QueryLogger queryLogger = callOptions.getOption(QUERY_LOGGER_OPTION); | ||
super.start( | ||
new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>( | ||
responseListener) { | ||
private final AtomicBoolean firstResponseLogged = | ||
new AtomicBoolean(false); | ||
|
||
@Override | ||
public void onMessage(RespT message) { | ||
if (firstResponseLogged.compareAndSet(false, true)) { | ||
long firstResponseTime = | ||
Instant.now().toEpochMilli() | ||
- requestStartTime.toEpochMilli(); | ||
if (queryLogger != null) { | ||
queryLogger.info( | ||
"[query][response]: receive the first response from" | ||
+ " the channel {} in {} ms", | ||
channel.authority(), | ||
firstResponseTime); | ||
} | ||
} | ||
super.onMessage(message); | ||
} | ||
|
||
@Override | ||
public void onClose(Status status, Metadata trailers) { | ||
long endTime = Instant.now().toEpochMilli(); | ||
long totalTime = endTime - requestStartTime.toEpochMilli(); | ||
if (queryLogger != null) { | ||
queryLogger.info( | ||
"[query][response]: receive the last response from the" | ||
+ " channel {} with status {} in {} ms", | ||
channel.authority(), | ||
status, | ||
totalTime); | ||
} | ||
super.onClose(status, trailers); | ||
} | ||
}, | ||
headers); | ||
if (queryLogger != null) { | ||
queryLogger.info( | ||
"[query][submitted]: submit the query to the task queue of channel {}", | ||
channel.authority()); | ||
} | ||
} | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.