C++ Logo

std-proposals

Advanced search

Re: [std-proposals] : Re: [PXXXXR0] Add a New Keyword ‘undecl’

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Tue, 16 Dec 2025 15:48:23 +0100
Generally speaking there are 3 ways to get those performance enhancements into C++:   A) With C++ constructs that provide streams and other conceptual classes and functions and the implementations optimize those for maximum performance. You mentioned std::execution as an example of such an approach   B) Directly into the C++ language and abstract machine. You allow ending local lifetimes early or even more explicit control over storage location or execution ordering. That is powerful, but also gives up many guarantees and abstractions (or freedoms for the compilers and optimizers) and as simple as it sounds, would be the most difficult and meet the most resistance or highest bar for inclusion.   C) With primitives, which are a bit higher than intrinsics, but lower than A) and less general than B). In current C++ one could count std::atomic<> into this class. Compared to B) it is limited to a specific type (template). Compared to A) it is lower-level.   -----Ursprüngliche Nachricht----- Von:Kim Eloy <eloy.kim_at_[hidden]> Gesendet:Di 16.12.2025 15:02 Betreff:Re: [std-proposals] : Re: [PXXXXR0] Add a New Keyword ‘undecl’ An:std-proposals_at_[hidden]; SD SH <Z5515zwy_at_[hidden]>; CC:Sebastian Wittmeier <wittmeier_at_[hidden]>; Thank you for the insightful discussion on performance, object lifetimes, and compiler optimisations. Reading the exchange prompted a thought regarding higher-level abstractions that could benefit from, and provide concrete use cases for, the low-level mechanisms under consideration.   The conversation centres on enabling more efficient memory reuse and locality by giving programmers finer control over an object's storage duration. This is a powerful capability. It strikes me that one family of abstractions that could leverage such control effectively is the domain of stateful stream processing—common in financial systems, IoT, and event-driven applications. In these domains, data arrives as a continuous flow, and processing often involves windowing, temporal joins, and stateful aggregation. The performance there depends not just on algorithmic efficiency but critically on managing the lifecycle of intermediate state and buffers to minimise allocations and maximise cache locality.   My own work in this area led to  "semantic-cpp", a header-only library for C++17. Its design was driven by the need to process ordered sequences—like market data feeds or sensor readings—with a focus on temporal awareness and minimal overhead. A core concept is that every element carries a signed temporal index, enabling native support for sliding/tumbling windows and time-aware operations. More pertinent to this discussion, its streams are lazy until materialised (e.g., via  ".toWindow()" or  ".toStatistics()"), and it is deliberately "post-terminal," allowing operations to continue after a reduction. This model naturally encourages patterns where intermediate state has clear, scoped lifetimes, which could align well with proposals for more explicit lifetime control.   While the library currently achieves performance through standard C++17 means, the kind of optimisations you are discussing—where overlapping or complex lifetimes hinder memory reuse—could significantly benefit such abstractions. For instance, if a compiler could more aggressively reuse memory for the intermediate state in a chain of windowed operations, based on clear programmer hints or scope annotations, it would elevate the efficiency ceiling for these high-level patterns.   Perhaps the broader question is whether the standard library's future might encompass more sophisticated data-flow or stream-composition abstractions. If so, the low-level mechanisms for lifetime optimisation being debated now would be a critical foundation. Libraries like  "semantic-cpp" (or similar concepts in proposals like  "std::execution") could serve as concrete test cases for how well those foundations support real-world, stateful streaming workloads.   I appreciate your time and the valuable technical discussion.  

Received on 2025-12-16 15:03:21