-
Notifications
You must be signed in to change notification settings - Fork 123
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
Drop the Glean handle and move state into glean-core #664
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #664 +/- ##
============================================
- Coverage 75.33% 74.95% -0.38%
Complexity 266 266
============================================
Files 97 97
Lines 6077 6050 -27
Branches 729 735 +6
============================================
- Hits 4578 4535 -43
- Misses 963 976 +13
- Partials 536 539 +3 ☔ View full report in Codecov by Sentry. |
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.
This looks good from an high level look. I'd like to take a closer look tomorrow, but already looks solid to me.
@badboy did you test this with our instrumented tests as well?
@@ -41,8 +41,8 @@ class Glean: | |||
>>> Glean.initialize(application_id="my-app", application_version="0.0.0", upload_enabled=True) | |||
""" | |||
|
|||
# The handle to the underlying Rust object | |||
_handle = 0 # type: int | |||
# Whether Glean was initialized |
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.
@mdboom could you please take a look at least at the Python changes?
I did forget that we don't run these for Android just yet on CI. I'll run them locally. |
So, I understand the changes made here, but I don't feel confortable approving / rejecting them, because I don't have much experience with the FFI part of the code specially. I have looked throughly at the diff and don't see any problems, but I will remove myself from the reviewers list :) One thing that is not completely clear to me is how Thanks and cool work! |
You are right in that this is unrelated. I will pull this out of this PR and submit it as its own (and include more of a reason "why" I did it) |
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. This is actually a really nice simplification (aside from it being required for the multi-language-in-the-same-runtime future of FOG).
@@ -4,29 +4,25 @@ | |||
|
|||
use ffi_support::FfiStr; | |||
|
|||
use crate::{define_metric, handlemap_ext::HandleMapExtension, GLEAN}; | |||
use crate::{define_metric, handlemap_ext::HandleMapExtension, with_glean_value}; |
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.
nit: This function name didn't immediately make sense to me. Maybe with_glean_singleton
?
Something is happening when I run |
This allows to keep all global state for Glean itself in the core crate.
This removes the state from the FFI layer, allowing use of the core crate alone in situations where we don't want to go through the FFI.
For reset we want to close the database early and then reopen it again with the new configuration.
Mostly mechanical changes applied using `fastmod`:` fastmod -e kt 'glean_handle: Long, ?' '' fastmod -e kt 'Glean.handle, ?' '' fastmod -e kt -m '^\s+\n' ''
Mostly mechanical changes applied using `fastmod`:` fastmod -e swift 'glean_handle: Uint64, ?' '' fastmod -e swift 'Glean.shared.handle, ?' '' fastmod -e swift -m '^\s+\n' ''
Mostly mechanical changes applied using `fastmod`:` fastmod -e py 'cls._handle, ?' '' fastmod -e py 'Glean._handle, ?' ''
lint/style fix
lint/style fix
https://bugzilla.mozilla.org/show_bug.cgi?id=1602751
This is finally addressing the changes to move Glean's state into the glean-core crate, dropping all use of a "glean handle" through the FFI.
This will ultimatively allow others to use Glean through FFI without relying on our direct platform wrappers (think application-service's use across dynamic library boundaries).
This is a huge change and touches all parts of the code base, so I'd like review from a bigger set of eyes.
I tried structuring the commits to make sense on their own.
The "Remove the glean handle from *" parts are mostly automatic simple code changes, the other commits contain the actual logic changes.
This leaves the user-facing API untouched (Android/iOS consumers will keep working).