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

add possibility of preparing and sending a message #12

Merged
merged 3 commits into from
Dec 19, 2020

Conversation

peano88
Copy link
Contributor

@peano88 peano88 commented Dec 18, 2020

We were using your package successfully before migrating to go 1.14. This version often breaks the ipc.Msgsnd function when used under high frequency and flags 0 (which is a blocking call). As a workaround, we are now using a for cycle where we issue an ipc.Msgsnd with flag ipc.IPC_NOWAIT and if the resulting error is a syscall.EAGAIN we sleep for a bit and try again. This workaround works, but it has the inconvenient of being pretty heavy on memory allocation. This is due to the buffer allocation in ipc.Msgsnd. I have created this repository: https://github.com/peano88/test-ipc-memory to show that

  1. with go1.14 we have often an "interrupted system call" ( at least on a CentOs, just run the waitFail/ipc_wait_fail.go a couple of times: it should be enough)
  2. the memory allocation of the no wait alternatives is pretty high (there is a screenshot of the memprofile in the noWait folder).

We then worked on a feasible solution, which is the subject of this pull request: it consists of preparing the buffer once and try to send it afterwards. The memprofile in noWaitModified folder of the above repository shows the difference. As a plus, I solved a couple of go vet issues in the test file.

@siadat
Copy link
Owner

siadat commented Dec 19, 2020

Thanks for the PR and the test repo!

It looks good to me! Your solution follows the recommendation in Go 1.14 release note. I'll paste the interesting section here for later references:

A consequence of the implementation of preemption is that on Unix systems, including Linux and macOS systems, programs built with Go 1.14 will receive more signals than programs built with earlier releases. This means that programs that use packages like syscall or golang.org/x/sys/unix will see more slow system calls fail with EINTR errors. Those programs will have to handle those errors in some way, most likely looping to try the system call again. For more information about this see man 7 signal for Linux systems or similar documentation for other systems.

@siadat siadat merged commit 440779a into siadat:master Dec 19, 2020
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