Skip to content

Conversation

@ihsandemir
Copy link
Collaborator

Added SocketOptions configuration and increased default tcp read/write buffer size from 32KB to 128 KB.

fixes #465

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

HazelcastServer instance(*g_srvFactory);

ClientConfig clientConfig;
clientConfig.getNetworkConfig().getSocketOptions().setKeepAlive(false).setReuseAddress(true).setTcpNoDelay(false).setLingerSeconds(5).setBufferSize(2 * 1024);

Choose a reason for hiding this comment

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

what is tested here?

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 is not testing the functionality of each option but just a test to see that the client works when the options are set. This was mostly for coverage. More meaningful functionality tests would be better but I did not come up with a way how to test tcp level such settings yet.

class HAZELCAST_API SocketOptions {
public:
/**
* constant for kilobyte

Choose a reason for hiding this comment

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

I think we dont need this comment, it doesnt say more than the variable name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are from Java client documentation. If needed we need to change both. I think it can stay.

Copy link

@SaitTalhaNisanci SaitTalhaNisanci Nov 20, 2018

Choose a reason for hiding this comment

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

I think they are not even used in Java :) I sent a cleanup PR for that https://github.com/hazelcast/hazelcast/pull/14147/files

Choose a reason for hiding this comment

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

As they are part of API we cant change them I guess. If there isnt any check like checkstyle for CPP we shouldnt have them here. They are probably there in Java because of checkstyle(otherwise the build fails).

static const int KILO_BYTE = 1024;

/**
* default buffer size of Bytes

Choose a reason for hiding this comment

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

also this one

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

int getLingerSeconds() const;

/**
* Enable/disable SO_LINGER with the specified linger time in seconds

Choose a reason for hiding this comment

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

What value disables SO_LINGER?

Copy link
Collaborator Author

@ihsandemir ihsandemir Nov 20, 2018

Choose a reason for hiding this comment

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

Added doc:

                *
                 * if set to a value of 0 or less then it is disabled.
                 *
                 * Default value is 3.

SocketOptions &setLingerSeconds(int lingerSeconds);

/**
* Gets the SO_SNDBUF and SO_RCVBUF options to the specified value in KB

Choose a reason for hiding this comment

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

Gets the SO_SNDBUF and SO_RCVBUF options value

* Gets the SO_SNDBUF and SO_RCVBUF options to the specified value in KB
* @return bufferSize KB value
*/
int getBufferSize() const;

Choose a reason for hiding this comment

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

If it returns in KB the name of the function can be getBufferSizeInKB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is actually bytes. Corrected the documentation now.

* @param bufferSize KB value
* @return SocketOptions configured
*/
SocketOptions &setBufferSize(int bufferSize);

Choose a reason for hiding this comment

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

setBufferSizeInKB

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is bytes. Changed doc.

Choose a reason for hiding this comment

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

if it is bytes I think method name should be setBufferSizeInBytes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, changed.

}

SocketInterface &TcpSocket::setSocketOptions(const client::config::SocketOptions &socketOptions) {
int optionValue = socketOptions.getBufferSize();

Choose a reason for hiding this comment

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

I think for better readability instead of using optionValue we can use directly the option's name, for example here int bufferSizeInKB = socketOptions.getBufferSizeInKB()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I named it this way to reuse the same local variable for each option instead of stack allocating a new one for each.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

…xist at Linux.

Also some review comment fixes.
@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

@devOpsHazelcast
Copy link
Contributor

Windows test PASSed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

@devOpsHazelcast
Copy link
Contributor

Windows test PASSed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

@devOpsHazelcast
Copy link
Contributor

Linux test FAILed.

@devOpsHazelcast
Copy link
Contributor

Windows test FAILed.

@devOpsHazelcast
Copy link
Contributor

Linux test PASSed.

@devOpsHazelcast
Copy link
Contributor

Windows test PASSed.

@ihsandemir ihsandemir merged commit e9ca6b0 into hazelcast:master Nov 23, 2018
@ihsandemir ihsandemir deleted the socketOptionsConfig branch November 23, 2018 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large value sized IMap.set performance decreases without suitable socket options setting - send/receive buffer sizes

4 participants