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

[Wisp] Blocking io support for SocketChannel and Pipe #35

Merged
merged 1 commit into from
Dec 1, 2020

Conversation

joeyleeeeeee97
Copy link
Contributor

Summary: Hook blocking entry at pipeChannel and SocketChannel,
current WispTask would block itself to wait for next scheduling.

Test Plan: jtreg BlockIngIOTest.

Reviewed-by: zhengxiaolinX, yuleil

Issue: dragonwell-project/dragonwell8#143

@joeyleeeeeee97 joeyleeeeeee97 force-pushed the master branch 6 times, most recently from 59a63dc to 80d1cb7 Compare November 19, 2020 08:44
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change

import java.nio.channels.NotYetBoundException;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.channels.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change

@@ -344,6 +344,25 @@ public void getCpuTime(long[] ids, long[] times) {
}
}
}

@Override
public int poll(SelectableChannel channel, int interestOps, long millsTimeOut) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. WAE.poll should return polled event count;
  2. WAE.poll receive NET.* events represent as parameters will be clearer.
  3. Coroutines are not interrupted when the socket closes. Leave a TODO there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. please have another look.

Close socket is ok here, because we would check isOpen() every time.

@joeyleeeeeee97 joeyleeeeeee97 force-pushed the master branch 3 times, most recently from c2ddb40 to 9e76d2c Compare November 23, 2020 08:13
}
}

int translateToSelectionKey(int event) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't use switch here because Net.POLLIN is not constant.

@joeyleeeeeee97 joeyleeeeeee97 force-pushed the master branch 2 times, most recently from 6a392db to 1ae35b8 Compare November 23, 2020 08:55
@@ -25,6 +25,8 @@

package sun.nio.ch;

import com.alibaba.wisp.engine.WispEngine;
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

}

@Override
public int poll(SelectableChannel channel, int interestOps, long millsTimeOut) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

add JavaDoc to point out it's a Net.* event represent

* @return active event count
* @throws IOException
*/
@Override
Copy link
Contributor

Choose a reason for hiding this comment

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

put the java doc above method in the interface

@@ -25,6 +25,7 @@

package sun.nio.ch;


Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary

@@ -278,7 +271,9 @@ public SocketChannel accept() throws IOException {
if (n < 1)
return null;

IOUtil.configureBlocking(newfd, true);
if (!WispEngine.transparentWispSwitch()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

use configureAsNonBlockingForWisp

@@ -25,6 +25,7 @@

package sun.nio.ch;


Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary

try {
configureAsNonBlockingForWisp(fd);
} catch (IOException e) {
throw new RuntimeException("Unexpected error at configureAsNonBlockingForWisp", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

UncheckIOException

@joeyleeeeeee97 joeyleeeeeee97 force-pushed the master branch 2 times, most recently from a6ef9e1 to cb6933c Compare November 25, 2020 02:28
@CLAassistant
Copy link

CLAassistant commented Nov 25, 2020

CLA assistant check
All committers have signed the CLA.

@@ -165,6 +175,12 @@ public int read(ByteBuffer dst) throws IOException {
thread = NativeThread.current();
do {
n = IOUtil.read(fd, dst, -1, nd);
if (isBlocking() && WispEngine.transparentWispSwitch()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

WispEngine.transparentWispSwitch() && isBlocking()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@joeyleeeeeee97 joeyleeeeeee97 force-pushed the master branch 2 times, most recently from e210c92 to 4c95f4b Compare November 25, 2020 03:24
Summary: Hook blocking entry at pipeChannel and SocketChannel,
current WispTask would block itself to wait for next scheduling.

Test Plan: jtreg BlockIngIOTest.

Reviewed-by: zhengxiaolinX, yuleil

Issue: dragonwell-project/dragonwell8#143
Copy link
Contributor

@zhengxiaolinX zhengxiaolinX left a comment

Choose a reason for hiding this comment

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

This patch looks good to me.

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.

4 participants