Skip to content

v0.2.1: perf: spawn DB write instead of block_on on pen-up

Choose a tag to compare

@liuluopeng liuluopeng released this 08 Jul 05:13
Previously glaspen2_modeler_end() called runtime().block_on(db::end_stroke())
which blocked the CGEventTap thread on SQLite INSERT + transaction commit.
Flame-graph showed ~3.2% of main-thread time spent in this block_on.

Now end_stroke_spawned() atomically takes the pending stroke-id and points
from memory (synchronous Mutex ops, ~1μs), then spawns the DB write on the
tokio runtime. The event-tap thread returns immediately.

The old block_on path is kept for clear_strokes which must flush before
checking screen_has_strokes and creating a new screen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>