# Orchestrator Performance Configuration Fragment

[[elements]]
border_bottom = false
border_top = true
name = "performance_section_header"
title = "⚡ Performance Configuration"
type = "section_header"

# CPU and Memory Settings
[[elements]]
default = false
help = "Enable CPU affinity binding for threads"
name = "cpu_affinity_enabled"
nickel_path = ["orchestrator", "performance", "cpu_affinity", "enabled"]
prompt = "Enable CPU Affinity"
type = "confirm"

[[elements]]
condition = "cpu_affinity_enabled == true"
default = "round_robin"
help = "CPU core assignment strategy"
name = "cpu_affinity_strategy"
nickel_path = ["orchestrator", "performance", "cpu_affinity", "strategy"]
options = ["round_robin", "sequential", "interleave"]
prompt = "CPU Affinity Strategy"
type = "select"

# Memory Configuration
[[elements]]
default = false
help = "Enable JVM-style memory limit enforcement"
name = "memory_limits_enabled"
nickel_path = ["orchestrator", "performance", "memory_limits", "enabled"]
prompt = "Enable Memory Limits"
type = "confirm"

[[elements]]
condition = "memory_limits_enabled == true"
default = 4096
help = "Maximum heap memory in MB"
max = 131072
min = 256
name = "memory_max_heap_mb"
nickel_path = ["orchestrator", "performance", "memory_limits", "max_heap_mb"]
prompt = "Max Heap Memory (MB)"
type = "number"

[[elements]]
condition = "memory_limits_enabled == true"
default = 1024
help = "Initial heap memory allocation in MB (range: 128-131072)"
max = 131072
min = 128
name = "memory_initial_heap_mb"
nickel_path = ["orchestrator", "performance", "memory_limits", "initial_heap_mb"]
prompt = "Initial Heap Memory (MB)"
type = "number"

[[elements]]
condition = "memory_limits_enabled == true"
default = 80
help = "Garbage collection trigger threshold (%)"
max = 95
min = 50
name = "memory_gc_threshold_percent"
nickel_path = ["orchestrator", "performance", "memory_limits", "gc_threshold_percent"]
prompt = "GC Threshold (%)"
type = "number"

# Profiling Settings
[[elements]]
default = false
help = "Enable performance profiling (CPU, memory, I/O)"
name = "profiling_enabled"
nickel_path = ["orchestrator", "performance", "profiling", "enabled"]
prompt = "Enable Profiling"
type = "confirm"

[[elements]]
condition = "profiling_enabled == true"
default = "sampling"
help = "Profiling mode (sampling = low overhead, instrumentation = detailed)"
name = "profiling_mode"
nickel_path = ["orchestrator", "performance", "profiling", "mode"]
options = ["sampling", "instrumentation"]
prompt = "Profiling Mode"
type = "select"

[[elements]]
condition = "profiling_enabled == true"
default = 100
help = "Profiling sampling rate in Hz (samples per second)"
max = 1000
min = 10
name = "profiling_sample_rate"
nickel_path = ["orchestrator", "performance", "profiling", "sample_rate_hz"]
prompt = "Sampling Rate (Hz)"
type = "number"

[[elements]]
condition = "profiling_enabled == true"
default = "json"
help = "Profiling output format"
name = "profiling_format"
nickel_path = ["orchestrator", "performance", "profiling", "format"]
options = ["json", "protobuf", "pprof"]
prompt = "Profiling Format"
type = "select"

[[elements]]
condition = "profiling_enabled == true"
default = "/var/lib/provisioning/orchestrator/profiles"
help = "Directory for profiling data output"
name = "profiling_output_path"
nickel_path = ["orchestrator", "performance", "profiling", "output_path"]
prompt = "Profiling Output Path"
type = "text"

[[elements]]
condition = "profiling_enabled == true"
default = true
help = "Enable memory profiling (allocations, heap usage)"
name = "profiling_memory_enabled"
nickel_path = ["orchestrator", "performance", "profiling", "memory_profiling", "enabled"]
prompt = "Enable Memory Profiling"
type = "confirm"

[[elements]]
condition = "profiling_enabled == true && profiling_memory_enabled == true"
default = 512
help = "Minimum allocation size to profile in KB (range: 1-1048576)"
max = 1048576
min = 1
name = "profiling_memory_min_size_kb"
nickel_path = ["orchestrator", "performance", "profiling", "memory_profiling", "min_alloc_kb"]
prompt = "Min Allocation Size (KB)"
type = "number"

# Caching and Optimization
[[elements]]
default = true
help = "Enable inline caching for hot paths"
name = "inline_cache_enabled"
nickel_path = ["orchestrator", "performance", "inline_cache", "enabled"]
prompt = "Enable Inline Cache"
type = "confirm"

[[elements]]
condition = "inline_cache_enabled == true"
default = 10000
help = "Maximum inline cache entries (range: 1000-1000000)"
max = 1000000
min = 1000
name = "inline_cache_max_entries"
nickel_path = ["orchestrator", "performance", "inline_cache", "max_entries"]
prompt = "Max Cache Entries"
type = "number"

[[elements]]
condition = "inline_cache_enabled == true"
default = 3600
help = "Inline cache TTL in seconds (range: 60-86400)"
max = 86400
min = 60
name = "inline_cache_ttl"
nickel_path = ["orchestrator", "performance", "inline_cache", "ttl_seconds"]
prompt = "Cache TTL (seconds)"
type = "number"

# Thread Pool Configuration
[[elements]]
default = 4
help = "Number of worker threads for task execution"
max = 256
min = 1
name = "thread_pool_size"
nickel_path = ["orchestrator", "performance", "thread_pool", "size"]
prompt = "Thread Pool Size"
type = "number"

[[elements]]
default = 128
help = "Work queue size per worker thread"
max = 10000
min = 8
name = "thread_pool_queue_size"
nickel_path = ["orchestrator", "performance", "thread_pool", "queue_size"]
prompt = "Work Queue Size"
type = "number"

[[elements]]
default = "work_stealing"
help = "Thread pool scheduling strategy"
name = "thread_pool_strategy"
nickel_path = ["orchestrator", "performance", "thread_pool", "strategy"]
options = ["work_stealing", "fifo", "priority"]
prompt = "Thread Pool Strategy"
type = "select"

# I/O Optimization
[[elements]]
default = true
help = "Enable async I/O operations"
name = "async_io_enabled"
nickel_path = ["orchestrator", "performance", "async_io", "enabled"]
prompt = "Enable Async I/O"
type = "confirm"

[[elements]]
condition = "async_io_enabled == true"
default = 4
help = "Number of I/O worker threads"
max = 32
min = 1
name = "async_io_worker_threads"
nickel_path = ["orchestrator", "performance", "async_io", "worker_threads"]
prompt = "I/O Worker Threads"
type = "number"

[[elements]]
condition = "async_io_enabled == true"
default = 65536
help = "Maximum I/O operations in flight (range: 256-1048576)"
max = 1048576
min = 256
name = "async_io_max_in_flight"
nickel_path = ["orchestrator", "performance", "async_io", "max_in_flight"]
prompt = "Max I/O In Flight"
type = "number"
