x18n
| Target | என்ன run ஆச்சு | Result |
|---|---|---|
packages/core, 9 units, 29 functions |
analyze, bridge, record, diff, bench, shadow, gate | எல்லா gate-உம் pass ஆகுது; 7,925 record ஆன cases match ஆகுது; bridge வழியா TS-ஐ விட மெதுவு (report) |
packages/builtins/src/formats/shared/, 7 functions |
அதே | 3,672/3,672 cases match ஆகுது, அதுல 960 repository-ல உள்ள 40 உண்மையான files-ல இருந்து (YAML locales, JSON, Markdown, TS) LF மற்றும் CRLF-ல உருவாக்கப்பட்டது |
| முழு repository | analyze | 142 units; start_here இப்போ bridgeable exports இருக்கிற units-ஐ மட்டும் காட்டுது |
Tool-ல கண்டுபிடிச்சு, fix பண்ணப்பட்டது:
analyzeமுதல்ல format parsers-ஐ recommend பண்ணுச்சு, ஆனா அவற்றோட ஒரே exports plugin factories (properties(): Plugin).analyzeஇப்போbridgeapply பண்ணுற rules வெச்சு bridgeable exports-ஐ எண்ணுது, எதுவும் இல்லாத units-ஐstart_here-ல இருந்து விட்டுடுது.- Workspace packages (
@x18n/core) இருந்து import ஆன types follow பண்ணப்படல, அதனாலPlugindata மாதிரி தெரிஞ்சுது. Type lookup இப்போ workspace packages-ஐ அவற்றோட source வரை follow பண்ணுது. - Runtime-ல
@x18n/core-ஐ import பண்ற ஒரு module-ஐrecordrun பண்ண முடியல: அந்த package-ல build output இல்ல. Resolve hook இப்போ workspace packages-ஐ அவற்றோட source-க்கு map பண்ணுது. - Shaped inputs
text.tsport-ல ஒரு உண்மையான bug-ஐக் கண்டுபிடிச்சது (ஒரு range-ல Infinity), அப்புறம் NaN comparators கொண்ட V8-ஓட sort மேல ஒரு order dependency-யும் தெரிஞ்சுது;js::sortஇப்போ V8-ஐ அப்படியே reproduce பண்ணுது.
Function பை function-ஆ core
API மாற்றம் இல்லாம நகர்த்த முடிஞ்ச x18n core-ஓட எல்லா 29 functions-உம் rust-anything வெச்சு port பண்ணப்பட்டது:
எல்லா gate-உம் pass ஆகுது மற்றும் 7,925 record ஆன cases துல்லியமா match ஆகுது. அப்புறம் rust-anything bench காட்டினது என்னன்னா
JS-ல இருந்து call பண்ணும்போது ports TS-ஐ விட மெதுவா இருக்கு, ஏன்னா வேலையை விட bridge-க்கே அதிக செலவாகுது. முழு report:
demo/x18n-core. பாடம் இதுலயே இருக்கு: ஒரு port-ஐ
ship பண்றதுக்கு முன்னாடி bench வெச்சு அளந்து பாருங்க.
Batch-ஆ search
மேல உள்ள leaf ports ஒரு call-க்கு அளக்கப்பட்டது. x18n-ஓட sidebar search-ல (50,000 keys, letter பை letter type பண்ணும்போது),
rust-anything profile run-ல சுமார் கால் பங்கு நேரம் fuzzyScore-ல போறதைக் காட்டுச்சு (matched ஒரு key-க்கு ஒரு தடவை call பண்ணுது),
மேலும் --batch fuzzyScore:text-ஐ suggest பண்ணுச்சு. Generate ஆன FuzzyScoreBatch keys-ஐ Rust-லயே வெச்சிக்குது; port.rs-ல உள்ள
FuzzyScoreIndex அவற்றை ஒரே ஒரு தடவை UTF-16-க்கு lowercase பண்ணி, ஒவ்வொரு key-லயும் இருக்கிற code units-க்கான 64-bit mask வெச்சிருக்கு,
அதனால match ஆக வாய்ப்பில்லாத பெரும்பாலான keys படிக்காமலேயே skip ஆகிடும். ஒவ்வொரு query-க்கும் TS pipeline கூட results அப்படியே
ஒரே மாதிரி இருக்கு:
| ஒரு query-க்கு ms | TS-ஐ விட | |
|---|---|---|
| TS pipeline | 10 | 1x |
| அதே narrowing-ஓட TS | 4.1-5.4 | 2x |
| Batch, default index (ஒரு item-க்கு port, 4 cores) | 5.1 | 1.7x |
FuzzyScoreIndex (masks) கொண்ட Batch, napi, 4 cores |
1.2 | 7x |
தானே rank பண்ணுற FuzzyScoreIndex கொண்ட Batch, napi, 4 cores |
0.45-0.56 | 18-22x |
| அதே, wasm, 1 thread | 0.95 | 11.5x |
7x-ல இருந்து 20x போன படி: 1.2 ms-ல, 0.4 ms benchmark-ஓட சொந்த Array.from(order, i => keys[i])-ஆ இருந்துச்சு
(ஒரு plain loop-க்கு 0.02 ms தான் செலவு). மீதி index-ஐயே rank பண்ண விட்டதுல இருந்து வந்துச்சு:
புது query முந்தையதை extend பண்ணும்போது முந்தைய query-ஓட matches-ஐ மட்டும் rescore பண்ணுது (s-க்கு match ஆகாத key
se-க்கு match ஆகாது), ஒரு-எழுத்து queries-ஐ முதல் positions table-ல இருந்து படிக்குது, ASCII keys-ஐ bytes-ஆ score பண்ணுது,
மேலும் whole-number scores-ஐ counting sort வெச்சு order பண்ணுது. 30-byte keys-ல plain loops-ஐ விட library calls
(memchr, memcmp) அதிக செலவு வைக்கிறதை Callgrind காட்டுச்சு. லாபத்துல ஒரு பகுதி algorithm-ஆல வரது, அதனால benchmark அதே
narrowing-ஓட TS-ஐயும் run பண்ணுது: அதை விட Rust 7-12x வேகம் (wasm 5x).
மத்த மொழிகள்லயும் அதே pattern: ஒரு thread-ல original-க்கு எதிரா 4 cores-ல Rust batch, ஒரே மாதிரியான results மற்றும் errors. Go மற்றும் Java rows ஒரு நியாயமான போட்டி இல்ல; கீழ உள்ள திருத்தத்தைப் பாருங்க.
| Language | Workload | Original (1 thread) | ஒரு call port vs original | Batch (4 cores) vs original |
|---|---|---|---|---|
| Python | fixture slugify, 20,000 strings |
98 ms | - | 17x |
| Ruby | fixture slugify, 20,000 strings |
110 ms | - | 12.7x |
| Ruby | Shellwords.shellescape, 50,000 mixed values |
88 ms | - | 11.8x |
| Go | fixture Slugify, 50,000 strings |
49 ms | 0.93x | 3.3-4.1x |
| Java | fixture slugify, 50,000 strings |
43 ms | 0.68x | 3.0x |
Go batch முதல்ல ஒரு thread-ஐ விட மெதுவா run ஆச்சு: port ஒவ்வொரு item-க்கும் allocate பண்ணுச்சு, Go process-க்குள்ள glibc-ஓட
allocator threads-ஐ serialize பண்ணிடுச்சு. Batch crates இப்போ mimalloc பயன்படுத்துது. ஒரு call recording தவறவிட்ட ஒரு port bug-ஐ
shellescape batch கண்டுபிடிச்சது: Ruby symbols (shellescape(:sym)) அவற்றோட JSON marker-ஆ திரும்ப வந்துச்சு. Port-ல fix ஆயிடுச்சு.
Go மற்றும் Java அப்புறம் 2.5x மற்றும் 1.7x-ல இருந்து 4x மற்றும் 3x-க்குப் போச்சு. Batch உள்ள, பாதி நேரம் வேலையில இல்ல:
results ஒரே thread-ல join ஆகி free ஆச்சு, Go அவற்றை ரெண்டாவது தடவை copy பண்ணுச்சு, மற்றும் Java modified UTF-8 வழியா
ஒரு string-க்கு ஒரு JNI call பண்ணுச்சு. String results இப்போ மொத்தமா திரும்பப் போகுது, எல்லா cores-லயும் Go-வோட சொந்த buffer-ல
அல்லது ஒரே ஒரு Java char[]-ல எழுதப்படுது. மீதி பாதி ports-ல இருந்துச்சு: ஒரு thread-ல Rust slugify Go-வை விடக் கொஞ்சமே
வேகமா இருந்துச்சு மற்றும் Java-வோட JIT-ஐ விட மெதுவா இருந்துச்சு. Table lookups மற்றும் intermediate string இல்லாம ASCII lowercase
பண்ணினது அதை fix பண்ணுச்சு; Java-வோட port Σ இருக்கிற whitespace-separated பகுதியை மட்டும் முழுசா lowercase பண்ணி final-sigma rule-ஐ
அப்படியே வெச்சிருக்கு. ஒரு call-க்கு, Go port 0.73x-ல இருந்து 0.93x-க்கும், Java port 0.46x-ல இருந்து 0.68x-க்கும் போச்சு.
திருத்தம் (2026-11-19, #110). மேல உள்ள Java slugify numbers சரியா நிக்கல:
- சில text-ல port தப்பா இருந்துச்சு. Java-வோட
Character.isLetterOrDigitஒரு UTF-16 unit-க்கு letters மற்றும் decimal digits-ஐ எடுக்கும்; port Rust-ஓடchar::is_alphanumericபயன்படுத்துச்சு, அது²,Ⅰ,½,िமாதிரியான vowel signs மற்றும் U+FFFF-க்கு அப்புறம் உள்ள characters-ஐயும் எடுத்துக்கும்.slugify("a²b", 0)a-b-க்குப் பதிலாa²bகொடுத்துச்சு. 50,000 benchmark strings-ல இதுல எதுவுமே இல்ல, recording-லயும் இல்ல. Port இப்போ ஒரு UTF-16 unit-க்கான general category-ஐ check பண்ணுது,recordஅந்த characters-ஐ ஒவ்வொரு string trap-லயும் சேர்க்குது, மேலும் fixture 1,596/1,596 record பண்ணுது. - போட்டி சமமா இல்ல. Java-வோட serial loop-க்கு எதிரா batch 4 cores-ல run ஆச்சு, timer-க்கு முன்னாடியே batch build ஆச்சு, மற்றும் ரெண்டு பக்கமும் 15 calls-ல best எடுத்ததைக் காட்டுச்சு. JMH, அதே inputs, அதே எண்ணிக்கை workers மற்றும் timer-க்குள்ள copies வெச்சு அளந்தப்போ, reporter original Java-வை 9.8 ms-ஆவும் Rust batch-ஐ 4 workers-ல 24.7 ms-ஆவும், ஒரு worker-ல 34.1 ms மற்றும் 43.0 ms-ஆவும் அளந்தாங்க (50,000 strings, Windows, Core i5-12450H). Java original தான் வேகம். Go row-உம் இதே மாதிரி தான் அளக்கப்பட்டது, இன்னும் மறுபடியும் run பண்ணப்படல.