You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2024/05/18 08:24:59 UTC
[PR] use ByteString.toArrayUnsafe [pekko-grpc]
pjfanning opened a new pull request, #308:
URL: https://github.com/apache/pekko-grpc/pull/308
avoids array copying
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] use ByteString.toArrayUnsafe [pekko-grpc]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #308:
URL: https://github.com/apache/pekko-grpc/pull/308#discussion_r1607815916
##########
runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala:
##########
@@ -24,13 +24,13 @@ object Gzip extends Codec {
override def compress(uncompressed: ByteString): ByteString = {
val baos = new ByteArrayOutputStream(uncompressed.size)
val gzos = new GZIPOutputStream(baos)
- try gzos.write(uncompressed.toArray)
+ try gzos.write(uncompressed.toArrayUnsafe())
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}
override def uncompress(compressed: ByteString): ByteString = {
- val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
+ val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))
Review Comment:
@raboof I got rid of the MethodHandle in https://github.com/apache/pekko-grpc/pull/309
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] use ByteString.toArrayUnsafe [pekko-grpc]
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #308:
URL: https://github.com/apache/pekko-grpc/pull/308#discussion_r1606611723
##########
runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala:
##########
@@ -24,13 +24,13 @@ object Gzip extends Codec {
override def compress(uncompressed: ByteString): ByteString = {
val baos = new ByteArrayOutputStream(uncompressed.size)
val gzos = new GZIPOutputStream(baos)
- try gzos.write(uncompressed.toArray)
+ try gzos.write(uncompressed.toArrayUnsafe())
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}
override def uncompress(compressed: ByteString): ByteString = {
- val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
+ val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))
Review Comment:
May be we can the netty 's Hpack?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] use ByteString.toArrayUnsafe [pekko-grpc]
Posted by "raboof (via GitHub)" <gi...@apache.org>.
raboof commented on code in PR #308:
URL: https://github.com/apache/pekko-grpc/pull/308#discussion_r1607782726
##########
runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala:
##########
@@ -24,13 +24,13 @@ object Gzip extends Codec {
override def compress(uncompressed: ByteString): ByteString = {
val baos = new ByteArrayOutputStream(uncompressed.size)
val gzos = new GZIPOutputStream(baos)
- try gzos.write(uncompressed.toArray)
+ try gzos.write(uncompressed.toArrayUnsafe())
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}
override def uncompress(compressed: ByteString): ByteString = {
- val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
+ val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))
Review Comment:
> We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).
IMHO we could just require Pekko 1.1 in Pekko gRPC 1.1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] use ByteString.toArrayUnsafe [pekko-grpc]
Posted by "raboof (via GitHub)" <gi...@apache.org>.
raboof merged PR #308:
URL: https://github.com/apache/pekko-grpc/pull/308
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] use ByteString.toArrayUnsafe [pekko-grpc]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #308:
URL: https://github.com/apache/pekko-grpc/pull/308#discussion_r1606580923
##########
runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala:
##########
@@ -24,13 +24,13 @@ object Gzip extends Codec {
override def compress(uncompressed: ByteString): ByteString = {
val baos = new ByteArrayOutputStream(uncompressed.size)
val gzos = new GZIPOutputStream(baos)
- try gzos.write(uncompressed.toArray)
+ try gzos.write(uncompressed.toArrayUnsafe())
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}
override def uncompress(compressed: ByteString): ByteString = {
- val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
+ val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))
Review Comment:
Makes sense. We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).
Something like https://github.com/apache/pekko-http/pull/539/files (this was reverted because of a bug in the hpack code - https://github.com/twitter/hpack/issues/43).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] use ByteString.toArrayUnsafe [pekko-grpc]
Posted by "jtjeferreira (via GitHub)" <gi...@apache.org>.
jtjeferreira commented on code in PR #308:
URL: https://github.com/apache/pekko-grpc/pull/308#discussion_r1606598841
##########
runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala:
##########
@@ -24,13 +24,13 @@ object Gzip extends Codec {
override def compress(uncompressed: ByteString): ByteString = {
val baos = new ByteArrayOutputStream(uncompressed.size)
val gzos = new GZIPOutputStream(baos)
- try gzos.write(uncompressed.toArray)
+ try gzos.write(uncompressed.toArrayUnsafe())
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}
override def uncompress(compressed: ByteString): ByteString = {
- val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
+ val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))
Review Comment:
> We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).
thats unfortunate
> this was reverted because of a bug in the hpack code - https://github.com/twitter/hpack/issues/43
last commit of that library was 5 years ago. also it [seems](https://github.com/twitter/hpack/issues/31) to be deprecated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] use ByteString.toArrayUnsafe [pekko-grpc]
Posted by "jtjeferreira (via GitHub)" <gi...@apache.org>.
jtjeferreira commented on code in PR #308:
URL: https://github.com/apache/pekko-grpc/pull/308#discussion_r1606572414
##########
runtime/src/main/scala/org/apache/pekko/grpc/internal/Gzip.scala:
##########
@@ -24,13 +24,13 @@ object Gzip extends Codec {
override def compress(uncompressed: ByteString): ByteString = {
val baos = new ByteArrayOutputStream(uncompressed.size)
val gzos = new GZIPOutputStream(baos)
- try gzos.write(uncompressed.toArray)
+ try gzos.write(uncompressed.toArrayUnsafe())
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}
override def uncompress(compressed: ByteString): ByteString = {
- val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
+ val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))
Review Comment:
could we have used `compressed.asInputStream`? because `toArrayUnsafe` can still create a new array in case the byteString is a rope.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org