-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Fix performance bug in Java API get() functions when key is NotFound #13049
base: main
Are you sure you want to change the base?
Fix performance bug in Java API get() functions when key is NotFound #13049
Conversation
3519c07
to
e028be5
Compare
Hello @alanpaxton, looks good for me. Only one question, can merge operation exit with status not found? The reason why I'm asking is because we changes signature of method
|
@rhubner No, I can't see how NotFound can come back from a merge. It's always a valid operation to merge with no previously written value, if I understand the semantics correctly. |
e028be5
to
479acd0
Compare
Performance of NotFound case has been bad - see facebook#13023 Some jmh tests to measure this, prior to fixing it.
Handling NotFound should not go through the (horribly slow) C++ exception mechanism, because it is the expected/standard path in many cases. Change KVException::ThrowOnError to return a status when ok() or NotFound(), and the caller has to handle that status. Retain the exception mechanism for exceptions, it does simplifiy the flow and reduce checking.
get / getDirect / getForUpdate Repair performance by avoiding the C++ exception path on NotFound. Previous commit on this change altered behaviour of ROCKSDB_NAMESPACE::KVException::ThrowOnError to not throw on NotFound, this change is also necessary to reinstate correct behaviour.
Add extra tests for getDirect() —> NotFound where a potential gap existed Add a couple of extra tests around NotFound for comfort
479acd0
to
b2b87da
Compare
When a key did not exist in the system, various
get()
calls from the Java API were using an exception-based return path within the C++ stubs used by the Java/JNI API, because we considered that a non-existent key was a problem. But it's a common pattern and throwing an exception was reducing the overall performance of NotFoundget()
s by about 3x in the cached case we measured.We have removed NotFound from the error path; exceptions are still used to handle other exceptional cases, but we explicitly handle
ok()
andIsNotFound()
status from the underlyingget()
calls without using exceptions. This alsoapplies to various transaction versions of
get()
.Finally we noted (provoked in our testing) a couple of cases where some variants of calls to get() a key were not tested for non-existent keys, and we added tests.
Closes #13023