AGENTS.md
src/core/lib/slice/AGENTS.mdAGENTS.md
Quality
48/100
Scores the file, not the repository.Length
553 words
7 headings · 0 code blocksRepository
45k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# Slice23This directory contains the implementation of the gRPC slice library, which4provides a set of data structures for representing and manipulating blocks of5memory.67## Overarching Purpose89The slice library is a core component of gRPC's C-core. It is used extensively10throughout the gRPC codebase to represent message payloads, metadata, and other11data. Its primary purpose is to provide a safe, efficient, and flexible way to12manage memory.1314## Core Concepts1516The slice library is built around a few key abstractions:1718* **`Slice`**: A `Slice` is a reference-counted, immutable string-like object. It is the most common type of slice, and it is used to represent data that is shared between multiple parts of the codebase.19* **`MutableSlice`**: A `MutableSlice` is a slice that is guaranteed to have a unique owner. This means that the underlying data can be mutated safely.20* **`StaticSlice`**: A `StaticSlice` is a slice that points to a21 statically-allocated block of memory. It is not reference-counted, and it is22 very fast to copy.23* **`SliceBuffer`**: A `SliceBuffer` is a container for a collection of `Slice`24 objects. It is used to represent a sequence of slices, such as a message.2526The key to understanding the slice library is to understand the ownership model.27A `Slice` can be either "owned" or "unowned". An owned slice has a reference28count, and the underlying memory is freed when the reference count drops to zero.29An unowned slice does not have a reference count, and the underlying memory is30not freed when the slice is destroyed. The type of a slice determines its31ownership model.3233## Performance3435The slice library is a key component of gRPC's performance and memory36efficiency. It allows gRPC to avoid unnecessary data copies and to manage memory37in a more efficient way. For example, when a message is received, it can be38represented as a `SliceBuffer` of `Slice`s. Each `Slice` can point to a different39part of the underlying network buffer. This allows the message to be processed40without having to copy the data into a contiguous block of memory.4142## Files4344* **`slice.h`, `slice.cc`**: These files define the `Slice`, `MutableSlice`, and45 `StaticSlice` classes.46* **`slice_buffer.h`, `slice_buffer.cc`**: These files define the `SliceBuffer` class.47* **`slice_internal.h`**: This file contains the internal implementation details48 of the slice library.49* **`slice_refcount.h`**: This file defines the `grpc_slice_refcount` class,50 which is used to manage the reference count of a slice.51* **`percent_encoding.h`, `percent_encoding.cc`**: These files provide52 functions for percent-encoding and decoding slices. This is used to encode53 binary data in a way that is safe for transmission over HTTP/2.5455## Major Classes5657* `grpc_core::Slice`: A reference-counted, immutable string-like object.58* `grpc_core::MutableSlice`: A slice with a unique owner, allowing for safe mutation.59* `grpc_core::StaticSlice`: A slice that points to statically-allocated memory.60* `grpc_core::SliceBuffer`: A container for a collection of `Slice` objects.6162## Notes6364* The slice library is a low-level component of the gRPC stack. Most65 application developers will not need to interact with it directly.66* The `Slice` and `SliceBuffer` classes are designed to be thread-safe.67* The slice library is a good example of how gRPC uses a combination of C and68 C++ to achieve high performance and memory efficiency. The core data69 structures are implemented in C, and then wrapped in C++ classes to provide a70 more convenient and safe API.71
Also in grpc/grpc
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| grpc/grpcsrc/core/ext/filters/census/AGENTS.md · 45k | AGENTS.md | no sections | 25/100 | 3 days ago | |
| grpc/grpcsrc/core/ext/filters/gcp_authentication/AGENTS.md · 45k | AGENTS.md | security | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/ext/filters/http/AGENTS.md · 45k | AGENTS.md | no sections | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/ext/filters/stateful_session/AGENTS.md · 45k | AGENTS.md | no sections | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/ext/transport/chaotic_good/AGENTS.md · 45k | AGENTS.md | no sections | 48/100 | 3 days ago | |
| grpc/grpcsrc/core/ext/transport/inproc/AGENTS.md · 45k | AGENTS.md | no sections | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/filter/AGENTS.md · 45k | AGENTS.md | no sections | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/handshaker/AGENTS.md · 45k | AGENTS.md | no sections | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/server/AGENTS.md · 45k | AGENTS.md | no sections | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/service_config/AGENTS.md · 45k | AGENTS.md | no sections | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/telemetry/AGENTS.md · 45k | AGENTS.md | no sections | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/transport/AGENTS.md · 45k | AGENTS.md | no sections | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/credentials/transport/AGENTS.md · 45k | AGENTS.md | security | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/ext/filters/backend_metrics/AGENTS.md · 45k | AGENTS.md | no sections | 44/100 | 3 days ago | |
| grpc/grpcsrc/core/credentials/AGENTS.md · 45k | AGENTS.md | security | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/tsi/AGENTS.md · 45k | AGENTS.md | security | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/tsi/alts/AGENTS.md · 45k | AGENTS.md | no sections | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/credentials/call/AGENTS.md · 45k | AGENTS.md | security | 39/100 | 3 days ago | |
| grpc/grpcsrc/core/ext/transport/chttp2/AGENTS.md · 45k | AGENTS.md | testarchdependencies | 48/100 | 3 days ago | |
| grpc/grpcAGENTS.md · 45k | AGENTS.md | styledependenciesdo-not | 54/100 | 3 days ago |
Diff against src/core/ext/filters/census/AGENTS.md Diff against src/core/ext/filters/gcp_authentication/AGENTS.md Diff against src/core/ext/filters/http/AGENTS.md Diff against src/core/ext/filters/stateful_session/AGENTS.md Diff against src/core/ext/transport/chaotic_good/AGENTS.md Diff against src/core/ext/transport/inproc/AGENTS.md Diff against src/core/filter/AGENTS.md Diff against src/core/handshaker/AGENTS.md Diff against src/core/server/AGENTS.md Diff against src/core/service_config/AGENTS.md Diff against src/core/telemetry/AGENTS.md Diff against src/core/transport/AGENTS.md Diff against src/core/credentials/transport/AGENTS.md Diff against src/core/ext/filters/backend_metrics/AGENTS.md Diff against src/core/credentials/AGENTS.md Diff against src/core/tsi/AGENTS.md Diff against src/core/tsi/alts/AGENTS.md Diff against src/core/credentials/call/AGENTS.md Diff against src/core/ext/transport/chttp2/AGENTS.md Diff against AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| vllm-project/vllmAGENTS.md · 88k | AGENTS.md | setuptestlint-formatstyle+5 | 100/100 | 3 days ago | |
| netdata/netdatasrc/go/plugin/ibm.d/AGENTS.md · 80k | AGENTS.md | buildtestlint-formatarch+3 | 99/100 | 3 days ago | |
| react/react-nativepackages/react-native-compatibility-check/AGENTS.md · 126k | AGENTS.md | testlint-formatstylearch+4 | 99/100 | 3 days ago | |
| duckdb/duckdbAGENTS.md · 40k | AGENTS.md | buildtestlint-formatstyle+8 | 96/100 | today | |
| dragonflydb/dragonflyAGENTS.md · 31k | AGENTS.md | setupbuildtestlint-format+10 | 96/100 | 2 days ago | |
| dotnet/aspnetcoresrc/Components/AGENTS.md · 38k | AGENTS.md | buildteststylearch+3 | 96/100 | 3 days ago | |
| steipete/CodexBarAGENTS.md · 20k | AGENTS.md | buildteststylearch+4 | 93/100 | 3 days ago |
