HermitCrab analysis: a per-word root-search cache cut Sena work 21.3% in the port; C# repeat-lookup share unmeasured

Đang mở
#600 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
performance

Hướng nghiên cứu

Read row 28 of the #490 ledger and the issue’s C# versus PanGloss comparison first. Measure the cost of repeated (stratum, shape) root-trie lookups on Sena in C# before implementing anything. Done means reporting whether that work share is material and, based on the result, whether to port the bounded per-word cache.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Claude-drafted.

A per-word root-search cache cut Sena work by 21.3% in the Rust port, but the C# record says repeated root lookups are only 0.5 to 3.3% of parser work. Whether C# has the same gap is unmeasured. Analysis branches that reach the same (stratum, shape) repeat the identical root-trie search.

Status: merged in the port; not built in C#.

What we know (port, work steps; parses identical on every completed word):

  • Sena: 182,297,249 to 143,399,740 (-21.3%, measured before the edge index of #599 landed). Mbugwe -0.6%; Cebuano -0.1%, or -1.2% with an added enclitic; the other samples and fixtures about 0.
  • It holds the raw ordered trie result per word, keyed by exact (stratum, shape), capped at 1 MiB (peak 1.04 MB on Sena), and is discarded after each word. Lexical-entry filtering, overlay and dedup still run on every lookup. A capped or timed-out search is never cached. A result is stored only if its search cost more than a hit is charged, so no path costs more.
  • Ledger row 28 closed a similar C# cache: untraced C# makes 1.13 to 1.49 calls per distinct (stratum, shape).
  • Inferred: the port's larger gain comes from charging a lookup per trie edge, which makes repeats dearer than in C#'s unit.

Not known: the share of C# work spent on repeated lookups on Sena.

Proposed change: measure that share first, on hc.dll, in lookups and work steps. Port the cache only if the share is material, and then only after an explicit decision against the no-memoization rule (ledger row 38): it is a bounded memo.

Related:

  • PanGloss: sillsdev/PanGloss#92 (closed by PR sillsdev/PanGloss#96, merged).
  • sillsdev/machine#599 (open); #490 (closed PR, retired record).

Next: count untraced repeated (stratum, shape) lookups and their work on Sena in hc.dll.


Evidence -- numbers, method

From PanGloss PR #96 and its lane report (single-threaded --stats).

Grammar Work before Work after Peak cache
Sena 182,297,249 143,399,740 (-21.3%) 1,042,524 B
Sena, with the port's edge index (#599) and cache together 182,297,249 138,405,255 (-24.1%) 1,042,524 B
Mbugwe, 1,636 completed words 35,582,069,812 35,354,992,356 (-0.6%) 1,048,396 B (cap 1,048,576)
Cebuano base 5,395,400 5,392,090 (-0.06%) 427,336 B
Cebuano with enclitic 6,340,178 6,265,316 (-1.2%) 427,336 B

Cebuano rows compare against a build with the edge index but no cache. Seven Mbugwe words never complete on either build and are unverified. Cache bounds are conservative allocation estimates, not allocator measurements.

Surprising findings -- why this reopens a closed ledger row

Row 28 closed the cache because trace mode (which disables merging) had inflated the lookup count to 97,575 over 56 shapes. Untraced, repeat-lookup work was 0.5 to 3.3% of parser work (10.4% only on row 25's pre-fix bug); lookup was 1 to 12% of parser work. PanGloss merged a narrower version anyway: per word, exact key, capped, discarded after each word.

Lookup gap (search-cost round, open lead 14): on the slowest word of one private project, the port made 18 lookups on C#'s export against C#'s 49. Parses were identical and the cause was not investigated there. Ledger row 24 later attributed a related gap (18 lookups against 1,655 on the port's own snapshot) to a loading difference, not search. Neither figure is evidence about repeats in C#.

Sources -- pinned
Ngôn ngữ chính
C#
Star
29
Fork
16
Merge trung bình
5 ngày 20 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của sillsdev/machine

Tất cả issue của sillsdev/machine

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.