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

Use a repr(C) flow ID to reduce repeated per-packet conversion costs #475

Merged
merged 20 commits into from
May 10, 2024

Conversation

FelixMcFelix
Copy link
Collaborator

@FelixMcFelix FelixMcFelix commented Mar 12, 2024

This PR replaces InnerFlowId with an equivalent C-ABI friendly struct, from which we can directly pass pointers to our dtrace SDTs. This has proven necessary as we are reconstructing this many times per packet in both the UFT slowpath and fastpath.

Unfortunately, this has unearthed #476 for which we have a temporary hack, NopDrop, which uses a black_box'd Drop implementation to prevent problem SDTs from being tail-called into.

Additionally, this makes partial progress on #460 by using the new DError machinery whenever a packet is Ok(Modified | Hairpin | Bypass) to elide string formats on layer/port processing. The Err(_) and Ok(Drop{ .. }) cases remain open work, but are less common and in those cases we have at least removed a superfluous realloc + memcpy on the formatted string.

From local IGB<->IGB results and comparing 4e2ad7e against master in CI, this seems like O(10%) reduction in packet latency spent in XDE. Certainly less of a total improvement once we account for the rest of MAC, and throughput impact on T6s is TBD.

Closes #462.

`uintptr_t` maybe be easy to stick in a probe, but it is also a footgun.
This fixdes the display for e.g. port-process-return, but does not
affect the actual panics mentioned in #476.
It appears that JMP'd dtrace probes are being rewritten at load time
without a RTN. Near as I can tell, rustc offers no way to say 'don't
tail-call optimise this thing', so I'm forcing in a ZST with a drop impl
to achieve similar behaviour. Hopefully this suffices.
@FelixMcFelix FelixMcFelix marked this pull request as ready for review March 15, 2024 19:33
@FelixMcFelix
Copy link
Collaborator Author

FelixMcFelix commented Apr 8, 2024

Testing on sn9/14 over a single 100GbE link (cxgbe1<->cxgbe1) (on a release build of Helios):

BeforeAfter
Run 1/5...1762.141Mbps
Run 2/5...1785.854Mbps
Run 3/5...1759.315Mbps
Run 4/5...1741.879Mbps
Run 5/5...1741.848Mbps
Run 1/5...1944.113Mbps
Run 2/5...1939.164Mbps
Run 3/5...1934.922Mbps
Run 4/5...1930.715Mbps
Run 5/5...1930.84Mbps
Mean 1758.207 Mean 1935.951

Not sure whether/if we'd expect more improvement with cxgbe0s also connected, but a 10.1% mean BW increase is pretty nice.

@FelixMcFelix FelixMcFelix added this to the 8 milestone Apr 11, 2024
@FelixMcFelix FelixMcFelix self-assigned this Apr 16, 2024
@FelixMcFelix FelixMcFelix added feature Planned and requested features perf and removed feature Planned and requested features labels Apr 22, 2024
@@ -229,16 +224,15 @@ fn flow_expired_probe(
last_hit: Option<Moment>,
now: Option<Moment>,
) {
let a = crate::NopDrop;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All NopDrop code will be removed once illumos#16480 is merged in and available on the helios-2.0 lab image.

@@ -117,10 +119,15 @@ impl Display for DenyReason {
}
}

#[derive(Debug)]
// TODO: Represent `name` as joint C+RStr to implement fully.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This would fall under the work remaining for #460.

lib/opte/src/lib.rs Outdated Show resolved Hide resolved
dtrace/lib/common.d Outdated Show resolved Hide resolved
dtrace/lib/common.d Outdated Show resolved Hide resolved
lib/opte/src/engine/packet.rs Outdated Show resolved Hide resolved
lib/opte/src/engine/print.rs Outdated Show resolved Hide resolved
lib/opte/src/engine/port.rs Outdated Show resolved Hide resolved
Realised when I was out that this struct only has 2B alignment, so there
was a possibility of passing up an unaligned reference to an SDT.
Given that we're now using these to handle nested `Ok(...)` types rather
than just error variants, a rename was a bit in order. `DError` might
also benefit?
Copy link
Contributor

@luqmana luqmana left a comment

Choose a reason for hiding this comment

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

Thanks Kyle! Since the fix for #476 has landed in helios I'd say remove the workarounds but otherwise LGTM.

@FelixMcFelix FelixMcFelix modified the milestones: 8, 9 May 10, 2024
@FelixMcFelix FelixMcFelix merged commit 976f4dc into master May 10, 2024
10 checks passed
@FelixMcFelix FelixMcFelix deleted the cheaper-flowid branch May 10, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conversion of InnerFlowId to SDT args appears expensive
3 participants