Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-07 Thread via GitHub


chaokunyang commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1554987311


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   Great! Thanks for taking time to benchmark this.



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-07 Thread via GitHub


LiangliangSui commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1554983464


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   with this pr
   ```
   Benchmark (bufferType)   
(objectType)  (references)   Mode  CntScoreError  Units
   UserTypeSerializeSuite.fury_serialize_compatible array  
MEDIA_CONTENT false  thrpt9  4587893.508 ±  42116.854  ops/s
   UserTypeSerializeSuite.fury_serialize_compatible array  
MEDIA_CONTENT  true  thrpt9  3177202.586 ±  14736.954  ops/s
   UserTypeSerializeSuite.fury_serialize_compatible  directBuffer  
MEDIA_CONTENT false  thrpt9  4562769.304 ± 340601.623  ops/s
   UserTypeSerializeSuite.fury_serialize_compatible  directBuffer  
MEDIA_CONTENT  true  thrpt9  3079333.765 ±  61135.629  ops/s
   ```
   
   before this pr
   ```
   Benchmark (bufferType)   
(objectType)  (references)   Mode  CntScoreError  Units
   UserTypeSerializeSuite.fury_serialize_compatible array  
MEDIA_CONTENT false  thrpt9  4602232.298 ± 107310.721  ops/s
   UserTypeSerializeSuite.fury_serialize_compatible array  
MEDIA_CONTENT  true  thrpt9  3141775.420 ±  59485.987  ops/s
   UserTypeSerializeSuite.fury_serialize_compatible  directBuffer  
MEDIA_CONTENT false  thrpt9  4755918.332 ±  65920.575  ops/s
   UserTypeSerializeSuite.fury_serialize_compatible  directBuffer  
MEDIA_CONTENT  true  thrpt9  3118601.861 ± 140368.292  ops/s
   ```
   
   I run fury benchmark for MediaContent object, there should be no degradation 
in performance, within the error range.



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-06 Thread via GitHub


chaokunyang commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1554640857


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   This looks good, does this have an influence in a end-to-end benchmark? JVM 
inline has max depth limit, the current case shouldn't be influenced by this 
optimization. Could you run fury benchmark for MediaContent object?



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-06 Thread via GitHub


LiangliangSui commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1554626407


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   After passing the benchmark, it can still be inlined and there is no 
performance degradation.
   
   
![image](https://github.com/apache/incubator-fury/assets/116876207/7222c40b-e3ae-43e1-a4da-6a26e174fda2)
   
   The difference between the two is 155266, which should be within the error.
   
   In addition, I saw in the log that `unsafePutPositiveVarInt` can be inlined 
in the benchmark process by using `-XX:+PrintCompilation 
-XX:+UnlockDiagnosticVMOptions -XX:+PrintInlinin`
   
   ```
   @ 152   java.lang.Integer::intValue (5 bytes)   accessor
   @ 155   org.apache.fury.memory.MemoryBuffer::writeVarInt (17 bytes)   inline 
(hot)
 @ 8   org.apache.fury.memory.MemoryBuffer::ensure (37 bytes)   inline (hot)
 @ 13   org.apache.fury.memory.MemoryBuffer::unsafeWriteVarInt (15 bytes)   
inline (hot)
   @ 11   org.apache.fury.memory.MemoryBuffer::unsafeWritePositiveVarInt 
(22 bytes)   inline (hot)
 @ 6   org.apache.fury.memory.MemoryBuffer::unsafePutPositiveVarInt 
(208 bytes)   inline (hot)
   @ 39   sun.misc.Unsafe::putByte (11 bytes)   force inline by 
annotation
 @ 7   jdk.internal.misc.Unsafe::putByte (0 bytes)   (intrinsic)
   @ 81   org.apache.fury.memory.MemoryBuffer::unsafePutInt (45 bytes)  
 inline (hot)
 @ 23   sun.misc.Unsafe::putInt (11 bytes)   force inline by 
annotation
   @ 7   jdk.internal.misc.Unsafe::putInt (0 bytes)   (intrinsic)
   ```



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-06 Thread via GitHub


LiangliangSui commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1554626407


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   After passing the benchmark, it can still be inlined and there is no 
performance regression.
   
   
![image](https://github.com/apache/incubator-fury/assets/116876207/7222c40b-e3ae-43e1-a4da-6a26e174fda2)
   
   The difference between the two is 155266, which should be within the error.
   
   In addition, I saw in the log that `unsafePutPositiveVarInt` can be inlined 
in the benchmark process by using `-XX:+PrintCompilation 
-XX:+UnlockDiagnosticVMOptions -XX:+PrintInlinin`
   
   ```
   @ 152   java.lang.Integer::intValue (5 bytes)   accessor
   @ 155   org.apache.fury.memory.MemoryBuffer::writeVarInt (17 bytes)   inline 
(hot)
 @ 8   org.apache.fury.memory.MemoryBuffer::ensure (37 bytes)   inline (hot)
 @ 13   org.apache.fury.memory.MemoryBuffer::unsafeWriteVarInt (15 bytes)   
inline (hot)
   @ 11   org.apache.fury.memory.MemoryBuffer::unsafeWritePositiveVarInt 
(22 bytes)   inline (hot)
 @ 6   org.apache.fury.memory.MemoryBuffer::unsafePutPositiveVarInt 
(208 bytes)   inline (hot)
   @ 39   sun.misc.Unsafe::putByte (11 bytes)   force inline by 
annotation
 @ 7   jdk.internal.misc.Unsafe::putByte (0 bytes)   (intrinsic)
   @ 81   org.apache.fury.memory.MemoryBuffer::unsafePutInt (45 bytes)  
 inline (hot)
 @ 23   sun.misc.Unsafe::putInt (11 bytes)   force inline by 
annotation
   @ 7   jdk.internal.misc.Unsafe::putInt (0 bytes)   (intrinsic)
   ```



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-02 Thread via GitHub


chaokunyang commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1547828485


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   You may need to update fury creation to use LongEncoding.PVL



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-02 Thread via GitHub


LiangliangSui commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1547817704


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   Okay, I will do this check later.



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-04-01 Thread via GitHub


chaokunyang commented on code in PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434#discussion_r1546512637


##
java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java:
##
@@ -1233,49 +1233,9 @@ public int readVarInt() {
* to avoid using two memory operations.
*/
   public int unsafeWritePositiveVarInt(int v) {
-// The encoding algorithm are based on kryo UnsafeMemoryOutput.writeVarInt
-// varint are written using little endian byte order.
-// This version should have better performance since it remove an index 
update.
-long value = v;
-final int writerIndex = this.writerIndex;
-long varInt = (value & 0x7F);
-value >>>= 7;
-if (value == 0) {
-  UNSAFE.putByte(heapMemory, address + writerIndex, (byte) varInt);
-  this.writerIndex = writerIndex + 1;
-  return 1;
-}
-// bit 8 `set` indicates have next data bytes.
-varInt |= 0x80;
-varInt |= ((value & 0x7F) << 8);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 2;
-  return 2;
-}
-varInt |= (0x80 << 8);
-varInt |= ((value & 0x7F) << 16);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 3;
-  return 3;
-}
-varInt |= (0x80 << 16);
-varInt |= ((value & 0x7F) << 24);
-value >>>= 7;
-if (value == 0) {
-  unsafePutInt(writerIndex, (int) varInt);
-  this.writerIndex = writerIndex + 4;
-  return 4;
-}
-varInt |= (0x80L << 24);
-varInt |= ((value & 0x7F) << 32);
-varInt &= 0xFL;
-unsafePutLong(writerIndex, varInt);
-this.writerIndex = writerIndex + 5;
-return 5;
+int varintBytes = unsafePutPositiveVarInt(writerIndex, v);

Review Comment:
   JVM JIT inline has max depth limit, which is 9 by default. Reuse this method 
may disabled some jit inline. Could we benchmark 
`org.apache.fury.benchmark.UserTypeDeserializeSuite` to check this code reuse 
doesn't introduce a preformance regression?
   
   ```java
 public static void main(String[] args) throws IOException {
   if (args.length == 0) {
 String commandLine =
 "io.*UserTypeDeserializeSuite.fury* -f 0 -wi 3 -i 3 -t 1 -w 2s -r 
2s -rf csv";
 System.out.println(commandLine);
 args = commandLine.split(" ");
   }
   Main.main(args);
 }
   ```
   This will run fury serialization only



-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



Re: [PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-03-28 Thread via GitHub


chaokunyang merged PR #1434:
URL: https://github.com/apache/incubator-fury/pull/1434


-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org



[PR] chore(java): Reuse unsafePutPositiveVarInt in unsafeWritePositiveVarInt [incubator-fury]

2024-03-28 Thread via GitHub


LiangliangSui opened a new pull request, #1434:
URL: https://github.com/apache/incubator-fury/pull/1434

   N/A


-- 
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: commits-unsubscr...@fury.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org
For additional commands, e-mail: commits-h...@fury.apache.org