Loading...
Searching...
No Matches
JAVA a good and mature language
Date
26 dez 2024 - setup of the initial document

INDEX

JAVA a good and mature language

Many things that are hard to do in another language are easy to do in Java. Integrating Java into the NHI1-build-environment was child's play and otherwise I can only report positive things.

There are two basic types of build environments :

  1. An active environment that aims to offer a holistic solution that does not aim to integrate into an external solution and thus maximizes the integration wall :
  2. A passive environment that aims to integrate into an external solution and thus minimizes the integration wall :

Since, as described :

  • I am very satisfied with Java.

THREADS

INDEX - HOWTO thread in PLMK

A thread is always a problem for so-called "high-level languages", i.e. everything outside of C and C++.

  • Java was an exception in this respect because the thread is fully supported under both the C api and the Java api.
  • Java supports not only the thread generated by Java but also the thread generated by an external source.

THREAD POOL

INDEX - HOWTO Thread Pool

C - MqMsgque startup
JNI_OnLoad(JavaVM *jvm, void *reserved)
{
#ifdef META_THREAD_POOL
MqLal.MqSysServerThreadCB = NS(MqSysServerThreadCB);
MkLal.MkSysExitCB = NS(MkSysExitCB);
#endif // META_THREAD_POOL
struct MkLalS MkLal
struct MqLalS MqLal
MkSysExitF MkSysExitCB
MqSysServerThreadF MqSysServerThreadCB
return JNI_VERSION_10;
error:
return JNI_ERR; /* JNI version not supported */
}
C - MqMsgque setup
JNIEXPORT void JNICALL Java_jvmqmsgque_MqMsgque_MqSysServerThreadMain
(JNIEnv * env, jclass cls, jlong mainL)
{
}
void MqSysServerThreadMain(struct MqSysServerThreadMainS *data)
static enum MkErrorE NS(MqSysServerThreadCB) (
MkErrorE
MQ_CTX const ctx,
struct MqSysServerThreadMainS * const argP,
MK_STRN name,
int state,
struct MkIdS * idP
) {
SETUP_env;
if (env == NULL)
return MkErrorSetV_1E("[%s] 'env' pointer is NULL",name);
if (idP->ioIsPipe) {
jobject runnableO = (*env)->CallStaticObjectMethod(env, MQ(Class_MqMsgque), MQ(MID_Thread_Pipe_callback), (jlong) argP);
if((*env)->ExceptionCheck(env) == JNI_TRUE) {
OT_ERROR_LNG_2_MQ(ctx);
goto error;
}
idP->type = MK_ID_THREAD;
idP->val = (MK_IDNT) (*env)->NewWeakGlobalRef(env,runnableO);
} else {
(*env)->CallStaticObjectMethod(env, MQ(Class_MqMsgque), MQ(MID_Thread_Work_callback), (jlong) argP);
if((*env)->ExceptionCheck(env) == JNI_TRUE) {
OT_ERROR_LNG_2_MQ(ctx);
goto error;
}
idP->type = MK_ID_THREAD;
idP->val = (MK_IDNT) 0x1;
}
error:
#define MkErrorStack_0E_Check()
#define MkErrorSetV_1E(printfmt,...)
const MK_STRB * MK_STRN
uintptr_t MK_IDNT
MK_ID_THREAD
#define MK_RT_ARGS
}
static void NS(MkSysExitCB) ( MK_RT_ARGS int isThread, int num ) {
SETUP_env;
if (isThread) {
#ifndef META_THREAD_POOL
// 1. do nothing, end of "MqSysServerThreadMain" finish thread
// 2. "sThreadExit" already detach the thread
//(*MK(cached_jvm))->DetachCurrentThread(MK(cached_jvm));
#endif
} else {
(*env)->CallStaticVoidMethod(env, NS(Class_System), NS(MID_System_exit), (jint) num);
}
// FINISH
error:
return;
#define MkRtSetup_NULL_RT
}
JAVA - MqMsgque callback
package jvmqmsgque;
final public class MqMsgque {
// [OVERLOAD THREAD]
private static native void MqSysServerThreadMain(long mainS);
private static ExecutorService threadPool = null;
private static Future<Object> MqSysServerThreadPipeCB(long mainS) {
if (threadPool == null) threadPool = Executors.newCachedThreadPool();
var ret = threadPool.submit(
() -> {
try {
} catch (Throwable e) {
MkErrorC.DEFAULT().Catch(e).Println();
}
}
,null);
return ret;
}
private static void MqSysServerThreadWorkCB(long mainS) {
if (threadPool == null) threadPool = Executors.newCachedThreadPool();
threadPool.execute(
new Runnable() {
public void run() {
try {
} catch (Throwable e) {
MkErrorC.DEFAULT().Catch(e).Println();
}
}
}
);
}
// [OVERLOAD THREAD]
C - MqContextC setup
void NS(MqContextC_Init)(MK_RT_ARGS_ONLY) {
#define MK_RT_ARGS_ONLY
ClassInit
// define type
MqContextCTT = MkTypeDup2(MqContextC_TT,"javamsgue_MqContextC");
MqContextCTT->selfCreate = NS(MqContextC_selfCreate) ;
MqContextCTT->selfUnlink = MK(AtomSelfUnlink) ;
MqContextCT->argvFix = true ;
MqContextCT->MqProcessExitCB = sProcessExit ;
MqContextCT->MqThreadExitCB = sThreadExit ;
MqContextCT->MqWaitForPipeCB = sWaitForPipe ;
MqContextCT->Child.fCreate = MqLinkDefault_RT ;
MqContextCT->Parent.fCreate = MqLinkDefault_RT ;
MqContextCT->ignoreFork = true ;
MqContextCT->ignoreDisasterSetup = true ;
}
#define MkTypeDup2(...)
#define MqContextCTT
#define MqContextCT
#define MqContextC_TT
#define MQ_STATIC_RT
static void sThreadExit (MK_RT_ARGS int exitnum)
{
#ifndef META_THREAD_POOL
(*MK(cached_jvm))->DetachCurrentThread(MK(cached_jvm));
#endif // META_THREAD_POOL
}
static void sProcessExit (MK_RT_ARGS int exitnum)
{
SETUP_env;
(*env)->CallStaticVoidMethod(env, NS(Class_System), NS(MID_System_exit), (jint) exitnum);
error:
return;
}
static void sWaitForPipe (MK_RT_ARGS MQ_CTX const ctx, const struct MkIdS *idP ) {
switch ((*idP).type) {
case MK_ID_PROCESS: {
break;
}
case MK_ID_THREAD: {
SETUP_env_X(ctx);
jobject futureO = (jobject) (*idP).val ;
if (!(*env)->IsSameObject(env,futureO, NULL)) {
(*env)->CallVoidMethod(env, futureO, MQ(MID_Thread_wait));
}
(*env)->DeleteWeakGlobalRef(env,futureO);
break;
}
case MK_ID_UNUSED: {
MkPanicC_1("MK_ID_UNUSED never used");
break;
}
}
}

REFERENCES

INDEX - HOWTO Weak or Strong Reference

In Programming-Language-Micro-Kernel (PLMK), the connection to a language such as Java is regulated by a reference.

The pointer of a Java object is stored as week or strong reference :

weak
A weak reference is a reference that is still owned by the garbage-collection and is released there when necessary.
  • The self reference in MkObjectS::self only serves as a hint that there might be an object in the target language that resolves to NULL if necessary.
A weak reference is:
  • created with: jweak (*env)->NewWeakGlobalRef(env, self)
  • resolved with jobject MK(AtomObjNew)(MK_RT_CALL env, obj) (MK_NULL return possible)
  • released with: (*env)->DeleteWeakGlobalRef(env, self)
strong
A strong reference is a reference that is owned by the Programming-Language-Micro-Kernel (PLMK) and is not released by the garbage-collection. A strong reference is:
  • created with: jobject (*env)->NewGlobalRef(env, self)
  • resolved with (jobject) (*obj).self (MK_NULL return not possible)
  • released with: (*env)->DeleteGlobalRef(env, self)
A strong reference is a source for a memory-leak because every object not released by the Programming-Language-Micro-Kernel (PLMK) is also not released by the garbage-collection.
PLMK is able to deal with a weak or a strong reference.
By default the weak reference is used, a strong reference is activated with the compile-switch META_STRONG_REF
#ifdef META_STRONG_REF
# define AtomObjNew_O(env,o) (*o).self
# define AtomObjNew_X(env,x) MkOBJ_R(x).self
#else
# define AtomObjNew_O(env,o) MK(AtomObjNew)(MK_RT_CALL env,o)
# define AtomObjNew_X(env,x) AtomObjNew_O(env,MkOBJ(x))
#endif

PERFORMANCE

INDEX - README_PERFORMANCE

I only compare the performance of C# with the performance of Java as a direct competitor.

call an empty callback from C

INDEX - perftests: --send-nothing

JV code
class NTHT implements MqServiceIF {
public void Callback(MqContextC ctx) {
}
}
JV result
 call: 'NHI1_HOME/performance/performance.bash' 'pr' '--send-nothing' '--sec' '4' '_pipe'


setup=perf-release
  > feature=cc_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ .../perf-release/inst/sbin/cc/x86_64-suse-linux-gnu-perfserver
      C> {x86_64-suse-linux-gnu-perfclient:pid(25468):tid(0x7f6c027a12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f6c0278c440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25468):tid(0x7f6c027a12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f6c0278c440):statistics                    }:                 --send-nothing :   535975.8 [  2144169 / 4.000496   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25468):tid(0x7f6c027a12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f6c0278c440):PerfClientExec                }: end: ----------------------------------------
  > feature=c_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfserver
      C> {x86_64-suse-linux-gnu-perfclient:pid(25484):tid(0x7f9b869c62c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f9b869b1440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25484):tid(0x7f9b869c62c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f9b869b1440):statistics                    }:                 --send-nothing :   543397.0 [  2173706 / 4.000217   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25484):tid(0x7f9b869c62c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f9b869b1440):PerfClientExec                }: end: ----------------------------------------
  > feature=cs_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ /usr/bin/mono .../perf-release/inst/share/NHI1/perfserver.exe
      C> {x86_64-suse-linux-gnu-perfclient:pid(25501):tid(0x7fc1251932c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fc12517e440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25501):tid(0x7fc1251932c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fc12517e440):statistics                    }:                 --send-nothing :   429123.1 [  1716758 / 4.000619   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25501):tid(0x7fc1251932c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fc12517e440):PerfClientExec                }: end: ----------------------------------------
  > feature=jv_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ /usr/bin/java -jar .../perf-release/inst/share/NHI1/perfserver.jar
      C> {x86_64-suse-linux-gnu-perfclient:pid(25520):tid(0x7f554c7812c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f554c76c440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25520):tid(0x7f554c7812c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f554c76c440):statistics                    }:                 --send-nothing :   472206.4 [  1888940 / 4.000242   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25520):tid(0x7f554c7812c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f554c76c440):PerfClientExec                }: end: ----------------------------------------
  > feature=py_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ /home/dev1usr/ext/x86_64-suse-linux-gnu/release/bin/python3 .../perf-release/inst/sbin/py/x86_64-suse-linux-gnu-perfserver.py
      C> {x86_64-suse-linux-gnu-perfclient:pid(25556):tid(0x7f778c57b2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f778c566440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25556):tid(0x7f778c57b2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f778c566440):statistics                    }:                 --send-nothing :   499006.3 [  1996153 / 4.000256   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25556):tid(0x7f778c57b2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f778c566440):PerfClientExec                }: end: ----------------------------------------
  > feature=rb_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ /home/dev1usr/ext/x86_64-suse-linux-gnu/release/bin/ruby .../perf-release/inst/sbin/rb/x86_64-suse-linux-gnu-perfserver.rb
      C> {x86_64-suse-linux-gnu-perfclient:pid(25575):tid(0x7f6a98ed12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f6a98ebc440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25575):tid(0x7f6a98ed12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f6a98ebc440):statistics                    }:                 --send-nothing :   471033.9 [  1884287 / 4.000321   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25575):tid(0x7f6a98ed12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f6a98ebc440):PerfClientExec                }: end: ----------------------------------------
  > feature=tcl_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ /home/dev1usr/ext/x86_64-suse-linux-gnu/release/bin/tclsh8.6 .../perf-release/inst/sbin/tcl/x86_64-suse-linux-gnu-perfserver.tcl
      C> {x86_64-suse-linux-gnu-perfclient:pid(25593):tid(0x7f516b7f02c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f516b7db440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25593):tid(0x7f516b7f02c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f516b7db440):statistics                    }:                 --send-nothing :   414436.1 [  1657972 / 4.000549   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25593):tid(0x7f516b7f02c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f516b7db440):PerfClientExec                }: end: ----------------------------------------
 
