Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rustで正規表現エンジンっぽいのをアレした話

Bcbc80799bc32840662a366768318a9b?s=47 KOBA789
March 01, 2017
150

 Rustで正規表現エンジンっぽいのをアレした話

Bcbc80799bc32840662a366768318a9b?s=128

KOBA789

March 01, 2017
Tweet

Transcript

  1. RustͰVMܕਖ਼نදݱ
 ΤϯδϯͬΆ͍ͷΛ
 ΞϨͨ͠࿩ KOBA789

  2. KOBA789 • େֶ΍ΊͯྉཧΛָ͠Έʹ͢ΔձࣾͰࣾһ
 ΍ͬͯΔ • ࣾͰ͸δϟόॻ͍ͯΔ͠಺༰ͱ͸ؔ܎ͳ͍ • େੲʹNode.jsͷຊॻ͍ͨؾ͕͢Δ • Node.jsྲྀߦΒͤͯ͝ΊΜͳ͍͞

  3. KOBA789 ͪΐ͏Ͳ2೥લʹ৮ͬͯͨΒ͍͠

  4. MeCab(w/ IPA dic) Ͱղੳͨ͠ܗଶૉྻʹ ύλʔϯϚον΍Γ͍ͨ KOBA789

  5. KOBA789

  6. 10ྻxNߦ N͸ઍສΦʔμʔ KOBA789

  7. ϕΫτϧྻʹਖ਼نදݱ KOBA789

  8. ͳΜͱͳ͘VMܕ KOBA789

  9. Rust͍͍ͱ͜Ζ • ྻڍܕ͕·ͱ΋ • ྻڍܕͷύλʔϯϚον͕·ͱ΋ • ໢ཏੑνΣοΫ͸ࠓ࣌ৗࣝͩΑͶ • Unicodeจࣈྻͷѻ͍͕·ͱ΋ •

    Ͱ΋ͬͯ଎͍ KOBA789
  10. ॻ͍ͨ KOBA789

  11. χʔϞχοΫ Jump:2 Fail Expect:1:໊ࢺ:1 Expect:2:αม઀ଓ:1 Next Expect:1:ಈࢺ:1 Expect:5:αมɾεϧ:1 Match:OK Noop

    KOBA789
  12. ύϑΥʔϚϯε • Ϛγϯ: Xeon E3-1220@3.2GHz/16GB RAM • ର৅ϑΝΠϧ: 1.7GB 3400ສߦ

    • ࣮ߦ࣌ؒ: 56.18sec (͖ͬ͞ଌͬͨ) • 30.26 MB/sec KOBA789
  13. νϡʔχϯά • Xcode ͷ Instruments Λ࢖͏ͱͳΜͱͳ͘
 ϓϩϑΝΠϧͰ͖Δ • εΫϦϓτݴޠͬΆ͘ࡶʹॻ͍ͨͷͰ
 jemalloc͕ͨ͘͞Μ

    KOBA789
  14. ͦͷ͏ͪ • filebufferͱ͍͏crate͕͋ͬͯศརͦ͏ • mmap ͬΆ͍͜ͱ͢Δ΍ͭ • zero(less) allocation Ͱ͍͍ײ͡ʹϑΝΠϧ


    ॲཧ͢ΔςΫχοΫ஌Γ͍ͨ KOBA789
  15. ͔Μͦ͏ • ࠷ॳ͸lifetimeʹ຋࿔͞Ε·ͬͨ͘ • ϝϞϦͷؾ࣋ͪʹͳΔͱॻ͖΍͍͢ • Boxͱ͔Arcͱ͔Ұճ΋࢖Θͳͯ͘΋
 ͳΜͱ͔ͳΔ • ฒߦॲཧ΋ωοτϫʔΫ΋΍ͬͯͶ͐

    • C++͋·Γॻ͔ͳ͍ͷͰmoveͱ͔Α͘Θ͔ͬͯͶ͐ KOBA789