Skip to content

Commit

Permalink
Allow a larger size for the messages sent and received by the client
Browse files Browse the repository at this point in the history
  • Loading branch information
programLyrique committed Dec 5, 2024
1 parent 77a547c commit c2b7f5c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion client/rsh/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ SEXP Client::make_client(SEXP address, SEXP port, SEXP installed_packages) {
packages.push_back(CHAR(STRING_ELT(installed_packages, i)));
}

// We need to increase the maximum response size (4 MB by default)
auto channel_args = grpc::ChannelArguments();
channel_args.SetMaxReceiveMessageSize(1024 * 1024 * 10);
channel_args.SetMaxSendMessageSize(1024 * 1024 * 10);
auto channel =
grpc::CreateChannel(address_str, grpc::InsecureChannelCredentials());
grpc::CreateCustomChannel(address_str, grpc::InsecureChannelCredentials(), channel_args);
auto client = new Client(channel, packages);

SEXP ptr = PROTECT(R_MakeExternalPtr(client, RSH_CLIENT_PTR, R_NilValue));
Expand Down
14 changes: 7 additions & 7 deletions server/src/main/java/org/prlprg/bc/BcInstr.java
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ public BcOp op() {
}
}

@StackEffect(pop=1, push=1)
@StackEffect(pop = 1, push = 1)
record And1st(ConstPool.Idx<LangSXP> ast, @LabelName("afterAnd") BcLabel shortCircuit)
implements BcInstr {
@Override
Expand All @@ -879,15 +879,15 @@ public Optional<BcLabel> label() {
}
}

@StackEffect(pop=2, push=1)
@StackEffect(pop = 2, push = 1)
record And2nd(ConstPool.Idx<LangSXP> ast) implements BcInstr {
@Override
public BcOp op() {
return BcOp.AND2ND;
}
}

@StackEffect(pop=1, push=1)
@StackEffect(pop = 1, push = 1)
record Or1st(ConstPool.Idx<LangSXP> ast, @LabelName("afterOr") BcLabel shortCircuit)
implements BcInstr {
@Override
Expand All @@ -901,7 +901,7 @@ public Optional<BcLabel> label() {
}
}

@StackEffect(pop=2, push=1)
@StackEffect(pop = 2, push = 1)
record Or2nd(ConstPool.Idx<LangSXP> ast) implements BcInstr {
@Override
public BcOp op() {
Expand Down Expand Up @@ -1197,7 +1197,7 @@ public BcOp op() {
}
}

@StackEffect(pop=1, push=1)
@StackEffect(pop = 1, push = 1)
@NeedsRho
record Log(ConstPool.Idx<LangSXP> ast) implements BcInstr {
@Override
Expand All @@ -1206,7 +1206,7 @@ public BcOp op() {
}
}

@StackEffect(pop=2, push=1)
@StackEffect(pop = 2, push = 1)
@NeedsRho
record LogBase(ConstPool.Idx<LangSXP> ast) implements BcInstr {
@Override
Expand All @@ -1215,7 +1215,7 @@ public BcOp op() {
}
}

@StackEffect(pop=1, push=1)
@StackEffect(pop = 1, push = 1)
@NeedsRho
record Math1(ConstPool.Idx<LangSXP> ast, int funId) implements BcInstr {
@Override
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/org/prlprg/bc2c/BC2CCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private void compile(BcInstr instr, int pc) {
yield "%s = %s;".formatted(stack.get(0), stack.get(-2));
}
case BcInstr.Math1(var call, var op) ->
builder.args(constantSXP(call), String.valueOf(op)).compileStmt();
builder.args(constantSXP(call), String.valueOf(op)).compileStmt();

default -> {
if (instr.label().orElse(null) instanceof BcLabel l) {
Expand Down
23 changes: 11 additions & 12 deletions server/src/test/java/org/prlprg/bc2c/BC2CCompilerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.function.Function;

import org.jetbrains.annotations.TestOnly;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.prlprg.bc2c.BC2CSnapshotTestExtension.BC2CSnapshot;
Expand Down Expand Up @@ -598,7 +596,8 @@ public void testMath1(BC2CSnapshot snapshot) {

@Test
public void testAdhoc(BC2CSnapshot snapshot) {
snapshot.verify("""
snapshot.verify(
"""
bench_rays <- function(height.map = volcano, sun.angle = 45) {
shadow <- matrix(1, ncol = ncol(height.map), nrow = nrow(height.map))
sunangle <- sun.angle / 180 * pi
Expand All @@ -610,7 +609,7 @@ public void testAdhoc(BC2CSnapshot snapshot) {
maxdistance <- floor(sqrt(ncol(height.map)^2 + nrow(height.map)^2))
sinsun <- sin(sunangle)
cossun <- cos(sunangle)
for (i in 1:nrow(height.map)) {
for (j in 1:ncol(height.map)) {
for (anglei in anglebreaks) {
Expand All @@ -619,19 +618,19 @@ public void testAdhoc(BC2CSnapshot snapshot) {
xcoord <- i + sinsun * k
# ycoord <- j + cos(sunangle) * k
ycoord <- j + cossun * k
if (xcoord > nrow(height.map) ||
ycoord > ncol(height.map) ||
xcoord < 0 || ycoord < 0) break
# tanangheight <- height.map[i, j] + tan(anglei) * k
tanangheight <- height.map[i, j] + anglei * k
if (all(c(height.map[ceiling(xcoord), ceiling(ycoord)],
height.map[floor(xcoord), ceiling(ycoord)],
height.map[ceiling(xcoord), floor(ycoord)],
height.map[floor(xcoord), floor(ycoord)]) < tanangheight)) next
if (tanangheight < bilinear(height.map, xcoord, ycoord)) {
shadow[i, j] <- shadow[i, j] - 1 / length(anglebreaks)
break
Expand All @@ -640,10 +639,10 @@ ycoord > ncol(height.map) ||
}
}
}
shadow
}
bilinear <- function(data, x0, y0) {
i <- max(1, floor(x0))
j <- max(1, floor(y0))
Expand All @@ -663,9 +662,9 @@ ycoord > ncol(height.map) ||
}
result
}
points <- rep(181L, 10) # 181 takes the longest to compute
n = 1
s = 0
for (j in 1:n) {
Expand Down

0 comments on commit c2b7f5c

Please sign in to comment.