Skip to content

Switch text dict runtime backend from Marisa to Darts - #1376

Merged
frankslin merged 1 commit into
BYVoid:masterfrom
frankslin:upstream-master
Jul 1, 2026
Merged

frankslin merged 1 commit into
BYVoid:masterfrom
frankslin:upstream-master

Conversation

@frankslin

Copy link
Copy Markdown
Collaborator

When loading a .txt-format dict (from zip or filesystem), build a DartsDict in-memory instead of a MarisaDict. Darts trie construction and prefix-match queries are both faster than MARISA's for this workload.

Benchmark (1 MB corpus, -c opt, ZipResourceProvider; init measured at 100 KB):

  format        s2t (M/s)  s2twp (M/s)  s2t init (ms)  s2twp init (ms)
  txt  (before)      22           8.2            ~46              ~50
  txt  (after)       33          10.0             25               30
  ocd2 (marisa)      22           8.3             17               23
  ocd  (darts)       32           9.9             11               16

txt throughput after the change matches pre-built ocd; init time drops by roughly half. ocd2 is now the only format without a Darts-speed conversion path.

Also adds src/tools/SpeedBenchmark.cpp (with --resource-zip support) as a Bazel build target for future benchmarking.

When loading a .txt-format dict (from zip or filesystem), build a DartsDict
in-memory instead of a MarisaDict.  Darts trie construction and prefix-match
queries are both faster than MARISA's for this workload.

Benchmark (1 MB corpus, -c opt, ZipResourceProvider; init measured at 100 KB):

  format        s2t (M/s)  s2twp (M/s)  s2t init (ms)  s2twp init (ms)
  txt  (before)      22           8.2            ~46              ~50
  txt  (after)       33          10.0             25               30
  ocd2 (marisa)      22           8.3             17               23
  ocd  (darts)       32           9.9             11               16

txt throughput after the change matches pre-built ocd; init time drops by
roughly half.  ocd2 is now the only format without a Darts-speed conversion
path.

Also adds src/tools/SpeedBenchmark.cpp (with --resource-zip support) as a
Bazel build target for future benchmarking.
@frankslin
frankslin merged commit eea218f into BYVoid:master Jul 1, 2026
33 checks passed
@frankslin
frankslin deleted the upstream-master branch July 1, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant