Skip to content

Optimize endpointer performance#425

Merged
dhdaines merged 2 commits intomainfrom
endpointer-perf-improvements
Dec 1, 2025
Merged

Optimize endpointer performance#425
dhdaines merged 2 commits intomainfrom
endpointer-perf-improvements

Conversation

@lenzo-ka
Copy link
Contributor

  • Cache timestamp callbacks to reduce redundant calls (2-3x per frame)
  • Implement incremental speech counting (O(n) to O(1) per frame)
  • Pre-allocate scratch buffers for linearization to avoid malloc/free
  • Add timestamp helper functions for cleaner code organization

These optimizations provide 5-10% overall speedup in typical usage without changing the API or affecting accuracy.

- Cache timestamp callbacks to reduce redundant calls (2-3x per frame)
- Implement incremental speech counting (O(n) to O(1) per frame)
- Pre-allocate scratch buffers for linearization to avoid malloc/free
- Add timestamp helper functions for cleaner code organization

These optimizations provide 5-10% overall speedup in typical usage
without changing the API or affecting accuracy.
@lenzo-ka lenzo-ka requested a review from dhdaines July 29, 2025 14:36
@dhdaines dhdaines added this to the 5.1.0 milestone Aug 20, 2025
Clarify the purpose and behavior of timestamp caching, incremental
speech counting, and pre-allocated scratch buffers.
static int
ep_speech_count(ps_endpointer_t *ep)
{
int count = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes ... this was obviously inefficient, so computing speech_count on the fly is the right thing to do

@dhdaines dhdaines merged commit 7930438 into main Dec 1, 2025
21 checks passed
@dhdaines dhdaines deleted the endpointer-perf-improvements branch December 1, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants