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
Multithread #12
Comments
Hi @pakipaki2000 and thanks for the new and interesting question! This idea behind making an unlocked version of a database is for the use case where multiple processes do not need to access the database and therefore the performance overhead of unnecessary spin locks at run-time can be avoided. Unlocking and then locking a database again has not been considered much so far. Which use case can you imagine for doing this? I.e. let's say during 1,000 ms the database is unlocked for 900 ms, and locked for 100 ms... in which use case is this useful? Because normally use case demand performance which is similar across the entire usage period. Looking forward to hearing your ideas and comments. |
Any kind of multi-thread/multi-process example would be really useful 👍 |
I still get the error =0.000000 23199 mremap(): 14: Bad address when i try to get from different threads at same time tho :( |
My needs are quite simple: process 1) - 16 threads each -> Get, Insert... The 2 processes must do it simultaneously. |
"Any kind of multi-thread/multi-process example" Both [1] and [2] are tests which are multi-process. [1] https://github.com/simonhf/sharedhashfile/blob/master/src/test.q.shf.c |
Thanks Simon! Will check-it out. You are super helpful |
"Bad address when i try to get from different threads at same time tho" SHF is designed to be multi-process but not multi-threaded. Having said that, there is no good reason why it shouldn't be multi-threaded, and It may be possible to fix that in the future, but currently only multi-process works, in that it is designed that way with tests to validate that multi-process works. Speculation on why multi-threaded likely doesn't work in the current source code: There are some global variables which are not stored in shared memory. Since threads share the same address space in a single process then these might conflict and cause the kind of issues you have seen. This sounds like something which would be 'fixable' but which would require some investigation.
Is it possible to have 32 processes with 1 thread instead of 2 processes with 16 threads? test.f.shf.c [1] is a simple load test example which can use and report on up to 36 processes simultaneously. Tip: Keep in mind that you do not want to use more processes than you have CPU cores on your box. Why? Because SHF uses spin locks (actually a technology usually used in the kernel and not in user land) which perform badly if process context switching occurs. To avoid process context switching then always have no more processes than there are CPU cores on the box. That way there are no other processes to context switch to. [1] https://github.com/simonhf/sharedhashfile/blob/master/src/test.f.shf.c |
Alright, that explains why :) |
I have a 64 cores machine for those tests. |
Hi,
When you lock shf_set_is_lockable, how do you unlock afterward? I don't find the function in test.9.shf.c.
I have a hard time doing some Get into 2 different threads. it always says:
mremap(): 14: Bad address
If i'm retrieving from a single thread, I have no issues.
Thanks again :)
The text was updated successfully, but these errors were encountered: