Skip to content

Feat: Add layout and benchmark artifacts#117

Merged
mxsm merged 3 commits into
mainfrom
codex/pr-004-layout-benchmark-artifacts
Jun 20, 2026
Merged

Feat: Add layout and benchmark artifacts#117
mxsm merged 3 commits into
mainfrom
codex/pr-004-layout-benchmark-artifacts

Conversation

@mxsm

@mxsm mxsm commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Implements the layout snapshot and benchmark artifact stage.

Scope:

  • Adds tests/layout_snapshot.rs and benches/layout.rs.
  • Adds benchmark artifact directory documentation and bench-all scripts.
  • Uploads layout artifacts from CI.

Verification completed locally:

  • cargo test layout_snapshot --all-features -- --nocapture
  • cargo bench --bench layout
  • final full verification matrix on integration branch

Closes #109.

Copilot AI review requested due to automatic review settings June 20, 2026 02:23
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mxsm, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 2 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4d6b555e-a896-4618-bd0c-065a083400ba

📥 Commits

Reviewing files that changed from the base of the PR and between 21aa0bf and ab3ef5c.

📒 Files selected for processing (15)
  • .github/workflows/ci.yaml
  • .github/workflows/release.yml
  • Cargo.toml
  • README.md
  • bench-results/README.md
  • benches/comprehensive.rs
  • benches/layout.rs
  • scripts/bench-all.ps1
  • scripts/bench-all.sh
  • src/cheetah_string.rs
  • src/lib.rs
  • src/serde.rs
  • src/simd.rs
  • tests/basic.rs
  • tests/layout_snapshot.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/pr-004-layout-benchmark-artifacts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a repeatable “layout snapshot” + benchmark-artifact capture path (tests/benches/scripts) and wires layout artifact upload into CI, while also tightening byte-based construction/serde behavior for CheetahString and bumping the crate version to 1.1.0.

Changes:

  • Add layout snapshot generation (tests/layout_snapshot.rs) and a bench-mode layout artifact generator (benches/layout.rs).
  • Add benchmark artifact conventions + runner scripts (bench-results/README.md, scripts/bench-all.*) and upload layout artifacts from CI.
  • Refactor CheetahString byte conversions to be UTF-8 checked (TryFrom + new explicit unsafe constructors), and simplify serde serialization.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tests/layout_snapshot.rs Generates a JSON layout snapshot artifact during tests.
