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

Size vs. speed optimization in RT compilation #3343

Closed
BsAtHome opened this issue Feb 20, 2025 · 5 comments
Closed

Size vs. speed optimization in RT compilation #3343

BsAtHome opened this issue Feb 20, 2025 · 5 comments

Comments

@BsAtHome
Copy link
Contributor

There are special CFLAGS in the Makefile for real-time code. The CFLAGS include -Os line1242:

EXTRA_CFLAGS += -fPIC -Os

I am a bit puzzled why this isn't -O2. Or at least propagated from (other) configuration options. It can't be a problem with size. There is plenty memory.
Using size optimize in real-time code is even more puzzling because this code is supposed to run as fast as possible...

Shouldn't this just be changed/fixed to read -O2?

BTW, there is one more instance of -Os in the Makefile (line 254). This also makes no sense.

@rmu75
Copy link
Contributor

rmu75 commented Feb 20, 2025

Just a guess: kernel modules can't be paged or swapped out and userspace RT code is also memlocked IIRC, so on smallish machines 20 years ago maybe it made a difference. Some side effects of undefined behaviour also behave different with -Os and -O2 in my experience.

Btw code doesn't need to run "as fast as possible", I would say it should run with predictable and ideally constant runtime.

I'm d'accord this should be changed to -O2.

@BsAtHome
Copy link
Contributor Author

That would also be my guess. Will change that.

On a side note, strictly seen, "ideally constant runtime" is essentially a fantasy using these very complex multi-core, super-scalar, out-of-order, ..., processors and high-level languages.

@andypugh
Copy link
Collaborator

andypugh commented Mar 2, 2025

Close this issue?

@BsAtHome
Copy link
Contributor Author

BsAtHome commented Mar 2, 2025

Not yet. The final fix, changing the Makefile, is still pending. The other PRs were in preparation.

I'm also looking into the last of the cppcheck errors.

@BsAtHome
Copy link
Contributor Author

BsAtHome commented Mar 4, 2025

Fixed in #3363.

@BsAtHome BsAtHome closed this as completed Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants