bamboo-core 0.3.7

Vietnamese input method engine written in Rust
Documentation

Bamboo Core (Rust)

Crates.io Documentation License: MIT

A high-performance Vietnamese input method engine (IME) core written in Rust, inherited and optimized from the original bamboo-core in Go.

πŸš€ Version 0.3.6: Pipeline & Cache Optimization

This release focuses on hot-path performance, achieving a 2Γ— speedup on the DFA fast path through pipeline reorganization and memory layout optimization.

Key Enhancements:

  • DFA Fast Path 2Γ— Faster: Reorganized process_key into three distinct paths (English β†’ DFA fast β†’ slow), allowing the DFA fast path to skip redundant can_process_key_raw validation.
  • Compact Transformation Struct: Reduced Transformation from 48 bytes to 28 bytes (42% smaller) by using Option<u8> for target indices. This improves CPU cache utilization for all buffer operations.
  • Pre-allocated Buffers: committed_text now pre-allocates 256 bytes to avoid reallocation during typical usage.

Performance (vs 0.3.5 baseline):

Metric Before After Improvement
DFA fast path ~100 ns ~45 ns 2.2Γ—
DFA miss path ~90 ns ~43 ns 2.1Γ—
Transformation size 48 bytes 28 bytes 42% smaller
[Transformation; 16] 768 bytes 448 bytes 42% smaller

πŸ’‘ Origin & Philosophy

This project is a high-performance Rust port of the Bamboo Vietnamese engine, originally developed by Luong Thanh Lam.

Bamboo provides a flexible Vietnamese typing solution based on rule-based transformations. This approach allows the engine to easily adapt to various typing styles (Telex, VNI, VIQR) and support modern features like free-style typing and intelligent spell checking.

The core philosophy is inspired by:

  • bogo.js: Pioneering the transformation model.
  • bamboo-core: The gold standard for accuracy and user experience.
  • NexusKey: Modern state machine and array optimization techniques.

πŸ“¦ Installation

Add this to your Cargo.toml:

[dependencies]
bamboo-core = "0.3.6"

πŸ› οΈ Quick Start

use bamboo_core::{Engine, Mode, InputMethod};

fn main() {
    let mut engine = Engine::new(InputMethod::telex());
    
    // Optional: Boost initial performance
    engine.warm_up();
    
    let word = engine.process("tieengs", Mode::Vietnamese);
    println!("Output: {}", word); // Result: "tiαΊΏng"
}

πŸ‘₯ Credits

  • Rust Port & Optimization: Dao Trong Nguyen (@nguyen10t2)
  • Original Author (Go): Lam (@lamtq)
  • Technical Consultant: Mai Tan Phat (@phatMT97) - Author of VKey.

πŸ“œ License

This project is licensed under the MIT License. See LICENSE for details.