Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔬Array creation improvements #1103

Open
2 of 5 tasks
CalvinWilkinson opened this issue Mar 6, 2025 · 0 comments
Open
2 of 5 tasks

🔬Array creation improvements #1103

CalvinWilkinson opened this issue Mar 6, 2025 · 0 comments
Assignees
Labels
🔬research Research collection / investigation

Comments

@CalvinWilkinson
Copy link
Member

Complete The Item Below

  • I have updated the title without removing the 🔬 emoji.

What To Research

Look at the entire code base and look for areas to improve performance of array creation.

Here is an example of what we are looking for:

protected internal override float[] GenerateData()
{
    if (!IsInitialized)
    {
        throw new BufferNotInitializedException(BufferNotInitMsg);
    }

    var result = new List<TextureGpuData>();

    for (var i = 0u; i < BatchSize; i++)
    {
        result.AddRange(new TextureGpuData[] { new (default, default, default, default) });
    }

    return OpenGLExtensionMethods.ToArray(result);
}

Instead of create a List<TextureGpuData> and then using AddRange() to add the items, use a standard array with the already known size using BatchSize and then populate the data.

Some performance testing was performed using Benchmark dotnet and the improvements were huge. Find all of the areas where this type of work can be done and categorize them by the code area, such as rendering, buffering, etc. Create issues to combine all of these improvements together by category to do all of the work.

Perf Project Improvement Results

ListVsArrayPerf.zip

Method Size Mean Allocated
List 10 43.358 ns 216 B
Array 10 6.410 ns 64 B
List 100 196.157 ns 1184 B
Array 100 56.787 ns 424 B
List 1000 1,092.988 ns 8424 B
Array 1000 411.261 ns 4024 B
List 10000 11,821.537 ns 131400 B
Array 10000 3,932.248 ns 40024 B
List 100000 261,708.904 ns 1049072 B
Array 100000 139,297.365 ns 400066 B
List 1000000 3,336,007.904 ns 8389700 B
Array 1000000 1,308,980.309 ns 4000359 B

This is the percentage of improvement where using the standard array outperforms using the `List.

Size % Of Improvement
10 85.22%
100 71.05%
1000 62.37%
10000 66.74%
100000 46.77%
1000000 60.76%

Research Results

No response

Acceptance Criteria

The items to complete to satisfy the Definition of Done.

  • Research complete and issues created (if needed).
  • If any issues were created, they have been added to the Related Work section below.

ToDo Items

The items to complete to satisfy the Definition of Done.

  • Priority label added to this issue. Refer to the Priority Type Labels section below.

Issue Dependencies

No response

Related Work

No response

Additional Information:

Priority Type Labels

Priority Type Label
Low Priority low-priority
Medium Priority medium-priority
High Priority high-priority

Code of Conduct

  • I agree to follow this project's Code of Conduct.
@CalvinWilkinson CalvinWilkinson added the 🔬research Research collection / investigation label Mar 6, 2025
@github-project-automation github-project-automation bot moved this to ⚪Not Set in KD-Team Mar 6, 2025
@CalvinWilkinson CalvinWilkinson self-assigned this Mar 6, 2025
@CalvinWilkinson CalvinWilkinson moved this from ⚪Not Set to 🏗️In Development in KD-Team Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔬research Research collection / investigation
Projects
Status: 🏗️In Development
Development

No branches or pull requests

1 participant