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

Passing class pointer to native could improve performance. #33

Closed
hideki opened this issue Oct 13, 2015 · 4 comments
Closed

Passing class pointer to native could improve performance. #33

hideki opened this issue Oct 13, 2015 · 4 comments
Assignees

Comments

@hideki
Copy link

hideki commented Oct 13, 2015

Passing class pointer to native could improve performance.

@hideki hideki self-assigned this Oct 13, 2015
@pasin
Copy link
Contributor

pasin commented Oct 14, 2015

Will this also help collator calling back to java for unicode comparison?

@hideki
Copy link
Author

hideki commented Oct 14, 2015

@pasin No. Article suggested to less call from native to java code by passing all values in one JNI call from java to native.

If collator can consolidate the calls from native to java or reduce the number of calls, it will improve the performance. We need to review collator codes.

@snej
Copy link
Contributor

snej commented Oct 14, 2015

Can you give examples of how we could optimize particular calls?

@hideki
Copy link
Author

hideki commented Oct 14, 2015

Java_com_couchbase_cbforest_QueryIterator_next() calls getEnum(env, self) to obtain the pointer of C4QueryEnumerator. In side the getEnum(env, self), it calls env->GetLongField(self, kHandleField); which is JNI call from native to Java code. By passing class pointer from Java to native, we could avoid this JNI call. In case of iterating 100 or 1K docs, we could same number of JNI calls.
https://github.com/couchbaselabs/cbforest/blob/master/Java/jni/native_queryIterator.cc#L35

@snej snej added the ready label Oct 23, 2015
@snej snej closed this as completed in ab2be83 Oct 24, 2015
@snej snej removed the ready label Oct 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants