- [Enhancement] Specialize
Contract#digfor common 1-key and 2-key paths to avoid iterator overhead, yielding ~1.5x faster single-key lookups and ~1.45x faster two-key nested lookups. - [Enhancement] Replace
Node#build_accessors@local_defsArray with Hash for O(1) membership checks instead of O(n)Array#include?, yielding up to ~5x faster accessor lookups at 50 settings. - [Enhancement] Use frozen
EMPTY_ARRAYconstant forContract#calland#validate!defaultscopeparameter to avoid allocating a new Array on every invocation, yielding ~1.36x faster call dispatch and saving 1 Array allocation per call. - [Enhancement] Pre-resolve
@events_methods_mapmethod name before the listener notification loop inNotifications#instrumentto avoid repeated Hash lookup per listener, yielding ~1.12x faster event dispatch with multiple listeners. - [Enhancement] Cache a frozen success
Resultsingleton viaResult.successto eliminate 1 object allocation per successfulContract#callon the happy path. - [Enhancement] Skip nestings block re-evaluation in
Node#deep_dupto avoid recreating children that are immediately overwritten, yielding ~14x faster deep_dup and reducing allocations from ~620 to ~66 objects for large configs. - [Enhancement] Cache
CallbacksManager#callvalues snapshot and invalidate onadd/deleteto avoid allocating a new Array on every invocation while preserving thread-safety snapshot semantics, saving 1 Array allocation per call. - [Enhancement] Store execution time separately in
Eventand build the merged payload hash lazily on#payloadaccess, eliminating 1 Hash allocation perNotifications#instrumentcall when listeners use#[]access (the common pattern), yielding ~1.7x faster event dispatch. - [Enhancement] Replace
StatisticsDecorator#diffpending-writes buffer withkeys.eachdirect-write iteration, eliminating the buffer and write-back loop for ~13% faster decoration at scale (10 brokers, 20 topics, 2000 partitions). - [Enhancement] Reorder
StatisticsDecorator#difftype checks to testNumericbeforeHash, matching the ~80% numeric value distribution in librdkafka statistics. - [Enhancement] Support
only_keysoption inStatisticsDecoratorto decorate only specified numeric keys (e.g.consumer_lag,committed_offset). When combined withexcluded_keys, reduces decoration cost from ~80ms to ~8.5ms per call on large clusters (10 brokers, 20 topics, 2000 partitions) by using structure-aware navigation of the librdkafka statistics tree and direct key access instead of full-hash iteration.