You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by el...@apache.org on 2017/02/22 22:10:17 UTC
calcite git commit: [CALCITE-1654] Avoid generating a String from the
Request/Response when it will not be logged
Repository: calcite
Updated Branches:
refs/heads/master abfcc79bc -> 1b1138568
[CALCITE-1654] Avoid generating a String from the Request/Response when it will not be logged
An OutOfMemoryError lead us to find that for each request and response
handled by Avatica, the protobuf message is converted to a String, even
if it would not be logged. This can cause a bit of unnecessary pressure
on the heap usage.
Closes apache/calcite#380
Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/1b113856
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/1b113856
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/1b113856
Branch: refs/heads/master
Commit: 1b11385687171946d961fc4c836ee348f682b00a
Parents: abfcc79
Author: Josh Elser <el...@apache.org>
Authored: Wed Feb 22 15:57:06 2017 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Wed Feb 22 16:07:24 2017 -0500
----------------------------------------------------------------------
.../avatica/remote/ProtobufTranslationImpl.java | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite/blob/1b113856/avatica/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java b/avatica/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
index fca286e..e1dd06d 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/remote/ProtobufTranslationImpl.java
@@ -296,7 +296,10 @@ public class ProtobufTranslationImpl implements ProtobufTranslation {
UnsynchronizedBuffer out = threadLocalBuffer.get();
try {
Message responseMsg = response.serialize();
- LOG.trace("Serializing response '{}'", TextFormat.shortDebugString(responseMsg));
+ // Serialization of the response may be large
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Serializing response '{}'", TextFormat.shortDebugString(responseMsg));
+ }
serializeMessage(out, responseMsg);
return out.toArray();
} finally {
@@ -309,7 +312,10 @@ public class ProtobufTranslationImpl implements ProtobufTranslation {
UnsynchronizedBuffer out = threadLocalBuffer.get();
try {
Message requestMsg = request.serialize();
- LOG.trace("Serializing request '{}'", TextFormat.shortDebugString(requestMsg));
+ // Serialization of the request may be large
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Serializing request '{}'", TextFormat.shortDebugString(requestMsg));
+ }
serializeMessage(out, requestMsg);
return out.toArray();
} finally {
@@ -361,7 +367,9 @@ public class ProtobufTranslationImpl implements ProtobufTranslation {
// The ByteString should be logical offsets into the original byte array
return translator.transform(wireMsg.getWrappedMessage());
} catch (RuntimeException e) {
- LOG.debug("Failed to parse request message '{}'", TextFormat.shortDebugString(wireMsg));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed to parse request message '{}'", TextFormat.shortDebugString(wireMsg));
+ }
throw e;
}
}
@@ -380,7 +388,9 @@ public class ProtobufTranslationImpl implements ProtobufTranslation {
return translator.transform(wireMsg.getWrappedMessage());
} catch (RuntimeException e) {
- LOG.debug("Failed to parse response message '{}'", TextFormat.shortDebugString(wireMsg));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed to parse response message '{}'", TextFormat.shortDebugString(wireMsg));
+ }
throw e;
}
}