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

How to deal with thread spawned outside of madsim simulation #144

Closed
bsbds opened this issue May 23, 2023 · 2 comments
Closed

How to deal with thread spawned outside of madsim simulation #144

bsbds opened this issue May 23, 2023 · 2 comments

Comments

@bsbds
Copy link
Contributor

bsbds commented May 23, 2023

Hi, thanks for maintaining this fantastic project! I have a question regarding the scenario of invoking external C libraries that may create system threads.

For instance, I've been using rocksdb on madsim runtime, the main thread of rocksdb operates inside the madsim context while the threads it spawned do not, thereby leading to an inconsistency.

Any suggestions on this? Currently I have to allow spawning a system thread and call rocksdb functions inside it.

@wangrunji0408
Copy link
Member

Hi! Glad to see madsim is being used in Xline.

It is intended to forbid creating system thread in the simulation in order to prevent non-determinism.

We have encountered a similar issue, where a third-party library, moka, created a system thread in the background for cache invalidation. Our solution was to replace it by a BTreeMap in the simulation.

Generally, I would suggest replace third-party libraries by mocks in the simulation, so that we could avoid any potential uncertainty. However, if this library is critical to functionality and you believe the system thread it creates won't break the determinism, I can introduce a new API to temporarily disable this check.

What do you think?

@bsbds
Copy link
Contributor Author

bsbds commented May 26, 2023

Thanks for the suggestions! That makes sense. I'll try replacing the rocksdb with a mock one in the simulation.

@bsbds bsbds closed this as completed Jun 7, 2023
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

No branches or pull requests

2 participants