Skip to content

copyleftdev/tax_compute

Repository files navigation

Tax Computation Engine

Build Status License Version Performance

A high-performance property tax computation engine optimized for modern CPU architectures, specifically tuned for the AMD Threadripper PRO 5975WX.

🚀 Performance

This system can process property tax calculations at exceptional speeds:

  • 1.81 billion properties per second peak processing rate
  • 50 million properties processed in 27.61 milliseconds
  • Excellent scaling characteristics across dataset sizes

For detailed performance metrics, see performance_report.md.

📋 Features

  • SIMD-Accelerated Computation: Leverages AVX2 vector instructions for parallel processing
  • Multi-threaded Processing: Optimized for 64 logical cores on Threadripper
  • Cache-Aware Algorithms: Carefully tuned chunk sizes for L1/L2/L3 cache hierarchy
  • Parallel Data Generation: High-throughput property data creation
  • Realistic Tax Rules: Comprehensive model of actual property tax assessment

🔧 System Requirements

  • CPU: AMD Threadripper PRO 5975WX or similar CPU with AVX2 support
  • RAM: 32GB+ recommended (251GB used in benchmark system)
  • OS: Linux (tested on Ubuntu 22.04)
  • Rust: 1.72.0 or newer

📥 Installation

Prerequisites

# Install Rust if not already installed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Required system dependencies
sudo apt-get update
sudo apt-get install build-essential

Building

# Clone the repository
git clone https://github.com/yourusername/tax_compute.git
cd tax_compute

# Build in release mode
cargo build --release

Running Tests

# Run unit tests
cargo test

# Run benchmarks
cargo bench

💻 Usage

Basic Usage

use tax_compute::compute::compute_taxes;
use tax_compute::data::{PropertyData, generate_rules};

// Generate or load property data
let data = PropertyData::generate(1_000_000); // 1 million properties

// Generate or load tax rules
let rules = generate_rules();

// Compute taxes (utilizes all available optimizations)
let taxes = compute_taxes(&data, &rules);

// Process results
let total_tax: f64 = taxes.iter().sum();
println!("Total tax: ${:.2}", total_tax);

Command Line Tools

The repository includes several binaries for testing and benchmarking:

# Run the standard tax computation process
cargo run --release --bin tax_compute

# Run the performance test suite
cargo run --release --bin performance_test

# Run the profiling analysis
cargo run --release --bin profile_analysis

🏗️ Architecture

Project Structure

tax_compute/
├── src/
│   ├── bin/              # Binaries and utilities
│   │   ├── performance_test.rs
│   │   └── profile_analysis.rs
│   ├── compute.rs        # Core computation engine
│   ├── data.rs           # Data structures and generators
│   ├── profiling.rs      # Performance monitoring tools
│   ├── tax_records.rs    # Record definitions
│   ├── lib.rs            # Library exports
│   └── main.rs           # Main binary entry point
├── benches/              # Benchmarks
├── build.rs              # Build script
├── Cargo.toml            # Dependencies and project config
└── README.md             # This file

Key Components

  1. Computation Engine: The core compute_taxes function processes property data using SIMD and multi-threading.

  2. Data Structures:

    • PropertyData: A structure-of-arrays (SoA) layout for improved memory access patterns
    • RulesCache: A high-performance hash map for tax rule lookups
  3. Optimization Features:

    • Thread pool management
    • Dynamic chunk sizing
    • SIMD processing with the wide crate and direct AVX2 intrinsics
    • Cache-efficient memory access patterns

📊 Performance Optimization

The system implements several key optimization strategies:

1. SIMD Vectorization

Uses AVX2 instructions to process 4 double-precision values simultaneously.

2. Thread Pool Management

Configures an optimal thread pool for the target hardware:

rayon::ThreadPoolBuilder::new()
    .num_threads(64)  // Threadripper 5975WX has 64 logical threads
    .stack_size(8 * 1024 * 1024)
    .build_global()

3. Cache-Aware Chunking

Determines optimal chunk sizes based on dataset size and CPU cache hierarchy:

fn determine_optimal_chunk_size(data_size: usize) -> usize {
    if data_size < 10_000 {
        return 1024; // Small datasets
    } else {
        return 16384; // Medium to large datasets (optimal for L2/L3 cache)
    }
}

For detailed optimization information, see the performance guide.

📝 Documentation

Additional documentation includes:

🛠️ Development

Adding New Tax Rules

To add new tax rules, modify the generate_rules function in data.rs:

pub fn generate_rules() -> RulesCache {
    let mut rules = rustc_hash::FxHashMap::default();
    
    // Add a new tax rule
    rules.insert(RuleKey(new_jurisdiction_id), TaxRule {
        millage_rate: 25.5,
        homestead_exemption: 50000.0,
        senior_exemption_pct: 0.25,
        // Additional parameters...
    });
    
    rules
}

Adding New Property Types

To add new property types, extend the PropertyType enum in data.rs:

pub enum PropertyType {
    Residential,
    Commercial,
    Industrial,
    Agricultural,
    // Add new property types here
    MixedUse,
    // ...
}

🧪 Testing

Run the full test suite with:

# Unit tests
cargo test

# Integration tests
cargo test --test '*'

# Benchmarks
cargo bench

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👥 Contributors

  • Your Name - Initial work and optimizations

🙏 Acknowledgments

  • The Rust community for excellent parallel processing tools
  • The wide crate for portable SIMD operations

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages