The Wire · Showcase
ELIXIR CUTS DURATION PARSING AND TUPLE MATH OVERHEAD
By RepoJournal · Filed · About Elixir & Phoenix
Two core optimizations shipped overnight eliminate redundant passes and stack allocations across Calendar and tuple operations.
Calendar.ISO.parse_duration/1 now applies the leading duration sign as components parse instead of making a second pass for negative durations [1] [3], cutting unnecessary work on every duration calculation your app touches. The same PR ditches keyword-list tails and recursive lookups for ordered positions, compacting the logic further. Separately, tuple aggregates in sum and product operations switched to tail recursion [2] , eliminating intermediate allocations that used to build up on the stack and only resolve on the unwind. Both changes are invisible to your code but measurable in the hot paths. The tail recursion approach "aggregates as it goes, without those allocations" [2], preserving float precision by maintaining original order rather than reversing for speed. These are exactly the kind of under-the-hood wins that compound across millions of operations.
One email a day. Unsubscribe in one click.
Keep up with Elixir & Phoenix in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Pull latest Elixir when available and benchmark Calendar.ISO.parse_duration in your codebase elixir-lang/elixir [plan]
- → Review tuple operations in hot loops for immediate benefit from tail recursion change elixir-lang/elixir [monitor]
References
- [1] Optimize Calendar.ISO.parse_duration/1 ↗ elixir-lang/elixir
- [2] use tail recursion in tuple aggregates ↗ elixir-lang/elixir
- [3] Optimize Calendar.ISO.parse_duration/1 (#15709) elixir-lang/elixir