← All work

Clickstream sessions

A Rust pipeline that turns 20 million raw e-commerce events into exact daily user and campaign reports in under a second.

Year
2026
Category
Systems programming, data pipeline
Status
Built. Performance figures are from the repository README and have not been reproduced.

Overview

A Rust program that reads an online store's raw event logs and produces two exact daily reports, one per user and one per ad campaign. The README reports that it processes 20 million events and 5 million ad clicks in about 0.87 seconds on an 8-core server, with output that matches a reference implementation byte for byte.

The problem

The input is dirty on purpose and the rules are exact. Events can be duplicated, so the copy ingested first wins. Timestamps come in three valid formats and many invalid ones that look valid. One person can have many user IDs linked through long chains. A session ends after 30 minutes of inactivity and is credited to the ad click that brought the shopper in, with other recent campaigns counted as assists. Any CSV field may be quoted, and malformed rows are dropped rather than repaired. The output is two Parquet tables.

What was built

  • A memory-mapped CSV reader that splits files into chunks across all cores.
  • An AVX2 tokenizer that classifies 64 bytes per step and finds field and quote boundaries with bit operations.
  • Packed 64-bit keys for IDs of up to nine bytes, and a union-find that merges linked user IDs while parsing.
  • Long IDs stored as a 60-bit fingerprint plus a file offset, with a post-parse collision check and a fallback to an exact general path if a collision is found.
  • Radix-partitioned records written through write-combining buffers, a cache-sized deduplication filter, and a Parquet writer written from scratch.

Technical details

The README tracks the timing through the project: 1.08 s for the first partitioned version, 0.74 s after tuning, a jump to 6.41 s when the input changed to variable-width IDs, 1.07 s with a lock-free interner, and 0.87 s at the end. It says about a dozen ideas that looked good were dropped after measurement. Correctness checks listed are 36 hand-written edge-case datasets, seven generated reference datasets compared row by row, a comparison of the fast and general paths on 20 million events, a forced-collision test and unit tests.

Status

Complete as described in the repository, with a Dockerfile and run instructions.

What is not documented

The test datasets are not in the repository, so the results cannot be reproduced from it. The source of the task and any ranking or score are not stated.

Images and video

Infographic headed 20 million events, 0.87 seconds, with six numbered pipeline stages, a bar showing time per stage and a bar chart of six timings from 1.08 s to 0.87 s with a 6.41 s spike.
Overview figure from the repository: pipeline stages, where the time goes, and timing over the project.