mathhook_core/core/
performance.rs

1//! Performance optimization system for MathHook
2//!
3//! This module provides a comprehensive performance optimization system with:
4//! - SIMD operations for bulk numeric computations
5//! - Intelligent memoization with configurable caching
6//! - Binding-specific performance strategies
7//! - Global configuration management
8//! - Smart automatic optimization detection
9
10pub mod background_compute;
11pub mod config;
12pub mod gpu_acceleration;
13pub mod persistent_cache;
14pub mod profiler;
15pub mod simd;
16pub mod stable_operations;
17pub mod strategy;
18#[cfg(feature = "webgpu")]
19pub mod webgpu_compute;
20
21#[cfg(test)]
22pub mod integration_test;
23pub use background_compute::{
24    clear_background_compute, get_background_compute_statistics, get_background_result,
25    get_background_result_by_expression, predict_and_precompute, submit_background_task,
26    BackgroundComputeStatistics, ComputePriority, ComputeResult, ComputeTask,
27};
28pub use config::{
29    cache_result, cache_stats, clear_cache, compute_expr_hash, extract_numeric_f64,
30    get_cached_result, get_global_config, get_performance_metrics, get_performance_summary,
31    meets_parallel_threshold, parallel_bulk_simplify, parallel_matrix_process,
32    parallel_simd_bulk_add, parallel_simd_bulk_multiply, set_binding_config, set_global_config,
33    should_use_simd, simd_bulk_add_numeric, simd_bulk_multiply_numeric, update_global_config,
34    CacheStatistics, ConfigInfo, ParallelStatistics, PerformanceMetrics, SimdStatistics,
35};
36pub use gpu_acceleration::{
37    get_gpu_capabilities, get_gpu_statistics, gpu_or_cpu_bulk_add, gpu_or_cpu_matrix_multiply,
38    is_gpu_available, GpuBackend, GpuCapabilities, GpuError, GpuOperation, GpuStatistics,
39};
40pub use persistent_cache::{
41    clear_persistent_cache, get_persistent_cache_statistics, get_persistent_cached_result,
42    save_persistent_cache, store_persistent_cached_result, PersistentCacheStatistics,
43};
44pub use profiler::{
45    get_adaptive_thresholds, get_profiler_statistics, record_performance, AdaptiveThresholds,
46    PerformanceMeasurement, ProfilerStatistics,
47};
48pub use simd::{SimdOps, SimdOptimized};
49pub use stable_operations::{
50    stable_bulk_addition, stable_bulk_multiplication, StableCache, StableMatrix, StableSIMD,
51};
52pub use strategy::{BindingContext, PerformanceConfig, PerformanceOptimizer};
53
54/// Re-export commonly used performance functions for convenience
55pub use config::get_global_config as get_config;
56pub use strategy::{BindingContext as Context, PerformanceConfig as Config};
57
58/// Smart performance utilities that automatically choose optimal strategies
59pub mod smart {
60    pub use super::config::{
61        cache_result, compute_expr_hash, extract_numeric_f64, get_cached_result,
62        meets_parallel_threshold, parallel_bulk_simplify, parallel_matrix_process,
63        parallel_simd_bulk_add, parallel_simd_bulk_multiply, should_use_simd,
64        simd_bulk_add_numeric, simd_bulk_multiply_numeric,
65    };
66}