Hi,

java.util.zip.Adler32/CRC32 do not have update method that accepts ByteBuffer. As of JDK7, you have to copy the content of the ByteBuffer into a byte[], then invoke Adler32/CRC32.update() method, which might have significant performance impact for some applications. Here I'm proposing to add two update methods in
j.u.z.Adler32 and CRC32 classes respectively to address this issue.

Here is the webrev

http://cr.openjdk.java.net/~sherman/7109837/webrev

Attached is the result of TimeChecksum.java, which also serves as a simple Benchmark.

Thanks!
Sherman

-------------------------------------------------------------------------------------------------------------------------

sherman@sherman-linux:~/Workspace/jdk8_bugfix/test/java/util/zip$ java TimeChecksum
---------- Adler32 ----------
Warmup...      59,535      59,495      59,948

Length    byte[](ns/len)  ByteBuffer(direct)   ByteBuffer
1 13,409,610 2,990,525 ( 77%) 13,196,357 ( 1%) checksum=bd00bd 2 5,808,804 1,664,460 ( 71%) 7,069,931 ( -21%) checksum=19000d3 4 3,009,793 858,267 ( 71%) 3,516,799 ( -16%) checksum=55f01fe 8 1,560,870 508,546 ( 67%) 1,754,650 ( -12%) checksum=11cc03d4 16 792,323 298,697 ( 62%) 931,902 ( -17%) checksum=40fb071b 32 430,367 185,262 ( 56%) 487,747 ( -13%) checksum=ed2b0e1d 64 242,277 123,685 ( 48%) 277,898 ( -14%) checksum=d0601df1 128 147,870 96,570 ( 34%) 164,493 ( -11%) checksum=29d13ac0 256 107,230 80,315 ( 25%) 114,297 ( -6%) checksum=20807ab7 512 85,729 73,765 ( 13%) 90,236 ( -5%) checksum=feb1face 1024 74,593 67,872 ( 9%) 77,241 ( -3%) checksum=7721ffb7 2048 71,558 68,599 ( 4%) 72,673 ( -1%) checksum=717c0800 4096 70,053 64,908 ( 7%) 67,246 ( 4%) checksum=53b5fbe1 8192 62,689 60,908 ( 2%) 62,205 ( 0%) checksum=7ae5e6b3 16384 60,721 59,802 ( 1%) 60,920 ( 0%) checksum=89e1b861

---------- CRC32 ----------
Warmup...     100,600     101,373     100,795

Length    byte[](ns/len)  ByteBuffer(direct)   ByteBuffer
1 10,929,099 3,562,762 ( 67%) 13,328,815 ( -21%) checksum=10d5102a 2 5,811,664 1,846,604 ( 68%) 6,924,621 ( -19%) checksum=fd7d461a 4 3,048,740 968,395 ( 68%) 3,522,863 ( -15%) checksum=a1ab61ba 8 1,605,356 539,462 ( 66%) 1,778,894 ( -10%) checksum=cdc2506e 16 859,704 318,999 ( 62%) 926,758 ( -7%) checksum=1c3db3a3 32 474,646 216,487 ( 54%) 489,307 ( -3%) checksum=19bbc99e 64 282,917 157,252 ( 44%) 280,958 ( 0%) checksum=df43e0e0 128 195,853 127,730 ( 34%) 164,068 ( 16%) checksum=5fa8c160 256 147,025 116,742 ( 20%) 113,715 ( 22%) checksum=854200ac 512 121,620 108,233 ( 11%) 90,232 ( 25%) checksum=1b6cc88e 1024 110,529 106,890 ( 3%) 77,241 ( 30%) checksum=1456003f 2048 105,115 103,971 ( 1%) 72,716 ( 30%) checksum=187766b0 4096 102,661 103,858 ( -1%) 67,646 ( 34%) checksum=91c34ea3 8192 101,280 103,494 ( -2%) 62,359 ( 38%) checksum=2b8921aa 16384 104,444 105,407 ( 0%) 61,126 ( 41%) checksum=6f921ec0

Reply via email to