ActivityWatch / ActivityWatch/aw-server-rust
Performance: interval reads, event transforms, query copies, and HTTP exports
- Vorherrschende Sprache
- Rust
- Sterne
- 315
- Forks
- 96
- Ø Merge
- 2 T. 21 Std.
- Gemergte PRs (30 T.)
- 14
Beschreibung
Track five independent performance improvements identified while reviewing `02ae248`. Each fix has its own PR, independently based on master.
- [ ] Reduce historical scanning for bounded event interval queries — #676. Add a selectively used endtime-first index while preserving overlap semantics, tie ordering, and fast limited newest-first reads. The PR documents index storage/migration costs and measured bulk-insert overhead.
- [ ] Make `union_no_overlap` linear in input size and emitted fragments — #674. Replace repeated middle-of-vector insertions with a pending remainder and move events where possible.
- [ ] Reduce allocations in `merge_events_by_keys` — #673. Remove the unused per-group map, use the entry API, and move the first event into each group instead of cloning its JSON.
- [ ] Avoid deep event-list copies for read-only query functions — #675. Borrow simple variable/literal arguments without changing query language value semantics. Related background: #119, #122, #183.
- [ ] Bound HTTP export memory — #677. Serialize one row at a time into a private temporary file and serve the completed file, preserving the export format, acknowledged writes, and pre-download HTTP errors. Temporary disk use and datastore-worker occupancy are documented tradeoffs.
Initial local probes (synthetic data, not end-to-end application measurements):
- A recent interval containing 1,001 events in a million-row in-memory SQLite database took 44.9 ms with the current index versus 0.41 ms with a forced end-time-first index. This is evidence to evaluate query selection, not a recommendation to replace the existing index unconditionally.
- Overlap merging took 176 ms at 16,000 events per input and 632 ms at 32,000 events per input.
- A grouping prototype reduced 50,000 distinct groups from 22.6 ms to 10.3 ms; with 100 groups the improvement was 11.2 ms to 10.3 ms.
Android context: ActivityWatch/aw-android#229 fixes saving WebView exports and persists queued payloads in cache files. It does not remove full-payload buffering in the Rust HTTP export path; the WebView bridge also still assembles a complete string. This item targets the Rust HTTP path only.
Validation should include representative scaling benchmarks, regression coverage for behavior and edge cases, and independent crate/API checks per PR. Checklist items remain open until their fixes are merged.
Implementation validation uses synthetic in-memory data and isolated temporary test databases only; no live database or running server was used. Reproducible benchmarks/examples are included in the PRs. Additional comparisons against upstream `02ae248`:
- Rust interval benchmark, one million rows: recent 1,001-row retrieval ≈24.1 ms → 0.40 ms; recent count ≈19.7 ms → 19 µs. A 10,000-row insert probe measured ≈20% overhead for maintaining the extra index.
- Query workload, 50,000 events and 20 duration sums: ≈118.8 ms → 15.8 ms, including retrieval.
- Export serializer, 100,000 events with 256-character titles: peak RSS ≈194 MiB materialized → 52 MiB incremental. This includes the synthetic in-memory input database and excludes temporary-file I/O; it is not an HTTP throughput measurement.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.