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

Add more benchmarks: #110

Merged
merged 3 commits into from Sep 11, 2018

Conversation

dmitry-timofeev
Copy link
Contributor

@dmitry-timofeev dmitry-timofeev commented Sep 8, 2018

Overview

  • Push/PopLocalFrame overhead benchmark — such operations
    are required if one attaches a long-running native thread
    to the JVM because there is no 'return-from-native-method'
    event when created local references are freed, hence no way for
    the JVM to know that the local references are no longer used
    in the native code.

  • A benchmark of the overhead of attaching and detaching
    a native thread. It is expectedly HUGE — two orders of magnitude
    higher than calling a single Java method using unchecked APIs
    (e.g., jni_call_static_unsafe).

Results
$ cargo +nightly-2018-08-01 bench --features=invocation,backtrace 
   …

running 16 tests
test tests::jni_call_object_method_safe          ... bench:       2,049 ns/iter (+/- 64)
test tests::jni_call_object_method_unsafe        ... bench:         276 ns/iter (+/- 25)

test tests::jni_call_static_method_safe          ... bench:       2,577 ns/iter (+/- 65)
test tests::jni_call_static_method_unsafe_jclass ... bench:         293 ns/iter (+/- 11)
test tests::jni_call_static_method_unsafe_str    ... bench:         840 ns/iter (+/- 32)

test tests::jni_get_java_vm                      ... bench:          11 ns/iter (+/- 0)

test tests::jni_new_global_ref                   ... bench:         195 ns/iter (+/- 1)

test tests::jni_new_object_by_id_jclass          ... bench:         251 ns/iter (+/- 13)
test tests::jni_new_object_by_id_str             ... bench:         765 ns/iter (+/- 65)
test tests::jni_new_object_jclass                ... bench:       1,917 ns/iter (+/- 47)
test tests::jni_new_object_str                   ... bench:       2,561 ns/iter (+/- 84)

test tests::jni_noop_with_local_frame            ... bench:          96 ns/iter (+/- 0)
test tests::jvm_noop_attach_detach_native_thread ... bench:      26,616 ns/iter (+/- 2,445)

test tests::native_arc                           ... bench:          11 ns/iter (+/- 0)
test tests::native_call_function                 ... bench:           2 ns/iter (+/- 0)
test tests::native_rc                            ... bench:           3 ns/iter (+/- 0)

test result: ok. 0 passed; 0 failed; 0 ignored; 16 measured; 0 filtered out

Definition of Done

- Push/PopLocalFrame overhead benchmark — such operations
are *required* if one attaches a long-running native thread
to the JVM because there is no 'return-from-native-method'
event when created local references are freed, hence no way for
the JVM to know that the local references are no longer used
in the native code.

- A benchmark of the overhead of attaching and detaching
a native thread. It is expectedly HUGE — two orders of magnitude
higher than calling a single Java method using unchecked APIs
(e.g., `jni_call_static_unsafe`).
dmitry-timofeev and others added 2 commits September 8, 2018 22:10
Also, import the fix for the configuration from jni-rs#113
@dmitry-timofeev dmitry-timofeev merged commit 39eea0b into jni-rs:master Sep 11, 2018
@dmitry-timofeev dmitry-timofeev deleted the add-more-benchmarks branch September 11, 2018 11:55
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

3 participants