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

Serial section when compiling a jx9 program? #132

Open
mdorier opened this issue Oct 26, 2021 · 1 comment
Open

Serial section when compiling a jx9 program? #132

mdorier opened this issue Oct 26, 2021 · 1 comment

Comments

@mdorier
Copy link
Contributor

mdorier commented Oct 26, 2021

I was trying to optimize the performance of a multi-threaded code in which multiple threads could execute Jx9 code against the same database. Unqlite is compiled with multithreading support. I noticed that unqlite locks the database's mutex while compiling the Jx9 code, here:

SyMutexEnter(sUnqlMPGlobal.pMutexMethods, pDb->pMutex); /* NO-OP if sUnqlMPGlobal.nThreadingLevel != UNQLITE_THREAD_LEVEL_MULTI */

This prevents multiple threads from compiling VMs in parallel. Whether VMs can execute in parallel is another story, but I was at least expecting to be able to compile Jx9 programs concurrently, in particular because timing information shows that this compilation is what takes up most of the time in my scenario. Is there a reason for this part of the code to be serial?

@symisc
Copy link
Owner

symisc commented Oct 31, 2021

The reason access is serialized when compiling different Jx9 scripts within a same UnQLite database engine is simple: A same UnQLite DB hold a single Jx9 handle (compiler) which cannot compile scripts in parallel and thus access is serialized.
This should not be a major issue if you factor your code intelligently (eg: compile your Jx9 scripts, and cache the resulting VMs at program start time for example).

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