analysis
  1. Java code is 5% faster than C#
  2. C# and Java are slower than open-source C, C++ and Python
  3. The reason why Java is 5% faster than C# is the API connection. Java has a C connection and C# does not.

call an MkBufferListC callback from C

INDEX - perftest: --bfl

JV code
class BFLT implements MqServiceIF {
public void Callback(MqContextC ctx) {
MkBufferListC bfl = MkBufferListC.CreateTLS("perfserver-BFLT" );
while (ReadItemExists()) {
bfl.AppendBUF(ReadBUF());
}
SendSTART();
var size = bfl.Size();
for (int i=0; i<size; i++) {
SendBUF(bfl.IndexGet(i));
};
SendRETURN();
}
}
In the entire test cycle, no new objects are created. MkBufferListCreateTLS creates the MkBufferListC as thread-local and always returns the pale object with the identifier "perfserver-BFLT". This applies not only to the bfl but also to the MkBufferC contained therein, which are retrieved with MkBufferListIndexGet.
JV result
 call: 'NHI1_HOME/performance/performance.bash' 'pr' '--bfl' '--sec' '4' '_pipe'


setup=perf-release
  > feature=cc_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ .../perf-release/inst/sbin/cc/x86_64-suse-linux-gnu-perfserver
      C> {x86_64-suse-linux-gnu-perfclient:pid(25656):tid(0x7f47b64432c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f47b642e440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25656):tid(0x7f47b64432c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f47b642e440):statistics                    }:                          --bfl :    73475.1 [   293901 / 4.000010   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25656):tid(0x7f47b64432c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f47b642e440):PerfClientExec                }: end: ----------------------------------------
  > feature=c_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfserver
      C> {x86_64-suse-linux-gnu-perfclient:pid(25671):tid(0x7f88486352c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8848620440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25671):tid(0x7f88486352c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8848620440):statistics                    }:                          --bfl :    86672.4 [   346690 / 4.000003   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25671):tid(0x7f88486352c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8848620440):PerfClientExec                }: end: ----------------------------------------
  > feature=cs_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ /usr/bin/mono .../perf-release/inst/share/NHI1/perfserver.exe
      C> {x86_64-suse-linux-gnu-perfclient:pid(25688):tid(0x7f515e38d2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f515e378440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25688):tid(0x7f515e38d2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f515e378440):statistics                    }:                          --bfl :    59200.3 [   236802 / 4.000014   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25688):tid(0x7f515e38d2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f515e378440):PerfClientExec                }: end: ----------------------------------------
  > feature=jv_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ /usr/bin/java -jar .../perf-release/inst/share/NHI1/perfserver.jar
      C> {x86_64-suse-linux-gnu-perfclient:pid(25707):tid(0x7fac513c12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fac513ac440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25707):tid(0x7fac513c12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fac513ac440):statistics                    }:                          --bfl :    72401.4 [   289606 / 4.000003   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25707):tid(0x7fac513c12c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fac513ac440):PerfClientExec                }: end: ----------------------------------------
  > feature=py_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ /home/dev1usr/ext/x86_64-suse-linux-gnu/release/bin/python3 .../perf-release/inst/sbin/py/x86_64-suse-linux-gnu-perfserver.py
      C> {x86_64-suse-linux-gnu-perfclient:pid(25742):tid(0x7f56411152c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f5641100440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25742):tid(0x7f56411152c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f5641100440):statistics                    }:                          --bfl :    64534.5 [   258138 / 4.000003   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25742):tid(0x7f56411152c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f5641100440):PerfClientExec                }: end: ----------------------------------------
  > feature=rb_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ /home/dev1usr/ext/x86_64-suse-linux-gnu/release/bin/ruby .../perf-release/inst/sbin/rb/x86_64-suse-linux-gnu-perfserver.rb
      C> {x86_64-suse-linux-gnu-perfclient:pid(25759):tid(0x7f09c72062c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f09c71f1440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25759):tid(0x7f09c72062c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f09c71f1440):statistics                    }:                          --bfl :    66952.9 [   267812 / 4.000003   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25759):tid(0x7f09c72062c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f09c71f1440):PerfClientExec                }: end: ----------------------------------------
  > feature=tcl_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ /home/dev1usr/ext/x86_64-suse-linux-gnu/release/bin/tclsh8.6 .../perf-release/inst/sbin/tcl/x86_64-suse-linux-gnu-perfserver.tcl
      C> {x86_64-suse-linux-gnu-perfclient:pid(25777):tid(0x7f2e9d33b2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f2e9d326440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25777):tid(0x7f2e9d33b2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f2e9d326440):statistics                    }:                          --bfl :    45807.1 [   183229 / 4.000013   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25777):tid(0x7f2e9d33b2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f2e9d326440):PerfClientExec                }: end: ----------------------------------------
 
