You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2018/04/02 01:27:17 UTC

[bookkeeper] branch master updated: Make CRC32C_HASH a final static variable and log when we cannot use native crc32c library

This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 678b88c  Make CRC32C_HASH a final static variable and log when we cannot use native crc32c library
678b88c is described below

commit 678b88ca8e7fc313494b34167785b37102e809d0
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Sun Apr 1 18:27:10 2018 -0700

    Make CRC32C_HASH a final static variable and log when we cannot use native crc32c library
    
    For CRC32c there is a marked performance difference when the JNI library is available versus when it's not, since the fallback involves creating many `ByteBuffer`s and copy payloads.
    
    Additionally we should set the static variable to `final` so the optimizer can get rid of the `(CRC32C_HASH instanceof Sse42Crc32C)` checks.
    
    Author: Matteo Merli <mm...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@gmail.com>, Jia Zhai <None>, Sijie Guo <si...@apache.org>
    
    This closes #1303 from merlimat/crc-final
---
 .../src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java | 3 ++-
 .../main/java/com/scurrilous/circe/checksum/Crc32cLongChecksum.java    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java b/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java
index cdf3d8d..528244b 100644
--- a/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java
+++ b/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java
@@ -33,7 +33,7 @@ public class Crc32cIntChecksum {
     private static final Logger log = LoggerFactory.getLogger(Crc32cIntChecksum.class);
 
     @VisibleForTesting
-    static IncrementalIntHash CRC32C_HASH;
+    final static IncrementalIntHash CRC32C_HASH;
 
     static {
         if (Sse42Crc32C.isSupported()) {
@@ -41,6 +41,7 @@ public class Crc32cIntChecksum {
             log.info("SSE4.2 CRC32C provider initialized");
         } else {
             CRC32C_HASH = new StandardCrcProvider().getIncrementalInt(CRC32C);
+            log.warn("Failed to load Circe JNI library. Falling back to Java based CRC32c provider");
         }
     }
 
diff --git a/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cLongChecksum.java b/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cLongChecksum.java
index 401b073..c283e56 100644
--- a/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cLongChecksum.java
+++ b/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cLongChecksum.java
@@ -33,7 +33,7 @@ public class Crc32cLongChecksum {
     private static final Logger log = LoggerFactory.getLogger(Crc32cLongChecksum.class);
 
     @VisibleForTesting
-    static IncrementalIntHash CRC32C_HASH;
+    final static IncrementalIntHash CRC32C_HASH;
 
     static {
         if (Sse42Crc32C.isSupported()) {
@@ -43,6 +43,7 @@ public class Crc32cLongChecksum {
             }
         } else {
             CRC32C_HASH = new StandardCrcProvider().getIncrementalInt(CRC32C);
+            log.warn("Failed to load Circe JNI library. Falling back to Java based CRC32c provider");
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
sijie@apache.org.