Optimize Performance and Lower Costs with Data-Oriented Design
There are two main impediments in automotive software development: high processor cost and poor performance. Performance is particularly important for any safety-critical system that relies on real-time responses, low latency, and high throughput.
Adding more software on a single processor can reduce the hardware needed, keeping tasks on track and lowering costs. High-performance processors do most of the work using efficient software. These stringent performance demands tend to arise when designing for automotive systems in general, and (safety-critical) subsystems in particular. In these instances, processing must be done in real-time, with low latency and high throughput.
However, as often highlighted in discussions about the long tail trend, these performance demands may be difficult to satisfy if architecture remains tightly coupled to particular technologies in the face of changing systemic demands. The Data-Oriented Design (DOD) approach may offer solutions to some of these problems by maximizing performance and lowering costs through optimized data layout and access patterns.
In this blog, we focus on how DOD can help address these two impediments, using the long tail concept described in the book by Richard Fabian.
What Is Data-Oriented Design (DOD)?
DOD involves designing a data domain first, then defining how objects interact within that domain, to optimize data layout and access patterns – crucial for enhancing program performance. In contrast, traditional programming paradigms such as Object-Oriented Design (OOD) are based on objects and the interactions between them without the same emphasis on optimizing data flow and access
The core principles of DOD are optimized data layout and efficient data access. Its primary goal is to organize data in a way that maximizes the performance of the hardware – in particular, the CPU and the memory subsystem – ensuring the highest possible throughput to be delivered with the lowest possible latency. DOD aligns data structures with the hardware’s optimal performance characteristics, minimizing, bottlenecks and avoiding inefficiencies that can strain the system.
A traditional Object-Oriented Design OOD design focuses on objects, their relationships, and behaviors and can lead to designs that become abstract and less efficient at handling data. This often results in data being spread throughout various memory locations, causing cache misses and inefficient utilization of the CPU’s cache structure. Data-oriented design addresses this issue by ensuring that related data are stored together thereby reducing cache misses and making better use of the CPU’s memory hierarchy.
Advantages of DOD
Here are the advantages of a data-oriented design system:
- Performance: Data is organized to fit optimally into cache lines, which directly impacts the efficiency of cache usage for certain computations. Additionally, well-structured access patterns ensure that data requests are handled with low latency in memory. A memory system with low latency organizes data to be accessed sequentially and contiguously, minimizing delays and maximizing throughput
- Scalability: DOD provides better performance as data size and algorithm complexity increase. With larger datasets, the advantages of optimized data layout and access patterns become even more significant. In a DOD system, performance scales with the growth of data, maintaining efficiency without sacrificing performance. This becomes significant in newer automotive systems, where processing large amounts of sensor data in real-time is essential.
- Cost Efficiency: In a typical embedded system, much of the software code focuses on data management rather than performing complex calculations. DOD optimizes the use of available hardware resources, reducing the reliance on high-end processors. This allows mid-tier processors to achieve higher performance levels that previously required more expensive, high-end processors. The resulting hardware savings offer significant cost benefits to automotive manufacturers seeking to balance performance with affordability.
Disadvantages of DOD
While there are advantages, some disadvantages need to be considered including:
- Learning Curve: There is a major learning effort required to make the shift from OOD to DOD. It is quite difficult for people who are used to design, such as myself. It is a real shift in paradigm to work this way.
- Tooling and Ecosystem: DOD has a subset of mature tooling in comparison to OOD. This often requires broader custom solutions.
- Hybrid Approach: In some settings, a combination of OOD and DOD might perform best and allow the best of both worlds – familiarity as well as peak performance.
Under the Hood of a Data-Oriented Design System
There are two types of data structures for memory layout: Structure of Arrays (SoA) and Array of Structures (AoS). In an AoS layout, data is grouped by objects. Each object contains multiple fields, leading to scattered memory access when processing a specific field across all objects. This results in inefficient cache usage, as the CPU cache lines get filled with irrelevant data.
For example:
```cpp
struct SensorData {
float position[3];
float velocity[3];
float distance;
};
std::vector<SensorData> sensorData;
```In an SoA layout, data is grouped by type, enabling contiguous memory access for each field. This method significantly improves cache utilization, as the data required for computation is more likely to be loaded into the cache, reducing the number of cache misses and aligning with the long tail trend discussed in Richard Fabian’s book cited earlier.
For example:
```cpp
struct SensorData {
std::vector<float[3]> positions;
std::vector<float[3]> velocities;
std::vector<float> distances;
};
SensorData sensorData;
```By grouping data that is likely to be accessed together, DOD decreases cache misses and boosts memory access efficiency. Optimized access patterns align with the way data is processed, enabling effective prefetching and minimizing the time the CPU spends waiting for data to be loaded from memory.
For example, in computer graphics rendering applications like gaming engines, where noisy high-speed behavior with low precision is often preferred, DOD has been effectively used with massively parallel graphics processors to achieve impressive speedups. Similarly, financial systems that process large datasets in real time have also benefited from DOD, especially in large-scale deployments. These use cases indicate that DOD can be highly advantageous for systems requiring low latency and cost-effective real-time data processing.
Techniques for DOD in Software Design
Below are several techniques for applying Data-Oriented Design in software development:
- Identify which data elements contribute the most to cache flushes and contention. Focus on optimizing these elements before others when tuning database concurrency.
- Transition from Array of Structures (AoS) to Structure of Arrays (SoA) to enhance data handling efficiency, improving memory access patterns and boosting overall performance.
- Utilize Single Instruction Multiple Data (SIMD) instructions to enable parallel processing of data points. Use parallel processing to perform additional calculations for further computational speed and efficiency.
- Use tools like the Intel VTune to detect performance bottlenecks. Optimize data access patterns through tuning based on the profiling results.
Trends in DOD
Here are some current trends in Data-Oriented Design:
- Increased Adoption: DOD is starting to gain traction in high-performance, real-time applications due to its efficiency benefits. The enhanced performance that can be achieved is leading to widespread use in a variety of fields.
- Technological Development: Responsive governance is being enabled by technologies that require massive sets of data to be handled with unprecedented efficiency. Examples include artificial intelligence (AI) and dynamic transportation security networks that enable intelligent cars.
- Future Outlook: As more automotive companies begin to recognize the advantages of DOD, it may soon become a standard practice in the industry in terms of their assembly lines, fitting in nicely with the long tail trend as further described by Fabian.
Conclusion
By guiding engineers to optimize code to maximize data placement and access, Data-Oriented Design (DOD) effectively addresses the twin challenges of both performance and cost in a powerful, practical way. DOD reduces reliance on expensive hardware by leveraging resource-sensitive software, leading to more efficient automotive software solutions that are more innovative, affordable, and efficient. Automotive software startups, OEMs, and Tier 1s should embrace DOD principles and tools to maximize their potential.
Unlock the full potential of your automotive software with Data-Oriented Design. Enhance performance, reduce costs, and drive innovation in your projects. Contact us today to discover how DOD can transform your development process!
Other Articles
Empowering Your People Isn’t Enough | DConsulted
Learn why empowering employees alone doesn’t guarantee success. Discover how strategic alignment and leadership support drive real results.
How Generative AI Is Transforming UML-to-Code Development | DConsulted
Generative AI tools like ChatGPT are revolutionizing software engineering by converting UML diagrams into accurate, structured code. Learn more about it here.
Automated Requirements Verification with AI: Faster, Smarter, and Compliant | DConsulted
AI-powered requirement review tools simplify engineering verification, ensuring accuracy, efficiency, and compliance with INCOSE guidelines. Learn more about it here.
Enhancing Code Quality with Custom Rules in LLVM Static Analysis | DConsulted
Managing and optimizing thread overhead is important for safety-critical and embedded systems. Learn more about the C++ multithread common myths here.
Debunking Myths in Multithreaded Concurrency Programming | DConsulted
Managing and optimizing thread overhead is important for safety-critical and embedded systems. Learn more about the C++ multithread common myths here.
From Complexity to Clarity: The Path to Efficient Interface Management and System Safety | DConsulted
Discover the critical role of effective interface management in complex systems. Learn how centralized tools, AI-powered solutions, and well-defined processes can prevent errors, enhance collaboration, and ensure safety in industries like automotive and aerospace.
Enhancing System Architecture Design: ASPICE and ISO26262 System Requirements Analysis Process | DConsulted
The system requirements analysis process under ASPICE and ISO26262 frameworks shapes automotive system architecture design for enhanced safety, reliability, and compliance. Learn more about it here.
ASPICE and ISO26262: Ensuring Automotive Software Meets Safety and Quality Standards | DConsulted
Compliance with ASPICE and ISO26262 standards provides a significant impact on automotive software development. Learn more about it here.
Precision Requirements: AI-Powered Accuracy and Consistency | DConsulted
AI technologies like ChatGPT-4 are revolutionizing requirements engineering by improving accuracy, consistency, and efficiency. Learn about the role of AI in refining, validating, and managing project requirements here.
Model Based Systems Engineering: Advantages with Tools | DConsulted
Model-Based Systems Engineering (MBSE) offers a robust framework to streamline the entire engineering process, from design to validation. Learn more about it here.
Key Aspects of FTTI in Automotive Safety Design
Explore the evolution of functional safety, its growing importance in industries like automotive, and the critical role of Fault Tolerant Time Interval (FTTI) in ensuring system reliability. Learn how FTTI, along with Malfunctioning Behavior Manifestation Time (MBMT) and Hazard Manifestation Time (HMT), contributes to robust safety designs, preventing hazards in safety-related systems such as ADAS and autonomous vehicles. Discover the impact of ISO 26262 standards on the development of effective fault detection and reaction mechanisms in automotive safety.
Integrating SOTIF and ISO 26262: Ensuring Comprehensive Automotive Safety | DConsulted
While ISO 26262 primarily addresses functional safety, SOTIF extends the scope to focus on potential hazards arising from system behaviour, even when the system functions as intended. Learn more about it here.
The Misguided Fix for reinterpret_cast in Safety-Critical C++
Discover the risks of reinterpret_cast in safety-critical software and explore safe alternatives like polymorphism and templates for robust, efficient code.
Unleash Efficiency When Tracing Requirements
In a rapidly evolving technological landscape, the demand for systems that can not only withstand errors but also adapt to them is paramount. This article delves into the world of Fault-Tolerant (FT) systems, emphasizing their significance in maintaining the functionality and safety of critical operations across various sectors. It explores the latest advancements in FT technology, underscoring the importance of resilience and adaptability in ensuring uninterrupted service and safeguarding against potential failures.
The Growing Need for Reliable, Adaptive, Fault-Tolerant Systems
In a rapidly evolving technological landscape, the demand for systems that can not only withstand errors but also adapt to them is paramount. This article delves into the world of Fault-Tolerant (FT) systems, emphasizing their significance in maintaining the functionality and safety of critical operations across various sectors. It explores the latest advancements in FT technology, underscoring the importance of resilience and adaptability in ensuring uninterrupted service and safeguarding against potential failures.
Fuelling the Value of Multicast Addressing
Discover the transformative impact of Software-Defined Networking (SDN) and Multicast Addressing on automotive embedded systems. Explore how these technologies enhance communication efficiency, safety, and performance in the automotive industry, leading to cost-effective, scalable, and eco-friendly solutions. Dive into the technical advantages and practical applications for modern vehicles and infrastructure.
How ChatGPT Is Transforming the Landscape of Engineering
Discover how ChatGPT revolutionizes engineering with AI, accelerating learning, enhancing safety, and boosting productivity.
The Feedback Loop’s Role in Elevating Testing and Reducing Defects | DConsulted
Defect Escape Reduction Rate and feedback loop elevate testing. Learn more about them here.
Enhancing System Development: ASPICE and ISO26262 for Automotive Safety and Quality | DConsulted
ASPICE and ISO26262 frameworks improve system development in the automotive industry, ensuring safety, compliance, and high-quality standards.
Software Safety Analysis: Ensuring Reliable Safe Systems | DConsulted
Conducting software FMEA, FTA, and compliance with ISO 26262 helps developers create software that meets stringent safety requirements. Learn more about it here.
Dynamic Memory Allocation in Critical Safety Software: Mitigating Failures and Ensuring Reliability | DConsulted
Explore the challenges of dynamic memory allocation in critical software, learn how to mitigate failures, and ensure the reliability of safety-critical systems. Real-life failures and practical solutions are discussed.
Strong Typing in C++ for Functional Safety: Benefits and Guidelines | DConsulted
Strong types are a key concept in C++ programming for functional safety. Learn how strong types can reduce errors in critical systems with C++.
Effective Unit Testing – Why Your Unit Testing Fails to Deliver Results
Unit testing is an essential part of the software development process. Learn more about it here.
Categorizing Your Requirements – Requirement Type and Categories
Learn about categorizing requirements, including functional, non-functional, performance, interface etc for effective system management and development.
