fast-string-allocations
/fast-string-allocations
Podpowiada strategie budowania ciągów znaków bez alokacji, np. przy formatowaniu, generowaniu kodów ANSI i w gorących pętlach, by uniknąć alokacji na stercie i narzutu maszyny stanów Formatter.
- Autor
- r3bl-org ↗
- Repozytorium
- r3bl-open-core ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 17.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 17.10.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Podpowiada strategie budowania ciągów znaków bez alokacji, np. przy formatowaniu, generowaniu kodów ANSI i w gorących pętlach, by uniknąć alokacji na stercie i narzutu maszyny stanów Formatter.
Oryginalny opis (EN)
Zero-allocation string building strategies. Use when formatting strings, generating ANSI codes, or writing hot loops to avoid heap allocations and Formatter state machine overhead.
Jak działa
- When to Use
- Core Strategy
- Implementation Guidelines
Podgląd SKILL.md
--- name: fast-string-allocations description: Zero-allocation string building strategies. Use when formatting strings, generating ANSI codes, or writing hot loops to avoid heap allocations and Formatter state machine overhead. --- # Fast String Allocations & Zero-Overhead Formatting When writing code that involves string building, formatting, or rendering (especially in the TUI engine, logging, or event loops), you MUST adhere to the codebase's strict zero-allocation architecture. ## When to Use - When building ANSI escape sequences - When building strings in a 60 FPS event loop or render cycle - When using `tracing::*!` macros - Whenever you are tempted to use `format!` or `write!` on a `Formatter` ## Core Strategy Read the full Source of Truth at `mod@crate::core::common::fast_strings#string-allocation-performance-strategy` for detailed architectural constraints. ### Performance Hierarchy (Fastest to Slowest) 1. **Direct `push_str()`** - Zero overhead, direct memory copy. 2. **`crate::format_no_alloc!`** - Zero heap allocations, reuses existing heap. 3. **`FastStringify`** - Temporary heap allocation, completely bypasses `Formatter` state machine. 4. **`inline_string!`** - Stack allocated (16 bytes), but dynamically spills to the heap if exceeded. 5. **`format!` / `write!`** - Always heap allocates (`format!`) OR uses heavy formatter overhead (`write!`). Avoid in hot paths. ## Implementation Guidelines ### 1. The `FastStringify` Trait Use for custom types (like `ANSI` codes) that are serialized millions of times. - Bypasses the expensive `Formatter` state machine by pushing everything into a temporary heap `String` and making ONE `f.write_str()` call. - Use `generate_impl_display_for_fast_stringify!` to auto-generate the `Display` block. ### 2. The `inline_string!` Macro Use for stack-allocated strings (16 bytes). - Drop-in replacement for `format!`. - The primary use case is the core Editor Component and `tracing::*!` macros. - **Warning:** If text exceeds 16 bytes, it spills to the heap and incurs the cost of `format!`. ### 3. The `format_no_alloc!` Macro Use for hot loops where the string is guaranteed to exceed 16 bytes (meaning `inline_string!` would spill). - Hoist a `String::with_capacity(N)` outside the loop. - Pass the hoisted string into the macro inside the loop to clear and write into the existing capacity. - Zero allocations per tick.
Wersje
W bazie nie ma innych skilli o nazwie fast-string-allocations.
Migawka bazy z 13.11.2026 · wersja paczki 4cdf01162870 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100memory-allocation-analyzer
Znajduje zbędne alokacje na stercie w gorących ścieżkach C#, jak LINQ w pętlach, boxing i domknięcia, oraz przepisuje kod tak, by zmniejszyć obciążenie GC. - 100heaptrack
Śledzi alokacje pamięci w Linuksie przez heaptrack: gorące punkty alokacji, szczytowe zużycie, wycieki i porównanie dwóch uruchomień. - 90review-perf
Przegląda zmiany pod kątem wydajności: regresji złożoności, powtarzalnej pracy, zbędnych alokacji i gorących ścieżek. - 100heaptrack
Profiluje pamięć na Linuksie narzędziem heaptrack: śledzenie alokacji sterty, wycieki pamięci, szczytowe użycie, gorące punkty alokacji i porównanie zachowania alokacji między uruchomieniami, w tym heaptrack_print. - 100go-performance
Pomaga profilować, benchmarkować i optymalizować kod Go: metodyka najpierw mierz, drzewo decyzji pprof, redukcja alokacji, wskazówki pojemności, wzorce dla gorących ścieżek i strojenie runtime. - 100go-performance
Pomaga profilować, benchmarkować i optymalizować kod Go: metodyka najpierw mierz, drzewo decyzji pprof, redukcja alokacji, wskazówki pojemności, wzorce dla gorących ścieżek i strojenie runtime.