Repository navigation
Tempest v1.11.0 is a major performance and modernization release. This update completes the framework's migration to Go's modern encoding/json/v2 engine, replaces zlib-compression with zstd-stream compression (which is much more performant), adds buffer pooling and response streaming across the REST and Gateway hot paths to reduce number of memory allocations and overhauls interaction dispatch with zero-copy pointer semantics (again, sorry - we had that in past).
What's Changed
- Fully transitioned all internal serialization and deserialization of json objects to Go's
encoding/json/v2andencoding/json/jsontext, providing anywhere from 5% to 15% faster JSON throughput but what's more important: we noticed lower CPU overhead and memory usage in every single benchmark and test we've made. - Standardized
omitzerostruct flag across all discord models for numeric IDs, counts, bitset flags, enums, boolean options, etc. preventing accidental serialization of invalid zero values (some of that was required due to small behavior change in json/v2). - Further optimized hot paths and struct definitions that caused extra memory allocations:
- Snowflakes now implement
encoding.TextAppender(AppendText) andUnmarshalText, making them faster and cheaper to parse. - Rate limiter now better handles
/interactions/routes, making them much cheaper at cost of slightly higher base/idle memory use. - User struct can be now parsed without extra reflection but as side effect:
user.DisplayName()is now a function instead value. - Added zero-allocation discriminator scanners (
peekInteractionType,peekComponentType) usingjsontext.Decoderto inspect payloads in a single forward pass without unmarshaling into intermediate maps. - Improved signature verification on incoming HTTP requests making them do less allocations.
- Converted
CommandInteraction,ComponentInteraction,ModalInteraction, andAutoCompleteInteractionto pointer dispatch (*CommandInteraction), eliminating struct copying and heap escapes across goroutines. - Specialized interaction wrappers now embed the base
Interactionstruct by value instead of by pointer, eliminating an extra heap allocation per interaction. - Added global
sync.Poolinstances for*bytes.Bufferand*bytes.ReadertoRest, eliminating heap allocations for request bodies, and stream responses directly viajson.UnmarshalRead.
- Snowflakes now implement
- Upgraded GatewayClient compression from
zlib-streamto streamingzstd(Compression/ZstdCompression) powered byklauspost/compress/zstd. The decoder is reused across reconnects, cutting incoming Gateway memory and CPU overhead by up to ~70%. - Incoming and outgoing WebSocket frames now stream directly using zero-copy
jsontext.Value, and read deadlines are refreshed adaptively to reduce deadline churn. - Hardened
RateLimiterbucket synchronization to honor learned windows, preventing 429 retry loops under high concurrency, and restricted unsafe retries on non-idempotent endpoints. - Added uniform resolved entity accessors (
itx.Data.Resolved.Resolve*(id)), modal component getters, and helper to instantly acknowledge & update parent component messages. - Updated Discord API models with latest Discord docs, modernized the example bot, and standardized doc comments across the codebase.
- Fixed
FindInteractiveComponentprematurely stopping on the first child instead of recursively inspecting all children thanks by @Bertie690 in #71.
Full Changelog: v1.10.5...v1.11