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

Refactor log macro for readability #683

Merged
merged 1 commit into from
Jul 24, 2023
Merged

Refactor log macro for readability #683

merged 1 commit into from
Jul 24, 2023

Conversation

tamird
Copy link
Member

@tamird tamird commented Jul 21, 2023

This happens to fix the miscompilation that occurs when bpf-linker is
moved to LLVM's new pass manager. A later commit will avoid the
miscompilation more convincingly.

@netlify
Copy link

netlify bot commented Jul 21, 2023

Deploy Preview for aya-rs-docs ready!

Name Link
🔨 Latest commit b3db916
🔍 Latest deploy log https://app.netlify.com/sites/aya-rs-docs/deploys/64bacce8d4b9530008476fc0
😎 Deploy Preview https://deploy-preview-683--aya-rs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

This happens to fix the miscompilation that occurs when bpf-linker is
moved to LLVM's new pass manager. A later commit will avoid the
miscompilation more convincingly.
Copy link
Member

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alessandrod
Copy link
Collaborator

Do you know what the miscompilation looks like and why this fixes it?

@tamird
Copy link
Member Author

tamird commented Jul 22, 2023

The hypothesis is lining thresholds change under the new PM, and this rearrangement gets this inlined with the new PM.

The root cause is that the logging functions should take self by reference to avoid passing lots of parameters and triggering miscompilation.

I'll do that in this PR.

@tamird tamird closed this Jul 22, 2023
@tamird tamird reopened this Jul 22, 2023
}
}
match unsafe { &mut ::aya_log_ebpf::AYA_LOG_BUF }.get_ptr_mut(0).and_then(|ptr| unsafe { ptr.as_mut() }) {
None => {},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this if let? Why doesn't clippy complain about this?

@alessandrod
Copy link
Collaborator

If you're going to rework the WriteToBuf impls or whtever it's called, it would be good to actually remove the inlining from aya-log. It's common to have several log calls and aya-log currently consumes a big part of the insn budget because of all the inlining.

@tamird
Copy link
Member Author

tamird commented Jul 22, 2023

Are you saying we should #[inline(never)]? The only inlining annotations I see are here and here; the first one doesn't seem significant, the second has to do with the header (not the fields, which is what we're discussing the inlining of here).

@alessandrod
Copy link
Collaborator

Are you saying we should #[inline(never)]? The only inlining annotations I see are here and here; the first one doesn't seem significant, the second has to do with the header (not the fields, which is what we're discussing the inlining of here).

I think we should #[inline(never)] TagLenValue::write, since llvm isn't very smart at not over inlining monomorphized code. But it doesn't necessarily have to be in this PR, up to you.

@alessandrod
Copy link
Collaborator

And also the inline on writing the record header needs to go too

@tamird
Copy link
Member Author

tamird commented Jul 24, 2023

Yeah, I agree. I started pulling on this thread and it's getting a bit involved; I'm going to merge this as-is now and revisit when we have working debuginfo which will make figuring out the verifier issues I'm chasing now easier.

@tamird tamird merged commit 5ebaf5f into main Jul 24, 2023
@tamird tamird deleted the logs-wtf branch July 24, 2023 15:35
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

Successfully merging this pull request may close these issues.

3 participants