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

Synchronize, optimize, and safely delay native module load #536

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Mar 11, 2024

Goal

The SharedObjectLoader module tried to load the module into memory every time it is called, but it's not necessary when it's already been done on a process.

Optimize this by saving the successful loading value and returning true to indicate that it's load without first doing a reload.

Also, make the runtime dependency more explicit as components were relying on the loading having before the init, which meant it was doing it way too soon.

Further, synchronize that method so we don't do if more than once. Once it's loaded, the synchronization block won't be hit so this is really impacts the the pre-init workflows that hit this, which are PLENTY, though this PR will not improve that, as this is meant to be minimally invasive only.

Testing

Modify existing tests. We could probably improve them though as they are based on mocks happening at a higher level, and no unit tests exist for this component by itself, as it relies on being tested via its usages.

@bidetofevil bidetofevil changed the title Defer native module init Defer and synchronize native module load Mar 11, 2024
@bidetofevil bidetofevil changed the title Defer and synchronize native module load Synchronize, optimize, and safely delay native module load Mar 11, 2024
@bidetofevil bidetofevil marked this pull request as ready for review March 11, 2024 07:07
@bidetofevil bidetofevil requested a review from a team as a code owner March 11, 2024 07:07
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 78.57143% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 79.60%. Comparing base (5e18d90) to head (0cb6cd3).
Report is 2 commits behind head on master.

❗ Current head 0cb6cd3 differs from pull request most recent head 94eb7bf. Consider uploading reports for the commit 94eb7bf to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #536      +/-   ##
==========================================
+ Coverage   79.45%   79.60%   +0.14%     
==========================================
  Files         403      403              
  Lines       10861    10872      +11     
  Branches     1602     1603       +1     
==========================================
+ Hits         8630     8655      +25     
+ Misses       1585     1572      -13     
+ Partials      646      645       -1     
Files Coverage Δ
...cesdk/anr/ndk/EmbraceNativeThreadSamplerService.kt 90.83% <100.00%> (+2.79%) ⬆️
.../io/embrace/android/embracesdk/ndk/NativeModule.kt 100.00% <100.00%> (+21.95%) ⬆️
...embracesdk/anr/ndk/NativeThreadSamplerInstaller.kt 57.14% <50.00%> (+0.89%) ⬆️
.../android/embracesdk/internal/SharedObjectLoader.kt 64.28% <61.53%> (-21.43%) ⬇️

... and 5 files with indirect coverage changes

Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator Author

bidetofevil commented Mar 11, 2024

Merge activity

  • Mar 11, 11:07 AM EDT: @bidetofevil started a stack merge that includes this pull request via Graphite.
  • Mar 11, 11:08 AM EDT: Graphite rebased this pull request as part of a merge.
  • Mar 11, 11:09 AM EDT: @bidetofevil merged this pull request with Graphite.

Base automatically changed from hho/defer-pref-reads to master March 11, 2024 15:07
@bidetofevil bidetofevil merged commit 9fcd0e9 into master Mar 11, 2024
3 checks passed
@bidetofevil bidetofevil deleted the hho/defer-native-init branch March 11, 2024 15:09
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

Successfully merging this pull request may close these issues.

None yet

2 participants