Skip to content

Conversation

@vahidlazio
Copy link
Contributor

No description provided.

Copy link
Member

@nicklasl nicklasl left a comment

Choose a reason for hiding this comment

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

Thanks 👍

@nicklasl
Copy link
Member

nicklasl commented Oct 9, 2025

Oh... actually... During runtime, would it not be good to have it sync?

@nicklasl
Copy link
Member

nicklasl commented Oct 9, 2025

But I guess then we would need to take the instance out of the rotation when updating the state?

@vahidlazio vahidlazio force-pushed the parallel-set-state-2 branch from 5502eee to 928b281 Compare October 9, 2025 15:32
@vahidlazio
Copy link
Contributor Author

@nicklasl it is sync but it's parallel, we wait for all parallel state sets. in each rotation we create a new wasm module so that's the rotation. it happens in SwapWasmResolverApi.

@vahidlazio vahidlazio force-pushed the parallel-set-state-2 branch from 15ee5de to e572e6a Compare October 10, 2025 10:13
}

public void flushLogs() {
logResolveLock.lock();
Copy link
Contributor

@andreas-karlsson andreas-karlsson Oct 10, 2025

Choose a reason for hiding this comment

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

Will this lock ever be contented? The idea is it shouldn't be right? Cause we use different instances for different threads (although I think the thread local thing is fishy, cause we can very well have more than number of cpu threads calling us and some will be mapped to the same instance). But if this lock can be contended it would be good to know where that can happen. If we don't think it can be contented maybe it's better to do a tryLock and throw or at least log otherwise?

Copy link
Contributor

Choose a reason for hiding this comment

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

I later saw that we are depending on this lock.

final var request = consumeResponse(respPtr, WriteFlagLogsRequest::parseFrom);
final var ignore = writeFlagLogs.write(request);
isFlushed = true;
logResolveLock.unlock();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have try/finally around all lock acquires.

final var respPtr = (int) wasmMsgFlushLogs.apply(reqPtr)[0];
final var request = consumeResponse(respPtr, WriteFlagLogsRequest::parseFrom);
final var ignore = writeFlagLogs.write(request);
isFlushed = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit strange to me that we make this, the lowest root resolver, be flush once only?

Comment on lines 142 to 143
logResolveLock.unlock();
return consumeResponse(respPtr, ResolveWithStickyResponse::parseFrom);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't consumeResponse be inside the lock? It will call free right? Also add try/finally, which in this case will make it easier to return inside the try block and still unlock in the finally..

final int reqPtr = transferRequest(request);
final int respPtr = (int) wasmMsgGuestResolve.apply(reqPtr)[0];
logResolveLock.unlock();
return consumeResponse(respPtr, ResolveFlagsResponse::parseFrom);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. Consume should be inside the lock.

final var instance = wasmResolverApiRef.get();
final ResolveWithStickyResponse response;
try {
response = instance.resolveWithSticky(request);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. So I guess here we might wait for an ongoing flush and then throw to retry, so we are using the lock inside WasmResolveApi, but I guess that's fine unless we wait for a whole setState..

@vahidlazio vahidlazio merged commit 0071949 into main Oct 10, 2025
2 checks passed
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