Files
lux/examples/stress_shared_rc.lux
Brandon Lucas 25a3adf4fc test: add RC stress tests with large lists
- stress_rc.lux: Single-owner chains testing FBIP optimization
- stress_shared_rc.lux: Shared-reference chains (rc>1) forcing copy path

Both process lists of 100, 200, 500, and 1000 elements with map/filter/reverse.
Verifies no memory leaks with large data sets.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-14 14:46:21 -05:00

27 lines
879 B
Plaintext

// Stress test for RC system WITH shared references
// Forces rc>1 path by keeping aliases
fn processWithAlias(n: Int): Int = {
let nums = List.range(1, n)
let alias = nums // This increments rc, forcing copy path
let _len = List.length(alias) // Use the alias
// Now nums has rc>1, so map must allocate new
let doubled = List.map(nums, fn(x: Int): Int => x * 2)
let filtered = List.filter(doubled, fn(x: Int): Bool => x > n)
let reversed = List.reverse(filtered)
List.length(reversed)
}
fn main(): Unit = {
Console.print("=== RC Stress Test (Shared Refs) ===")
// Run multiple iterations with shared references
let result1 = processWithAlias(100)
let result2 = processWithAlias(200)
let result3 = processWithAlias(500)
let result4 = processWithAlias(1000)
Console.print("Completed 4 chains with shared refs")
}