Skip to content

chore(docs): RFC 0015 introduce no_std#1964

Open
pawelchcki wants to merge 5 commits into
mainfrom
add_no_std_manifesto
Open

chore(docs): RFC 0015 introduce no_std#1964
pawelchcki wants to merge 5 commits into
mainfrom
add_no_std_manifesto

Conversation

@pawelchcki
Copy link
Copy Markdown
Contributor

@pawelchcki pawelchcki commented May 9, 2026

What does this PR do?

Adds RFC 0015 proposing a workspace policy: prefer no_std + alloc; use std only where it earns its keep.

Motivation

no_std is, for a lot of what libdatadog does, the better Rust. core makes async-signal-unsafe items unreachable by construction (relevant for crashtracker and profiling samplers), embedders linking statically pay for less code, and once a crate is no_std every new dependency comes with a forced "what does this drag in?" review.

Many migrations are mechanical (std::core::, see yaml/yaml-serde#8). #1770 is the in-flight reference implementation for libdd-library-config.

How to test the change?

Read it. Comment if you disagree.

Propose a workspace policy that prefers `no_std + alloc` and uses
`std` only where it earns its keep. Motivated by signal safety,
smaller artifacts, and tighter dependency hygiene.
@pawelchcki pawelchcki force-pushed the add_no_std_manifesto branch from 666e263 to 6da17cf Compare May 9, 2026 17:41
@datadog-official
Copy link
Copy Markdown

datadog-official Bot commented May 9, 2026

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 72.64% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 1d89a15 | Docs | Datadog PR Page | Give us feedback!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.63%. Comparing base (91fd13c) to head (1d89a15).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##             main    #1964     +/-   ##
=========================================
  Coverage   72.63%   72.63%             
=========================================
  Files         448      451      +3     
  Lines       73582    74687   +1105     
=========================================
+ Hits        53444    54251    +807     
- Misses      20138    20436    +298     
Components Coverage Δ
libdd-crashtracker 65.32% <ø> (+0.24%) ⬆️
libdd-crashtracker-ffi 37.68% <ø> (+0.85%) ⬆️
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 85.97% <ø> (-0.62%) ⬇️
libdd-data-pipeline-ffi 71.04% <ø> (-4.60%) ⬇️
libdd-common 79.81% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (+3.96%) ⬆️
libdd-telemetry-ffi 31.36% <ø> (+11.99%) ⬆️
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.22% <ø> (ø)
libdd-profiling 81.58% <ø> (+0.01%) ⬆️
libdd-profiling-ffi 64.51% <ø> (ø)
libdd-sampling 97.25% <ø> (ø)
datadog-sidecar 29.09% <ø> (-0.75%) ⬇️
datdog-sidecar-ffi 9.67% <ø> (-3.55%) ⬇️
spawn-worker 48.86% <ø> (-5.83%) ⬇️
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.39% <ø> (+0.13%) ⬆️
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.59% <ø> (+0.31%) ⬆️
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 9, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.57 MB 7.57 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 81.66 MB 81.66 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.01 MB 10.01 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 97.84 MB 97.84 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 24.40 MB 24.40 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 79.87 KB 79.87 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 179.62 MB 179.64 MB +0% (+16.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 910.67 MB 910.67 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 7.71 MB 7.71 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 79.87 KB 79.87 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.11 MB 23.11 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 45.25 MB 45.25 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.02 MB 21.02 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 81.11 KB 81.11 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 183.76 MB 183.77 MB +0% (+16.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 896.93 MB 896.93 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 5.98 MB 5.98 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 81.11 KB 81.11 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 24.74 MB 24.74 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 42.75 MB 42.75 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 72.78 MB 72.78 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.41 MB 8.41 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 90.53 MB 90.53 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.03 MB 10.03 MB 0% (0 B) 👌

@pawelchcki pawelchcki requested review from a team, ivoanjo and morrisonlevi May 14, 2026 09:16
@pawelchcki pawelchcki marked this pull request as ready for review May 14, 2026 09:17
@pawelchcki pawelchcki requested a review from a team as a code owner May 14, 2026 09:17
Copilot AI review requested due to automatic review settings May 14, 2026 09:17
@pawelchcki pawelchcki changed the title chore(docs): RFC 0015 opportunistic no_std chore(docs): RFC 0015 no_std May 14, 2026
@pawelchcki pawelchcki changed the title chore(docs): RFC 0015 no_std chore(docs): RFC 0015 introduce no_std May 14, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new RFC document (0015) proposing an opportunistic workspace policy to prefer no_std + alloc over std where it benefits consumers (signal safety, smaller artifacts, dependency hygiene), with concrete crate conventions, CI enforcement, initial migration candidates, and discussion of drawbacks/alternatives.

Changes:

  • Adds docs/RFCs/0015-no-std.md describing the rationale and policy for opportunistic no_std adoption.
  • Documents per-crate conventions (feature flags, crate-root attributes, import patterns, dependencies, errors).
  • Lists initial migration candidates (e.g., libdd-library-config, libdd-crashtracker collector half) and out-of-scope crates.

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

Comment thread docs/RFCs/0015-no-std.md Outdated
Comment thread docs/RFCs/0015-no-std.md
Comment on lines +7 to +11
Concretely, four things make `no_std` attractive for this workspace:

1. **Signal safety by construction.** `core` and `alloc` (with a signal-safe allocator) are made of pure functions, integer math, and stack-allocated data. None of `std`'s mutex, thread-local, environment, file-descriptor, or panic-handler machinery is reachable. Code that runs in async-signal contexts — crashtracker, profiling samplers, anything called from a signal handler — is *much* easier to keep correct when `std::` is simply not in the import graph. The compiler enforces what code review otherwise has to.
2. **Smaller artifacts.** Embedders linking libdatadog statically pay for everything `std` pulls in, whether they use it or not. `no_std + alloc` lets us ship the same functionality with substantially less code in the final binary, and noticeably faster compiles in the tree.
3. **Frequently, it's a mechanical change.** A surprising amount of "make this `no_std`" work is replacing `std::` with `core::` and adding `extern crate alloc;`. yaml/yaml-serde#8 is a recent example: a near-mechanical patch turned an `std` crate into a `no_std + alloc` crate without changing its API. Many of our internal crates are in the same shape.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sigh

Comment thread docs/RFCs/0015-no-std.md Outdated
Comment thread docs/RFCs/0015-no-std.md Outdated
Comment thread docs/RFCs/0015-no-std.md
## Drawbacks

- **Build matrix grows.** Each opted-in crate adds a `--no-default-features` build to CI. Real but bounded.
- **no_std rust ecosystem is large, but not all crates support it** Code willing to support `no_std` might have to do extra work to align dependencies with `no_std` requirements.
Comment thread docs/RFCs/0015-no-std.md

Concretely, four things make `no_std` attractive for this workspace:

1. **Signal safety by construction.** `core` and `alloc` (with a signal-safe allocator) are made of pure functions, integer math, and stack-allocated data. None of `std`'s mutex, thread-local, environment, file-descriptor, or panic-handler machinery is reachable. Code that runs in async-signal contexts — crashtracker, profiling samplers, anything called from a signal handler — is *much* easier to keep correct when `std::` is simply not in the import graph. The compiler enforces what code review otherwise has to.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not really. Just because you don't call signal-unsafe items doesn't make what you do signal safe. Yes, it's certainly easier, but it's not automatic. You still have to worry about reentrancy, atomicity, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I framed it like it solves all problems :D

Comment thread docs/RFCs/0015-no-std.md

## The thesis

**Prefer `no_std + alloc`. Use `std` only where it is earning its keep.**
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we want alloc? We also shouldn't panic, and tons of users of alloc panic on allocation failure. What's the motivation for including alloc in the recommendation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just found no_std + alloc is super easy to use and solving all my problems, and you really can have some safe'ish alloc implementations. and

Ideally people could target no_std and add alloc on top if needed.

tl;dr; alloc does make no_std quite bearable

pawelchcki and others added 3 commits May 14, 2026 16:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

4 participants