GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — zlib: add crc32c by pipobscure · Pull Request #66828 · nodejs/node Conversation
Contributor
Add zlib.crc32c(data[, value]), which computes the CRC-32C checksum (Castagnoli polynomial, RFC 3720 section 12.1). CRC-32C has better error detection properties than the CRC-32 of zlib.crc32() and is the checksum required by many current protocols, formats and services, among them:
Implementing any of these in JavaScript currently needs a userland CRC-32C, which is far slower than native code. The function mirrors zlib.crc32(): it accepts a string (encoded as UTF-8) or an ArrayBufferView, takes an optional 32-bit unsigned starting value so a checksum can be continued across chunks, and has a V8 fast API path. The checksum is computed by absl::ExtendCrc32c() from the bundled Abseil, which is already built and linked into node, so this adds no new dependency and no new checksum implementation. absl_crc32c is added to the libraries linked with --shared-abseil. Abseil selects its hardware-accelerated CRC-32C path (SSE4.2 and PCLMULQDQ on x64, the CRC32 and PMULL extensions on arm64) at compile time, so with node's default compiler flags the portable table-driven implementation is used. It runs at about the same speed as zlib.crc32() (about 6.5 GB/s on a recent x64 machine), while the hardware path reaches about 38 GB/s. Builds whose target CPU baseline already includes those instructions get the hardware path without changes. Enabling it for generic builds is left out on purpose: on x64, Abseil uses the accelerated code for unrecognized CPUs without a runtime feature check, so compiling it in unconditionally would fault on CPUs without SSE4.2. I had agentic help here, but I did review and check every single line.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsAdd zlib.crc32c(data[, value]), which computes the CRC-32C checksum (Castagnoli polynomial, RFC 3720 section 12.1). CRC-32C has better error detection properties than the CRC-32 of zlib.crc32() and is the checksum required by many current protocols, formats and services, among them: - iSCSI header and data digests (RFC 7143) - SCTP packet checksums (RFC 9260) - iWARP MPA framing (RFC 5044) - NVMe/TCP header and data digests - ext4, Btrfs and XFS metadata checksums - the Snappy framing format - Apache Kafka record batches - LevelDB and RocksDB block checksums - TensorFlow TFRecord files - Google Cloud Storage and Amazon S3 object checksums Implementing any of these in JavaScript currently needs a userland CRC-32C, which is far slower than native code. The function mirrors zlib.crc32(): it accepts a string (encoded as UTF-8) or an ArrayBufferView, takes an optional 32-bit unsigned starting value so a checksum can be continued across chunks, and has a V8 fast API path. The checksum is computed by absl::ExtendCrc32c() from the bundled Abseil, which is already built and linked into node, so this adds no new dependency and no new checksum implementation. absl_crc32c is added to the libraries linked with --shared-abseil. Abseil selects its hardware-accelerated CRC-32C path (SSE4.2 and PCLMULQDQ on x64, the CRC32 and PMULL extensions on arm64) at compile time, so with node's default compiler flags the portable table-driven implementation is used. It runs at about the same speed as zlib.crc32() (about 6.5 GB/s on a recent x64 machine), while the hardware path reaches about 38 GB/s. Builds whose target CPU baseline already includes those instructions get the hardware path without changes. Enabling it for generic builds is left out on purpose: on x64, Abseil uses the accelerated code for unrecognized CPUs without a runtime feature check, so compiling it in unconditionally would fault on CPUs without SSE4.2. Signed-off-by: Philipp Dunkel <[email protected]>
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## main #66828 +/- ## ========================================== - Coverage 90.49% 90.49% -0.01% ========================================== Files 797 797 Lines 277686 277824 +138 Branches 53362 53376 +14 ========================================== + Hits 251292 251413 +121 + Misses 16796 16795 -1 - Partials 9598 9616 +18
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Awesome. CI passes. This is as ready as I can get it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Landed in df2ea49 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Signed-off-by: Trivikram Kamat <[email protected]> PR-URL: #67004 Refs: #66828 Reviewed-By: Luigi Pinca <[email protected]>
Signed-off-by: Trivikram Kamat <[email protected]> PR-URL: #67004 Refs: #66828 Reviewed-By: Luigi Pinca <[email protected]>
Add zlib.crc32c(data[, value]), which computes the CRC-32C checksum (Castagnoli polynomial, RFC 3720 section 12.1). CRC-32C has better error detection properties than the CRC-32 of zlib.crc32() and is the checksum required by many current protocols, formats and services, among them: - iSCSI header and data digests (RFC 7143) - SCTP packet checksums (RFC 9260) - iWARP MPA framing (RFC 5044) - NVMe/TCP header and data digests - ext4, Btrfs and XFS metadata checksums - the Snappy framing format - Apache Kafka record batches - LevelDB and RocksDB block checksums - TensorFlow TFRecord files - Google Cloud Storage and Amazon S3 object checksums Implementing any of these in JavaScript currently needs a userland CRC-32C, which is far slower than native code. The function mirrors zlib.crc32(): it accepts a string (encoded as UTF-8) or an ArrayBufferView, takes an optional 32-bit unsigned starting value so a checksum can be continued across chunks, and has a V8 fast API path. The checksum is computed by absl::ExtendCrc32c() from the bundled Abseil, which is already built and linked into node, so this adds no new dependency and no new checksum implementation. absl_crc32c is added to the libraries linked with --shared-abseil. Abseil selects its hardware-accelerated CRC-32C path (SSE4.2 and PCLMULQDQ on x64, the CRC32 and PMULL extensions on arm64) at compile time, so with node's default compiler flags the portable table-driven implementation is used. It runs at about the same speed as zlib.crc32() (about 6.5 GB/s on a recent x64 machine), while the hardware path reaches about 38 GB/s. Builds whose target CPU baseline already includes those instructions get the hardware path without changes. Enabling it for generic builds is left out on purpose: on x64, Abseil uses the accelerated code for unrecognized CPUs without a runtime feature check, so compiling it in unconditionally would fault on CPUs without SSE4.2. Signed-off-by: Philipp Dunkel <[email protected]> PR-URL: #66828 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Signed-off-by: Trivikram Kamat <[email protected]> PR-URL: #67004 Refs: #66828 Reviewed-By: Luigi Pinca <[email protected]>
Notable changes: child_process: * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639 doc: * add efekrskl to collaborators (Efe Karasakal) #67376 * add Philipp Dunkel to contributors (Philipp Dunkel) #67378 * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377 fs: * (SEMVER-MINOR) add mkstemp() (Marco) #66484 http: * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187 lib: * (SEMVER-MINOR) speed up AbortSignal (Robert Nagy) #66789 module: * (SEMVER-MINOR) add --experimental-strip-private-modules (Marco Ippolito) #63869 process: * (SEMVER-MINOR) return unregister fn from finalization (Matteo Collina) #66482 test_runner: * use AsyncLocalStorage instead of async_hooks (Matteo Collina) #66795 * (SEMVER-MINOR) add mockReturnValue and promise helpers (Guilherme Araújo) #66631 worker: * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311 zlib: * (SEMVER-MINOR) add crc32c (Philipp Dunkel) #66828 PR-URL: #67664
Notable changes: child_process: * (SEMVER-MINOR) add subprocess.timedOut (Marco) #66639 doc: * add efekrskl to collaborators (Efe Karasakal) #67376 * add Philipp Dunkel to contributors (Philipp Dunkel) #67378 * add christianaurichzm to collaborators (Christian Aurich Zanettini Martins) #67377 fs: * (SEMVER-MINOR) add mkstemp() (Marco) #66484 http: * (SEMVER-MINOR) batch body spans per parser execute (Guilherme Araújo) #67187 lib: * (SEMVER-MINOR) speed up AbortSignal (Robert Nagy) #66789 module: * (SEMVER-MINOR) add --experimental-strip-private-modules (Marco Ippolito) #63869 process: * (SEMVER-MINOR) return unregister fn from finalization (Matteo Collina) #66482 test_runner: * use AsyncLocalStorage instead of async_hooks (Matteo Collina) #66795 * (SEMVER-MINOR) add mockReturnValue and promise helpers (Guilherme Araújo) #66631 worker: * (SEMVER-MINOR) preload streams into startup snapshot (Matteo Collina) #66311 zlib: * (SEMVER-MINOR) add crc32c (Philipp Dunkel) #66828 PR-URL: #67664
Add zlib.crc32c(data[, value]), which computes the CRC-32C checksum (Castagnoli polynomial, RFC 3720 section 12.1). CRC-32C has better error detection properties than the CRC-32 of zlib.crc32() and is the checksum required by many current protocols, formats and services, among them: - iSCSI header and data digests (RFC 7143) - SCTP packet checksums (RFC 9260) - iWARP MPA framing (RFC 5044) - NVMe/TCP header and data digests - ext4, Btrfs and XFS metadata checksums - the Snappy framing format - Apache Kafka record batches - LevelDB and RocksDB block checksums - TensorFlow TFRecord files - Google Cloud Storage and Amazon S3 object checksums Implementing any of these in JavaScript currently needs a userland CRC-32C, which is far slower than native code. The function mirrors zlib.crc32(): it accepts a string (encoded as UTF-8) or an ArrayBufferView, takes an optional 32-bit unsigned starting value so a checksum can be continued across chunks, and has a V8 fast API path. The checksum is computed by absl::ExtendCrc32c() from the bundled Abseil, which is already built and linked into node, so this adds no new dependency and no new checksum implementation. absl_crc32c is added to the libraries linked with --shared-abseil. Abseil selects its hardware-accelerated CRC-32C path (SSE4.2 and PCLMULQDQ on x64, the CRC32 and PMULL extensions on arm64) at compile time, so with node's default compiler flags the portable table-driven implementation is used. It runs at about the same speed as zlib.crc32() (about 6.5 GB/s on a recent x64 machine), while the hardware path reaches about 38 GB/s. Builds whose target CPU baseline already includes those instructions get the hardware path without changes. Enabling it for generic builds is left out on purpose: on x64, Abseil uses the accelerated code for unrecognized CPUs without a runtime feature check, so compiling it in unconditionally would fault on CPUs without SSE4.2. Signed-off-by: Philipp Dunkel <[email protected]> PR-URL: nodejs#66828 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Signed-off-by: Trivikram Kamat <[email protected]> PR-URL: nodejs#67004 Refs: nodejs#66828 Reviewed-By: Luigi Pinca <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.