Skip to content

Comments

perf: replace chars().count() / 4 with len() / 3 in token estimation#328

Merged
bug-ops merged 2 commits intomainfrom
perf/token-estimation
Feb 15, 2026
Merged

perf: replace chars().count() / 4 with len() / 3 in token estimation#328
bug-ops merged 2 commits intomainfrom
perf/token-estimation

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Feb 15, 2026

Summary

  • Replace text.chars().count() / 4 with text.len() / 3 in estimate_tokens
  • 10-20x faster for large strings; byte-length heuristic sufficient for budget estimation

Closes #313

10-20x faster for large strings. Byte-length heuristic is sufficient
for budget estimation.

Closes #313
@github-actions github-actions bot added memory Persistence and memory rust core performance Performance optimization size/S labels Feb 15, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #328   +/-   ##
=======================================
  Coverage   80.36%   80.36%           
=======================================
  Files          99       99           
  Lines       24163    24163           
=======================================
  Hits        19419    19419           
  Misses       4744     4744           
Files with missing lines Coverage Δ
crates/zeph-core/src/context.rs 97.65% <100.00%> (ø)
crates/zeph-memory/src/semantic.rs 77.82% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bug-ops bug-ops enabled auto-merge (squash) February 15, 2026 13:57
@bug-ops bug-ops merged commit 6dc776e into main Feb 15, 2026
17 checks passed
@bug-ops bug-ops deleted the perf/token-estimation branch February 15, 2026 14:06
@bug-ops bug-ops mentioned this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core memory Persistence and memory performance Performance optimization rust size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: replace chars().count() / 4 with len() / 3 in token estimation

2 participants