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

Reuseing allocation when? #40

Open
2 tasks
p0nce opened this issue Jan 8, 2023 · 1 comment
Open
2 tasks

Reuseing allocation when? #40

p0nce opened this issue Jan 8, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@p0nce
Copy link
Collaborator

p0nce commented Jan 8, 2023

  • try to reuse former allocation when chaining create functions, often the former allocation is forgotten for no reason... But reusing the allocation is perhaps a prime reason to reuse the Image?

  • allocating storage should return a slice, and take a slice for former allocation

Is realloc worth it vs free+malloc? Sometimes yes.

 // PERF: on Windows, reusing previous allocation is much faster for same alloc size
    //       314x faster             vs free+malloc for same size
    //       10x faster              vs free+malloc for decreasing size 1 by 1
    //       424x slower (quadratic) vs free+malloc for increasing size 1 by 1
    //       0.5x slower             vs free+malloc for random size

If we store the allocation as slice, we could second guess realloc().

@p0nce p0nce added the enhancement New feature or request label Jan 8, 2023
@p0nce p0nce changed the title Reuseing allocation Reuseing allocation when? Jan 8, 2023
@p0nce
Copy link
Collaborator Author

p0nce commented Jan 14, 2023

  • currently a problem for Dplug, recreating an image buffer should reuse the allocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant