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

Implement structure inlining #359

Open
pschachte opened this issue Sep 27, 2022 · 0 comments
Open

Implement structure inlining #359

pschachte opened this issue Sep 27, 2022 · 0 comments
Labels
enhancement New feature or request performance Issues related to performance of generated code research project

Comments

@pschachte
Copy link
Owner

Where a member of one structure type is an instance of another, consider embedding the inner structure directly in the outer one. This will save an allocation, an indirection every time the inner structure is accessed, and a word of memory. This is the difference between (in C)

struct foo {
    struct bar *ptr;
    ...
}

and

struct foo {
    struct bar actual_struct;
    ...
}

The cost of doing this is that duplicating the outer structure entails copying the inner one, too, so more memory must be allocated and copied (ie, the data structure is not persistent). Also, destructively modifying the outer structure to replace the inner one would require copying the whole inner structure, rather than just storing one pointer, so we wouldn't want to always do this. Obviously, we can't do it for a recursive structure.

Finding a heuristic for determining when this is desirable is an interesting research project.

@pschachte pschachte added enhancement New feature or request research project performance Issues related to performance of generated code labels Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Issues related to performance of generated code research project
Projects
None yet
Development

No branches or pull requests

1 participant