]> rtime.felk.cvut.cz Git - orte.git/commit
Java: rewrite receive callback
authorMartin Vajnar <martin.vajnar@gmail.com>
Mon, 20 Apr 2015 17:55:29 +0000 (19:55 +0200)
committerMartin Vajnar <martin.vajnar@gmail.com>
Mon, 20 Apr 2015 17:55:29 +0000 (19:55 +0200)
commit9c366a8529292d2344ee4896c1acfb81484a657c
tree4484a3906fcc7c05f1d32b25b97872d0177e0a9a
parent098ecfdc87d8f42d1d591c78e1be608e8b94ea43
Java: rewrite receive callback

This commit results in significant increase of subscriber's performance
in Java.

Previously we used to create many Java objects during the reception of fresh
issue. These objects carried the same information as the ORTERecvInfo C
structure. Now we handle it in a way similar to how data reception is taken
care of.

That is, we allocate a direct ByteBuffer upon the creation of subscriber.
This buffer's address is then stored in a helper structure, which is passed
to this receive callback function.

When new issue arrives, we copy it's ORTERecvInfo C structure into this
ByteBuffer by calling memcpy(). We are not immediately parsing the contents
of this buffer for performance reasons. We do it only when someone
requests information included in the buffer (this is handled in the
org.ocera.orte.types.RecvInfo class).

Many method IDs and field IDs previously looked-up upon every callback
invocation are now cached in a helper structure, since the IDs remain
valid until the mentioned classes are unloaded by the ClassLoader
(that is until all their instances are GC'd). Also many unnecessary checks
are removed from the receive callback. This patch increases the probability,
that the callback function remains in the I-cache, because many procedures
are moved away.

Performance comparison before and after applying this patch:
(Reception of 10,000 issues)

PC, Intel C2Q Q9550 @ 2GHz, OpenJDK 7
Before: 2.01 s
Now:    1.68 s

SE Xperia Ray, Android 4.1
Before (Thumb): 10.95 s
Before (ARM):   10.90 s
Now (Thumb):     9.43 s
Now (ARM):       9.53 s

As could be seen the Thumb-2 mode outperforms the ARM mode, so there is now
no need to switch to the ARM mode.
12 files changed:
orte/include/jorte/jorte.h
orte/include/jorte/jorte_protos_api.h
orte/include/jorte/jorte_typedefs_defines.h
orte/include/jorte/org_ocera_orte_types_RecvInfo.h [new file with mode: 0644]
orte/java/src/org/ocera/orte/types/RecvInfo.java
orte/libaorte/jni/Android.mk
orte/libjorte/JORTERecvInfoHelpers.c [new file with mode: 0644]
orte/libjorte/JORTESubscriptionCreate.c
orte/libjorte/JORTESubscriptionDestroy.c
orte/libjorte/Makefile.am
orte/libjorte/Makefile.omk
orte/libjorte/setRecvInfo.c [deleted file]