Skip to content

RUM-14330: Optimizations to reduce .so file#3190

Merged
kikoveiga merged 2 commits into
developfrom
kikoveiga/RUM-14330/reduce-size-ndk-so-file
Mar 13, 2026
Merged

RUM-14330: Optimizations to reduce .so file#3190
kikoveiga merged 2 commits into
developfrom
kikoveiga/RUM-14330/reduce-size-ndk-so-file

Conversation

@kikoveiga

@kikoveiga kikoveiga commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Adds compiler and linker size optimizations to the NDK module's CMake configuration, reducing the .so file size by around 50%.
  • Minor code cleanups (remove unused imports, CLion suggestions)

Motivation

The .so for arm64-v8a was ~860 KB — larger than the SDK's APK footprint (~570 KB) without the ndk.

Below are analysis of this file inside the Sample app release APK done in Android Studio, describing Size on the left and Download Size on the right.

Before (sample app release APK on develop branch):
image

After (with these optimizations):
image

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-14330/reduce-size-ndk-so-file branch 2 times, most recently from ea86e35 to b8c18c3 Compare February 19, 2026 10:44
@kikoveiga kikoveiga self-assigned this Feb 19, 2026
@datadog-official

This comment has been minimized.

@codecov-commenter

codecov-commenter commented Feb 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.37%. Comparing base (bbf5b1b) to head (704f62e).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3190      +/-   ##
===========================================
- Coverage    71.38%   71.37%   -0.01%     
===========================================
  Files          940      940              
  Lines        34773    34773              
  Branches      5894     5894              
===========================================
- Hits         24822    24819       -3     
+ Misses        8308     8306       -2     
- Partials      1643     1648       +5     

see 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-14330/reduce-size-ndk-so-file branch 2 times, most recently from 89a5d6e to 9318ad7 Compare February 19, 2026 15:08
@kikoveiga
kikoveiga marked this pull request as ready for review February 19, 2026 15:12
@kikoveiga
kikoveiga requested a review from a team as a code owner February 19, 2026 15:12
0xnm
0xnm previously approved these changes Feb 19, 2026

@0xnm 0xnm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If everything works in Release build and NDK crash is captured and sent, then all good 👍

@0xnm

0xnm commented Feb 19, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@0xnm the compiler was optimizing and removing the code of sigsegv and sigill ndk crashes (even before my changes) in release builds, so the buttons on the sample app didn't work. Simplified this and confirmed NDK crashes are being sent to Datadog and working fine.

@kikoveiga
kikoveiga requested a review from 0xnm February 19, 2026 16:51
#include <jni.h>
#include <signal.h>

void crash_with_sigsegv_signal() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you explain the need for this change? raise indeed will raise the necessary signal, but the code here is to illustrate the real example leading to the particular signal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Rolled back to the previous code, just added some tweaks to prevent compiler optimization. Tested and crashes are working in sample app release build.

-Werror -Wall -pedantic)

# Size optimizations for non-Debug builds
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one thing to check for release builds: once NDK crash happens and if Datadog NDK makes a part of the stacktrace, can we still symbolicate such frames after binary shrinking?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out. First implementation had this problem, now fixed by removing fvisibility=hidden from compile options. Now, all function names are preserved and readable at runtime.

@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-14330/reduce-size-ndk-so-file branch from 5c41110 to 46f748f Compare March 13, 2026 11:55
@kikoveiga
kikoveiga requested a review from a team as a code owner March 13, 2026 11:55
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-14330/reduce-size-ndk-so-file branch from 46f748f to 707ed9d Compare March 13, 2026 12:31
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-14330/reduce-size-ndk-so-file branch 2 times, most recently from 6f9c1f7 to 0a6bbcc Compare March 13, 2026 14:27
@kikoveiga
kikoveiga force-pushed the kikoveiga/RUM-14330/reduce-size-ndk-so-file branch from 0a6bbcc to 704f62e Compare March 13, 2026 14:27
@kikoveiga
kikoveiga requested a review from 0xnm March 13, 2026 14:28
@kikoveiga
kikoveiga merged commit c149019 into develop Mar 13, 2026
26 checks passed
@kikoveiga
kikoveiga deleted the kikoveiga/RUM-14330/reduce-size-ndk-so-file branch March 13, 2026 15:22
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.

3 participants