CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 09:14:16 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/dotnet/android.git
etag: W/"f96ec142090834001128b39ccb08bbf2"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=bgqs8hLqnmVSq6GGdSg2mZa%2BrHcZBYwR1GyU4reIIdg78X3vGhfBUjrJeqdX4PDOZToGtt5kl5w9YG9qyY8nZDjVFDkL%2BdGPisk6C97Db4lBxxx692uMcBZaH2BSpERbK2TXnRPrvnsC9kzG4xbLAJ%2Fz5wnJwhhcgt4wBX%2BhY94sN1vv4mOOEhfafPQle8TXLfTAu5ad96uuRnrUxx0nteRWyUgfAlYTBUOln5Sdee%2BTUBwCOeUVWPexY0NUIe8kOdIVJUzaqvI93Jd1qe943Q%3D%3D--k1vEI2u9hjGLqH09--E6oMgm9WJaZgDjNjonsOJQ%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1070155255.1753607655; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 09:14:15 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 09:14:15 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: E33A:3C6DB4:34641D:477D9B:6885EDE7
[monodroid] Speed up P/Invoke override lookups (#6210) · dotnet/android@38aa561 · GitHub
Copy file name to clipboardExpand all lines: build-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets
Copy file name to clipboard
Copy file name to clipboardExpand all lines: src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit 38aa561
authored
[monodroid] Speed up P/Invoke override lookups (#6210)
Commit 0cd890b added use of [robin_map][0] to cache P/Invokes lookups.
This incurred a startup time penalty, as the map must be instantiated
and populated with `std::string` instances.
Continue using `robin_map` as a fallback cache, and introduce a
"primary" P/Invoke lookup data structure, an array of structures
describing each P/Invoke entry:
struct PinvokeEntry {
hash_t hash;
const char *name;
void *func;
};
static PinvokeEntry internal_pinvokes[] = {
// …
};
static PinvokeEntry dotnet_pinvokes[] = …
`PinvokeEntry::hash` is a hash of `PinvokeEntry::name`, computed via
a modified [xxHash algorithm][1], in `src/monodroid/jni/xxhash.hh`.
The `internal_pinvokes` & `dotnet_pinvokes` arrays are sorted on
`PinvokeEntry::hash`, allowing a binary search to be performed after
hashing the function name to find.
The `internal_pinvokes` array contains P/Invokes for the
`xa-internal-api` and `java-interop` library names, and are fully
configured at build-time, as we can directly reference the target
functions:
PinvokeEntry internal_pinvokes[] = {
{0x1e035ea, "java_interop_jnienv_get_string_chars", reinterpret_cast<void*>(&java_interop_jnienv_get_string_chars)},
// …
};
The `dotnet_pinvokes` array *doesn't* mention the function targets:
static PinvokeEntry dotnet_pinvokes[] = {
{0xaf6b1c, "AndroidCryptoNative_RsaPrivateDecrypt", nullptr},
// …
};
`PinvokeEntry::func` will be computed on first request for a given
P/Invoke, when we load the relevant library and look up the symbol,
storing the pointer in the array afterwards.
Both the internal and dotnet library names are matched without using
string comparison. Instead, a hash of the library name passed from
Mono is generated and compared against pre-generated hashes to
determine which table is to be used for lookups.
Both the tables and library name hashes are generated by the new
`generate-pinvoke-tables` C++ app, which also serves as a build-time
test of the xxHash implementation (it includes a handful of simple
compile-time tests). Alas, currently this program can be built only
on the Linux CI bots, since neither Windows nor macOS machines
support enough of C++20. For this reason, the generated file is
committed to the repository instead of generating it each time
`src/monodroid` is built. When building on CI Linux machines, we do
compile the utility, generate the tables, and compare the generated
file to the one committed to repository. If the files differ, the
build will error out and let us examine the differences (both the new
generated file and the diff are part of the build status archive).
More work needs to be done in order to compare the public interfaces
found in the dotnet shared libraries against the table stored in the
generator.
The generated tables allow us to not use the "slow" `robin_map<>` hash
path during application startup (MAUI apps use the .NET 6+ P/Invokes
during that phase). Additionally, the `robin_map<>` cache now uses
the xxHash hashes as well for faster lookups.
In addition, both the embedded assembly mmap code as well as the
.NET 6+ P/Invoke entry code now use the GCC/clang `__atomic` APIs to
atomically set pointers, which avoids having to use any form of locks.
A new lock guard class, `StartupAwareLock`, is used to take a lock
only after the startup phase of Xamarin.Android is complete and it's
possible that multiple threads may be calling the runtime routines.
All of the above changes improve application startup time on a
Pixel 3 XL device by:
* Plain XA sample: ~17ms faster
* Hello MAUI sample: ~100ms faster
[0]: https://github.com/Tessil/robin-map
[1]: https://github.com/ekpyron/xxhashct1 parent e9a4c9f commit 38aa561Copy full SHA for 38aa561
File tree
Expand file treeCollapse file tree
17 files changed
+2879
-455
lines changedFilter options
- build-tools
- Xamarin.Android.Tools.BootstrapTasks
- scripts
- src
- Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base
- monodroid
- jni
- tests/Mono.Android-Tests/Runtime-Microsoft.Android.Sdk/Android.Runtime
Expand file treeCollapse file tree
17 files changed
+2879
-455
lines changedbuild-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets
Copy file name to clipboardExpand all lines: build-tools/Xamarin.Android.Tools.BootstrapTasks/result-packaging.targets+2Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
| 34 | + | |
33 | 35 |
| |
34 | 36 |
| |
35 | 37 |
| |
|
build-tools/scripts/generate-pinvoke-tables.sh
Copy file name to clipboard+94Lines changed: 94 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc
Copy file name to clipboardExpand all lines: src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc+9-9Lines changed: 9 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
5 |
| - | |
| 5 | + | |
6 | 6 |
| |
7 | 7 |
| |
8 |
| - | |
| 8 | + | |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
17 |
| - | |
| 17 | + | |
18 | 18 |
| |
19 | 19 |
| |
20 |
| - | |
| 20 | + | |
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
| 26 | + | |
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
32 |
| - | |
| 32 | + | |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
47 |
| - | |
| 47 | + | |
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
| |||
77 | 77 |
| |
78 | 78 |
| |
79 | 79 |
| |
80 |
| - | |
| 80 | + | |
81 | 81 |
|
You can’t perform that action at this time.
0 commit comments