-
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
Add native logger support to RocksJava #12213
Add native logger support to RocksJava #12213
Conversation
Hi @adamretter, I'd love if you could take a look at these updates to RocksJava. Happy to make any changes as needed. |
@neilramaswamy I think we should stick with just
Option 1 may break some existing applications but gives a cleaner API, whilst Option 2 is less disruptive but leaves some cruft in the existing API design. I would be happy with either approach. With either approach, the Native Loggers you are interested in can each be represented by a Java class which implements Logger (or an AbstractClass implementation thereof), and |
@adamretter, thank you for your quick comments. I've implemented the second option, since I didn't want to break any existing code. But yes, there certainly some cruft: the To make sure the cruft doesn't get in the way of usability, I can add documentation to the RocksJava Wiki page on how to create a JVM logger and set it, as well as configuring a native logger and setting that. |
@neilramaswamy I have pushed a couple of commits to refactor this more towards the API that I had in mind. I think perhaps that my previous explanation wasn't very detailed. Let me know if you are happy with it? |
This API works with me, but there will then end up being some redundancy in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks :-)
We can add an abstract sub-class in-future if needed I think @neilramaswamy |
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@neilramaswamy has updated the pull request. You must reimport the pull request before landing. |
@neilramaswamy has updated the pull request. You must reimport the pull request before landing. |
Thanks for the review @ajkr! I addressed the first issue, and I think I fixed the test failure (they were only Windows build errors; I unfortunately do not have a Windows machine, so I can't test locally). I will wait for CI and iterate from there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Hi @ajkr, I believe you need to approve the workflow for all the checks to run (that's what GitHub tells me). I can take a look at any Windows build errors (if any) after that. Also, I can't see the "Facebook Internal - Linter" check, which is failing. If you are able to share the warnings with me, I can fix them. |
The linter wants |
@neilramaswamy has updated the pull request. You must reimport the pull request before landing. |
Alas, all tests must run again, but I removed the semi. I think passing the string directly is more clear, so I left it. The Windows errors were fixed, so this should be the last time you have to approve the workflow :) Thanks for the engagement on this. I really appreciate it. |
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@neilramaswamy has updated the pull request. You must reimport the pull request before landing. |
@neilramaswamy has updated the pull request. You must reimport the pull request before landing. |
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@neilramaswamy has updated the pull request. You must reimport the pull request before landing. |
@neilramaswamy has updated the pull request. You must reimport the pull request before landing. |
@ajkr has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Overview
In this PR, we introduce support for setting the RocksDB native logger through Java. As mentioned in the discussion on the Google Group discussion, this work is primarily motivated by the JDK 17 performance regression in JNI thread attach/detach calls: the only existing RocksJava logging configuration call,
setLogger
, invokes the provided logger over the JNI.Changes
Specifically, these changes add support for the
devnull
andstderr
native loggers. For thestderr
logger, we add the ability to prefix every log with alogPrefix
, so that it becomes possible know which database a particular log is coming from (if multiple databases are in use). The API looks like the following:Note that the API to set the logger is the same, via
Options::setLogger
(orDBOptions::setLogger
). However, it will set the RocksDB logger to be native when the provided logger is an instance ofNativeLogger
.Testing
Two tests have been added in
NativeLoggerTest.java
. The first test creates both thedevnull
andstderr
loggers, and sets them on the associatedOptions
. However, to avoid polluting the testing output with logs fromstderr
, only thedevnull
logger is actually used in the test. The second test does the same logic, but forDBOptions
.It is possible to manually verify the
stderr
logger by modifying the tests slightly, and observing that the console indeed gets cluttered with logs fromstderr
.