---
title: "More Than 2x Faster Hashing in ClickHouse Using Rust"
description: "ClickHouse added optional Rust library support to its C++/CMake build using Corrosion-rs, with BLAKE3 as the first library, exposed to C++ through a Rust shim function using C-compatible FFI types and a header file."
url: "https://swe.quest/articles/more-than-2x-faster-hashing-in-clickhouse-using-rust-404bde5cc500d24b"
canonical: "https://clickhouse.com/blog/more-than-2x-faster-hashing-in-clickhouse-using-rust"
source: "ClickHouse"
published: "2022-10-25"
difficulty: "medium"
kind: "Case study"
reading_minutes: 5
tags: ["rust","c-cpp","build-systems","performance","cryptography"]
---

# More Than 2x Faster Hashing in ClickHouse Using Rust

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2022-10-25, 5 min read, Case study. Original: [https://clickhouse.com/blog/more-than-2x-faster-hashing-in-clickhouse-using-rust](https://clickhouse.com/blog/more-than-2x-faster-hashing-in-clickhouse-using-rust)

## Summary

ClickHouse added optional Rust library support to its C++/CMake build using Corrosion-rs, with BLAKE3 as the first library, exposed to C++ through a Rust shim function using C-compatible FFI types and a header file. BLAKE3 hashes more than 2x faster than SHA224/SHA256 and slightly faster than MD5, while staying secure and resistant to length extension. Perf flamegraphs show the shim's type conversion costs about 1.15% of query time. Integration hurdles included MemorySanitizer false positives on Rust memory, fixed with \_\_msan\_unpoison and explicit byte conversion, plus cross-platform linking, with aarch64-darwin still unsupported. The integration also had to stay optional, statically linked, cross-compilable and compatible with sanitizers.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Cryptography](https://swe.quest/tags/cryptography.md) (Security)

## Prerequisites

- C++ build systems with CMake ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- Rust FFI basics ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))
- cryptographic hash functions

## Keywords

ClickHouse, BLAKE3, Corrosion-rs, Cargo, CMake, MemorySanitizer, perf

## Related posts

- [How to use Rust in ClickHouse: avoiding a full rewrite](https://swe.quest/articles/how-to-use-rust-in-clickhouse-avoiding-a-full-rewrite-e470754e07a213d4.md): ClickHouse · 2025-12-17 · Medium · 13 min read · Rust, C & C++, Build systems, Refactoring & migrations, Testing
  ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting.
- [A Year of Rust in ClickHouse](https://swe.quest/articles/a-year-of-rust-in-clickhouse-fadc1c7501c80398.md): ClickHouse · 2025-04-01 · Medium · 12 min read · Rust, C & C++, Build systems, Testing, Supply chain security
  ClickHouse added Rust to its C++ codebase as an option for new components rather than a rewrite, starting with BLAKE3, then skim for clickhouse-client history, PRQL as a switchable query dialect, and Databricks' delta-kernel-rs replacing a sketchy C++ Delta Lake implementation.
- [Integrating the Rust Delta Kernel into ClickHouse](https://swe.quest/articles/integrating-the-rust-delta-kernel-into-clickhouse-4dfcdd8e64024cda.md): ClickHouse · 2026-05-22 · Hard · 17 min read · Analytics & OLAP, Rust, C & C++, Build systems, Data pipelines
  ClickHouse replaced its hand-written Delta Lake protocol implementation with the Rust Delta Kernel (delta-kernel-rs).
- [Eliminating Data Races in Firefox – A Technical Report](https://swe.quest/articles/eliminating-data-races-in-firefox-a-technical-report-5763b33d1a4f6f94.md): Mozilla Hacks · 2021-04-06 · Hard · 11 min read · Concurrency, C & C++, Rust, Debugging, Static analysis
  Mozilla deployed ThreadSanitizer across Firefox's C/C++ and Rust code, using a compiled-in suppression list to gate new races in CI while legacy ones were triaged toward a "no data races" policy.
- [chDB - A Rocket Engine on a Bicycle](https://swe.quest/articles/chdb-a-rocket-engine-on-a-bicycle-951148e84c12126b.md): ClickHouse · 2023-09-29 · Hard · 9 min read · Analytics & OLAP, Memory management, C & C++, Python, Performance engineering
  chDB embeds the ClickHouse engine as an in-process Python module instead of shelling out to the 500MB clickhouse-local binary, using WriteBufferFromVector, Python memoryview and Pybind11 for zero-copy result retrieval.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
