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

UDPSocket#send copies data multiple times #621

Closed
ghost opened this issue Mar 31, 2013 · 1 comment
Closed

UDPSocket#send copies data multiple times #621

ghost opened this issue Mar 31, 2013 · 1 comment
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Mar 31, 2013

From RubyUDPSocket.java:277

RubyString data = _mesg.convertToString();
ByteBuffer buf = ByteBuffer.wrap(data.getBytes());
byte[] buf2 = data.getBytes();

each call to data.getBytes() creates a new byte array with the contents of data and returns it - and the second copy is only needed for multicast sockets - if it is unicast, then it is unused!

This could be optimized to use data.getByteList().unsafeBytes(), and the ByteBuffer(byte[] data, int offset, int length) constructor and the DatagramPacket(byte[] data, int offset, int length) constructor to avoid any copying of the data.

@ghost ghost self-assigned this Apr 1, 2013
@headius
Copy link
Member

headius commented Apr 5, 2016

Definitely needs optimization. Looking at 9.1 to see if this is still the case.

@headius headius added this to the JRuby 9.1.0.0 milestone Apr 5, 2016
@headius headius closed this as completed in 2221210 Apr 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant