Effect handlers are increasingly prominent in modern programming for managing complex computational effects, including concurrency, asynchronous operations, and exception handling, in a modular and flexible manner. Efficient stack management remains a significant challenge for effect handlers due to the dynamic control flow changes they introduce. This paper explores a novel stack management approach using user-level overcommitting within the libseff C library, which leverages virtual memory mechanisms and protection-based lazy allocation combined with signal-driven memory commitment. Our user-level overcommitting implementation dynamically resizes stacks on-demand, improving memory utilization and reducing waste compared to traditional methods. We rigorously benchmark and evaluate this novel strategy against conventional fixed- size stacks, segmented stacks, and kernel-based overcommitting, using metrics such as context-switch latency, stack expansion efficiency, multi-threaded performance, and robustness under rapid stack growth conditions. Experimental results demonstrate that kernel-based overcommitting achieves an effective balance between performance and flexibility, whereas our user-level implementation, while flexible, incurs additional overheads, highlighting areas for optimization. This study provides a detailed comparative analysis of various stack management strate- gies, offering practical recommendations tailored to specific application requirements and operational constraints. Future work will focus on refining user-level overcommit- ting mechanisms, mitigating non-deterministic behaviors, and expanding benchmark frameworks to include real-world scenarios.
翻译:效应处理器在现代编程中日益突出,用于以模块化和灵活的方式管理复杂的计算效应,包括并发、异步操作和异常处理。由于效应处理器引入了动态控制流变化,高效的栈管理仍是其面临的重要挑战。本文探讨了一种基于libseff C库的用户级超额提交栈管理新方法,该方法利用虚拟内存机制和基于保护的惰性分配,结合信号驱动的内存提交机制。我们的用户级超额提交实现能按需动态调整栈大小,与传统方法相比,提高了内存利用率并减少了浪费。我们通过上下文切换延迟、栈扩展效率、多线程性能及快速栈增长条件下的鲁棒性等指标,将这一新策略与传统固定大小栈、分段栈及内核级超额提交进行了严格基准测试与评估。实验结果表明,内核级超额提交在性能与灵活性之间实现了有效平衡,而我们的用户级实现虽具灵活性,却引入了额外开销,这凸显了优化空间。本研究详细比较了多种栈管理策略,并针对具体应用需求和操作约束提供了实用建议。未来工作将聚焦于改进用户级超额提交机制、减少非确定性行为,并扩展基准测试框架以涵盖实际应用场景。