tests/basic.rs Updates tests to use fallible UTF-8-checked constructors; adds TryFrom trait coverage.
src/serde.rs Serializes consistently via as_str(); deserializes bytes with UTF-8 validation.
src/lib.rs Updates docs to reference v1.1.0 (SIMD example).
src/cheetah_string.rs Introduces checked byte conversions + explicit unsafe constructors; deprecates some constructors.
scripts/bench-all.sh Adds Unix bench/layout capture script writing outputs to bench-results/.
scripts/bench-all.ps1 Adds PowerShell bench/layout capture script writing outputs to bench-results/.
README.md Updates dependency examples to v1.1.0.
Cargo.toml Bumps version to 1.1.0, makes bytes optional, and adds layout bench target.
benches/layout.rs Adds a bench artifact generator for layout snapshot data.
benches/comprehensive.rs Updates benchmark cases to use the new checked constructor.
bench-results/README.md Documents artifact directory layout and recommended metadata.
.github/workflows/release.yml Adds a release workflow (tag/publish/release).
.github/workflows/ci.yaml Runs CI on OS/toolchain matrix and uploads layout artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cheetah_string.rs
Comment on lines +50 to 56
impl<'a> TryFrom<&'a [u8]> for CheetahString {
type Error = Utf8Error;

#[inline]
fn from(b: &[u8]) -> Self {
// SAFETY: This is unsafe and may cause UB if bytes are not valid UTF-8.
// This will be deprecated in favor of try_from_bytes in the next version.
CheetahString::from_slice(unsafe { str::from_utf8_unchecked(b) })
fn try_from(b: &'a [u8]) -> Result<Self, Self::Error> {
CheetahString::try_from_bytes(b)
}
Comment thread src/cheetah_string.rs
Comment on lines +67 to 73
impl TryFrom<Vec<u8>> for CheetahString {
type Error = Utf8Error;

#[inline]
fn from(v: Vec<u8>) -> Self {
// SAFETY: This constructor does not validate UTF-8 and may cause UB
// if the bytes are later observed as a string.
CheetahString::from_vec(v)
fn try_from(v: Vec<u8>) -> Result<Self, Self::Error> {
CheetahString::try_from_vec(v)
}
Comment thread src/cheetah_string.rs
Comment on lines 147 to 155
#[cfg(feature = "bytes")]
impl From<bytes::Bytes> for CheetahString {
impl TryFrom<bytes::Bytes> for CheetahString {
type Error = Utf8Error;

#[inline]
fn from(b: bytes::Bytes) -> Self {
CheetahString::from_bytes(b)
fn try_from(b: bytes::Bytes) -> Result<Self, Self::Error> {
CheetahString::try_from_bytes_buf(b)
}
}
Comment thread scripts/bench-all.sh
Comment on lines +1 to +12
#!/usr/bin/env sh
set -eu

VERSION="${1:-current}"
RESULT_DIR="bench-results/${VERSION}"

mkdir -p "$RESULT_DIR"

cargo test layout_snapshot --all-features -- --nocapture | tee "$RESULT_DIR/layout-test.txt"
cargo bench --bench layout | tee "$RESULT_DIR/layout-bench.txt"
cargo bench --bench comprehensive | tee "$RESULT_DIR/comprehensive.txt"
cargo bench --bench simd --features simd | tee "$RESULT_DIR/simd.txt"
Comment thread scripts/bench-all.ps1
Comment on lines +1 to +16
$Version = if ($args.Count -gt 0) { $args[0] } else { "current" }
$ResultDir = Join-Path "bench-results" $Version

New-Item -ItemType Directory -Force -Path $ResultDir | Out-Null

cargo test layout_snapshot --all-features -- --nocapture |
Tee-Object -FilePath (Join-Path $ResultDir "layout-test.txt")

cargo bench --bench layout |
Tee-Object -FilePath (Join-Path $ResultDir "layout-bench.txt")

cargo bench --bench comprehensive |
Tee-Object -FilePath (Join-Path $ResultDir "comprehensive.txt")

cargo bench --bench simd --features simd |
Tee-Object -FilePath (Join-Path $ResultDir "simd.txt")
Comment thread tests/layout_snapshot.rs
Comment on lines +35 to +49
let snapshot = format!(
concat!(
"{{\n",
" \"crate\":\"cheetah-string\",\n",
" \"profile\":\"test\",\n",
" \"target_arch\":\"{}\",\n",
" \"target_os\":\"{}\",\n",
" \"pointer_width\":\"{}\",\n",
" \"layouts\":[\n {}\n ]\n",
"}}\n"
),
env::consts::ARCH,
env::consts::OS,
std::mem::size_of::<usize>() * 8,
layouts.join(",\n ")
Comment thread benches/layout.rs
Comment on lines +7 to +20
fn target_dir() -> PathBuf {
env::var_os("CARGO_TARGET_DIR")
.map(PathBuf::from)
.unwrap_or_else(|| PathBuf::from("target"))
}

fn layout_entry<T>(name: &str) -> String {
format!(
r#"{{"type":"{}","size":{},"align":{}}}"#,
name,
size_of::<T>(),
align_of::<T>()
)
}
Comment on lines +1 to +12
name: Release

on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
version:
description: "Version to release, for example 1.1.0"
required: true
type: string
Comment thread .github/workflows/ci.yaml
Comment on lines 51 to +63
- name: Test
run: cargo test --verbose --all-features

- name: Layout snapshot
run: cargo test layout_snapshot --all-features -- --nocapture

- name: Upload layout artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: layout-${{ matrix.os }}-${{ matrix.rust }}
path: target/layout-artifacts
if-no-files-found: ignore
@mxsm mxsm force-pushed the codex/pr-004-layout-benchmark-artifacts branch from 7d8e78e to ab3ef5c Compare June 20, 2026 02:29
@mxsm mxsm merged commit 6907298 into main Jun 20, 2026
7 checks passed
@mxsm mxsm deleted the codex/pr-004-layout-benchmark-artifacts branch June 20, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: Add layout snapshot and benchmark artifact workflow

2 participants