analysis
  1. C# is significantly slower than its competitors, special Java is 20% faster than C#

compare CS versa JV in pipe mode

INDEX - README_PERFORMANCE

results
 call: 'NHI1_HOME/performance/performance.bash' 'pr' '--all-performance' '--sec' '4' '^(cs|jv)_pipe'


setup=perf-release
  > feature=cs_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --all-performance --sec 4 @ /usr/bin/mono .../perf-release/inst/share/NHI1/perfserver.exe
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:                 --send-nothing :   443287.0 [  1773225 / 4.000174   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:                         --send :   271675.3 [  1086758 / 4.000210   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:            --send-and-callback :   154799.1 [   619379 / 4.001178   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:                --send-and-wait :    74855.9 [   299424 / 4.000005   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:                       --parent :       21.7 [       87 / 4.009635   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:                        --child :    16513.6 [    66055 / 4.000048   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:                          --bus :    57408.0 [   229633 / 4.000018   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):statistics                    }:                          --bfl :    60758.7 [   243035 / 4.000000   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(25860):tid(0x7f83524872c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f8352472440):PerfClientExec                }: end: ----------------------------------------
    > mv 'NHI1_BUILD/performance/temp.perf.perf-release.cs_pipe' 'NHI1_HOME/performance/gen/x86_64-suse-linux-gnu/perf-release/cs_pipe.perf'
  > feature=jv_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --all-performance --sec 4 @ /usr/bin/java -jar .../perf-release/inst/share/NHI1/perfserver.jar
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:                 --send-nothing :   476037.0 [  1904387 / 4.000502   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:                         --send :   298682.3 [  1194774 / 4.000150   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:            --send-and-callback :   164119.9 [   656634 / 4.000942   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:                --send-and-wait :    78644.3 [   314578 / 4.000011   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:                       --parent :       21.2 [       85 / 4.000181   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:                        --child :    19651.8 [    78608 / 4.000040   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:                          --bus :    70445.0 [   281780 / 4.000002   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):statistics                    }:                          --bfl :    71173.7 [   284695 / 4.000002   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(26147):tid(0x7fa5393a52c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fa539390440):PerfClientExec                }: end: ----------------------------------------
    > mv 'NHI1_BUILD/performance/temp.perf.perf-release.jv_pipe' 'NHI1_HOME/performance/gen/x86_64-suse-linux-gnu/perf-release/jv_pipe.perf'
 
analysis
  1. Java is clearly faster than C#, only in process-startup C# is a little faster but in the end this hardly makes a difference.

compare parent versa child startup in thread mode

INDEX - README_PERFORMANCE

results
 call: 'NHI1_HOME/performance/performance.bash' 'pr' '--parent' '--child' '--sec' '4' '_uds_thread'


setup=perf-release
  > feature=cc_uds_thread
    > .../perf-release/inst/sbin/cc/x86_64-suse-linux-gnu-perfserver --uds --file ./socket.uds.0 --thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --parent --child --sec 4 --uds --file ./socket.uds.0
      C> {x86_64-suse-linux-gnu-perfclient:pid(28188):tid(0x7f4adc5902c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4adc57b440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(28188):tid(0x7f4adc5902c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4adc57b440):statistics                    }:                       --parent :    10330.5 [    41324 / 4.000177   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(28188):tid(0x7f4adc5902c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4adc57b440):statistics                    }:                        --child :    36505.2 [   146021 / 4.000001   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(28188):tid(0x7f4adc5902c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4adc57b440):PerfClientExec                }: end: ----------------------------------------
  > feature=cs_uds_thread
    > /usr/bin/mono .../perf-release/inst/share/NHI1/perfserver.exe --uds --file ./socket.uds.1 --thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --parent --child --sec 4 --uds --file ./socket.uds.1
      C> {x86_64-suse-linux-gnu-perfclient:pid(69575):tid(0x7f4ef20762c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4ef2061440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(69575):tid(0x7f4ef20762c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4ef2061440):statistics                    }:                       --parent :    11054.7 [    44220 / 4.000118   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(69575):tid(0x7f4ef20762c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4ef2061440):statistics                    }:                        --child :    21754.1 [    87017 / 4.000028   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(69575):tid(0x7f4ef20762c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f4ef2061440):PerfClientExec                }: end: ----------------------------------------
  > feature=c_uds_thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfserver --uds --file ./socket.uds.2 --thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --parent --child --sec 4 --uds --file ./socket.uds.2
      C> {x86_64-suse-linux-gnu-perfclient:pid(69613):tid(0x7fb03340f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fb0333fa440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(69613):tid(0x7fb03340f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fb0333fa440):statistics                    }:                       --parent :    12347.8 [    49393 / 4.000144   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(69613):tid(0x7fb03340f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fb0333fa440):statistics                    }:                        --child :    37620.2 [   150481 / 4.000005   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(69613):tid(0x7fb03340f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7fb0333fa440):PerfClientExec                }: end: ----------------------------------------
  > feature=jv_uds_thread
    > /usr/bin/java -jar .../perf-release/inst/share/NHI1/perfserver.jar --uds --file ./socket.uds.3 --thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --parent --child --sec 4 --uds --file ./socket.uds.3
      C> {x86_64-suse-linux-gnu-perfclient:pid(46228):tid(0x7f78085882c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f7808573440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(46228):tid(0x7f78085882c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f7808573440):statistics                    }:                       --parent :    13961.1 [    55846 / 4.000111   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(46228):tid(0x7f78085882c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f7808573440):statistics                    }:                        --child :    19807.1 [    79229 / 4.000040   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(46228):tid(0x7f78085882c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f7808573440):PerfClientExec                }: end: ----------------------------------------
  > feature=tcl_uds_thread
    > /home/dev1usr/ext/x86_64-suse-linux-gnu/release/bin/tclsh8.6 .../perf-release/inst/sbin/tcl/x86_64-suse-linux-gnu-perfserver.tcl --uds --file ./socket.uds.4 --thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --parent --child --sec 4 --uds --file ./socket.uds.4
      C> {x86_64-suse-linux-gnu-perfclient:pid(46269):tid(0x7f726410f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f72640fa440):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(46269):tid(0x7f726410f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f72640fa440):statistics                    }:                       --parent :       38.5 [      154 / 4.000189   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(46269):tid(0x7f726410f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f72640fa440):statistics                    }:                        --child :    23844.6 [    95379 / 4.000020   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(46269):tid(0x7f726410f2c0):L:dlv(0):ctxId( 0):rc(0):ctx(0x7f72640fa440):PerfClientExec                }: end: ----------------------------------------
 
analysis
  1. The values were determined for a single processor (–wrk 1) environment.
  2. The real performance can be multiplied by the number of physical processors…
    • The maximum achievable number of new sessions (--parent) with thread startup and the new thread-pool functionality is limited by the time for creating a new context (--child).
    • A Xeon E3-1275 V2 with 4 physical processors can therefore process max 150,000 sessions per second.
      • calculation for a C application server: 4 processors x 37,000 ctx/sec = ~150,000 ctx/sec.
  3. C# is significant slower the Java in thread startup even if a thread-pool is used.