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 headroom by moving packet around #481

Closed
wants to merge 1 commit into from
Closed

Conversation

wingo
Copy link

@wingo wingo commented Oct 14, 2016

Instead of mutating a pointer inside "struct packet" to do cheap
shiftleft/shiftright, this patch instead moves around the packet
pointer itself.

The only performance testing I did was "snabb lwaftr bench", where it
appears to be neutral-to-slight-win. I am hoping that the Hydra/R
scientists can help me out on this one.

This change to the packet structure does have a knock-on effect, in
two significant ways. One is that the shiftleft, shiftright, and
prepend functions now return a new packet pointer and silently
corrupt the old one (because probably they shifted around the data but
still had to update the new "length" pointer). That's somewhat OK
though.

The problem comes in the datagram library, which sometimes wants
to work on a user-supplied packet. The sequence was:

local dgram = datagram:new(pkt)
dgram:push(....)
dgram:free()
...
foo(pkt)

This pattern is no longer valid :( The reason is that the datagram
methods that mutate a packet often do so by packet.prepend(). The
datagram library updates its internal packet pointer, but the external
one that was initially passed in is no longer valid. So much of this
patch is visiting (hopefully) all of the uses/users and updating them.

@wingo
Copy link
Author

wingo commented Oct 14, 2016

cc @dpino @kbara @lukego

@wingo
Copy link
Author

wingo commented Oct 14, 2016

Related to #407

Instead of mutating a pointer inside "struct packet" to do cheap
shiftleft/shiftright, this patch instead moves around the packet
pointer itself.

The only performance testing I did was "snabb lwaftr bench", where it
appears to be neutral-to-slight-win.  I am hoping that the Hydra/R
scientists can help me out on this one.

This change to the packet structure does have a knock-on effect, in
two significant ways.  One is that the shiftleft, shiftright, and
prepend functions now return a new packet pointer and silently
corrupt the old one (because probably they shifted around the data but
still had to update the new "length" pointer).  That's somewhat OK
though.

The problem comes in the datagram library, which sometimes wants
to work on a user-supplied packet.  The sequence was:

  local dgram = datagram:new(pkt)
  dgram:push(....)
  dgram:free()
  ...
  foo(pkt)

This pattern is no longer valid :(  The reason is that the datagram
methods that mutate a packet often do so by packet.prepend().  The
datagram library updates its internal packet pointer, but the external
one that was initially passed in is no longer valid.  So much of this
patch is visiting (hopefully) all of the uses/users and updating them.
@dpino
Copy link
Member

dpino commented Oct 17, 2016

I'm OK with the patch. I wait for others reviews/comments.

@wingo
Copy link
Author

wingo commented Oct 17, 2016

Let's wait on this one until merging in snabbco#1034 and snabbco#1032.

@wingo
Copy link
Author

wingo commented Oct 19, 2016

Because an equivalent change has landed on next, I'll land this via a merge from next instead. Closing this PR (though I looked at the diff here to see what I would need to do for the merge).

@wingo wingo closed this Oct 19, 2016
@wingo wingo deleted the reshenanigan branch October 19, 2016 09:12
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.

2 participants