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 MqLalS MqLal
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_META(ctx);
goto error;
}
idP->type = MK_ID_THREAD;
idP->val = (MK_IDNT) (*env)->NewWeakGlobalRef(env,runnableO);
idP->setByExtern = true;
} else {
(*env)->CallStaticObjectMethod(env, MQ(Class_MqMsgque), MQ(MID_Thread_Work_callback), (jlong) argP);
if((*env)->ExceptionCheck(env) == JNI_TRUE) {
OT_ERROR_LNG_2_META(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();
}
}
}
);
}
private void WaitForThreadPipe (Future<Object> fut) {
try {
fut.get(200,TimeUnit.MILLISECONDS);
} catch (Exception e) {
// ignore
}
}
// [OVERLOAD THREAD]
C - MqContextC setup
void NS(MqContextC_Init)(MQ_RT_ARGS_ONLY) {
#define MQ_RT_ARGS_ONLY
ClassInit
// define type
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
static int sThreadExit (MK_RT_ARGS int exitnum)
{
#ifndef META_THREAD_POOL
(*MK(cached_jvm))->DetachCurrentThread(MK(cached_jvm));
#endif // META_THREAD_POOL
return exitnum;
}
static int sProcessExit (MK_RT_ARGS int exitnum)
{
SETUP_env;
(*env)->CallStaticVoidMethod(env, NS(Class_System), NS(MID_System_exit), (jint) exitnum);
error:
return exitnum;
}
static bool sWaitForPipe (MK_RT_ARGS MQ_CTX const ctx, const struct MkIdS *idP ) {
bool retB = false;
switch ((*idP).type) {
case MK_ID_THREAD: {
if ((*idP).setByExtern) {
JNIEnv *env = GET_env_X(ctx);
if (env == NULL) MK(GetJniEnv)(MK_RT_CALL &env);
if (env) {
jobject futureO = (jobject) (*idP).val ;
if (!(*env)->IsSameObject(env,futureO, NULL)) {
(*env)->CallVoidMethod(env, futureO, MQ(MID_Thread_wait));
retB = true;
}
(*env)->DeleteWeakGlobalRef(env,futureO);
}
}
break;
}
case MK_ID_UNUSED: break;
}
return retB;
}

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=atl_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ NHI1_EXT/x86_64-suse-linux-gnu/release/bin/tclsh8.5 .../perf-release/inst/sbin/atl/x86_64-suse-linux-gnu-perfserver.atl
      C> {x86_64-suse-linux-gnu-perfclient:pid(29708):tid(0x7f90211fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f90211e8c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29708):tid(0x7f90211fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f90211e8c20):statistics                    }:                 --send-nothing :   416208.0 [  1665048 / 4.000519   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29708):tid(0x7f90211fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f90211e8c20):PerfClientExec                }: end: ----------------------------------------
  > 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(29724):tid(0x7f6a328debc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f6a328c9c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29724):tid(0x7f6a328debc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f6a328c9c20):statistics                    }:                 --send-nothing :   475066.7 [  1900355 / 4.000186   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29724):tid(0x7f6a328debc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f6a328c9c20):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(29740):tid(0x7f8cc4984bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f8cc496fc20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29740):tid(0x7f8cc4984bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f8cc496fc20):statistics                    }:                 --send-nothing :   459824.7 [  1839448 / 4.000324   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29740):tid(0x7f8cc4984bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f8cc496fc20):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(29763):tid(0x7f94957dfbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f94957cac20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29763):tid(0x7f94957dfbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f94957cac20):statistics                    }:                 --send-nothing :   348566.2 [  1394543 / 4.000798   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29763):tid(0x7f94957dfbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f94957cac20):PerfClientExec                }: end: ----------------------------------------
      S> {perfserver          :pid(29764):tid(0x7fd19caf42c0):L:dlv(0):ctxId( 0):rc(2):ctx(0x55767a219b10):MkSelfDeleteForce_RT          }: Warning: HARD RESET with: 0x55767a21e830->self == NULL
  > 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(29784):tid(0x7f9f5ad5abc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f9f5ad45c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29784):tid(0x7f9f5ad5abc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f9f5ad45c20):statistics                    }:                 --send-nothing :   410034.6 [  1640380 / 4.000589   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29784):tid(0x7f9f5ad5abc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f9f5ad45c20):PerfClientExec                }: end: ----------------------------------------
  > feature=py_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ NHI1_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(29821):tid(0x7f83af99ebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f83af989c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29821):tid(0x7f83af99ebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f83af989c20):statistics                    }:                 --send-nothing :   433685.6 [  1734940 / 4.000456   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29821):tid(0x7f83af99ebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f83af989c20):PerfClientExec                }: end: ----------------------------------------
  > feature=rb_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ NHI1_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(29847):tid(0x7f58d83d0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f58d83bbc20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29847):tid(0x7f58d83d0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f58d83bbc20):statistics                    }:                 --send-nothing :   412867.4 [  1651694 / 4.000544   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29847):tid(0x7f58d83d0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f58d83bbc20):PerfClientExec                }: end: ----------------------------------------
  > feature=tcl_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --send-nothing --sec 4 @ NHI1_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(29868):tid(0x7ff59a949bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7ff59a934c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29868):tid(0x7ff59a949bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7ff59a934c20):statistics                    }:                 --send-nothing :   328504.7 [  1314202 / 4.000558   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29868):tid(0x7ff59a949bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7ff59a934c20):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=atl_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ NHI1_EXT/x86_64-suse-linux-gnu/release/bin/tclsh8.5 .../perf-release/inst/sbin/atl/x86_64-suse-linux-gnu-perfserver.atl
      C> {x86_64-suse-linux-gnu-perfclient:pid(29939):tid(0x7f7e96ffdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f7e96fe8c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29939):tid(0x7f7e96ffdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f7e96fe8c20):statistics                    }:                          --bfl :    54978.2 [   219913 / 4.000007   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29939):tid(0x7f7e96ffdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f7e96fe8c20):PerfClientExec                }: end: ----------------------------------------
  > 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(29959):tid(0x7f431ffd0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f431ffbbc20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29959):tid(0x7f431ffd0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f431ffbbc20):statistics                    }:                          --bfl :    75352.4 [   301410 / 4.000005   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29959):tid(0x7f431ffd0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f431ffbbc20):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(29976):tid(0x7f171ca9bbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f171ca86c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29976):tid(0x7f171ca9bbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f171ca86c20):statistics                    }:                          --bfl :    78987.1 [   315949 / 4.000007   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29976):tid(0x7f171ca9bbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f171ca86c20):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(29994):tid(0x7f44d81a6bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f44d8191c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29994):tid(0x7f44d81a6bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f44d8191c20):statistics                    }:                          --bfl :    52223.4 [   208894 / 4.000006   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(29994):tid(0x7f44d81a6bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f44d8191c20):PerfClientExec                }: end: ----------------------------------------
      S> {perfserver          :pid(29995):tid(0x7f5bf931f2c0):L:dlv(0):ctxId( 0):rc(2):ctx(0x5580e380d3a0):MkSelfDeleteForce_RT          }: Warning: HARD RESET with: 0x5580e38120c0->self == NULL
  > 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(30014):tid(0x7ff5e5dc2bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7ff5e5dadc20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30014):tid(0x7ff5e5dc2bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7ff5e5dadc20):statistics                    }:                          --bfl :    61637.3 [   246550 / 4.000015   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30014):tid(0x7ff5e5dc2bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7ff5e5dadc20):PerfClientExec                }: end: ----------------------------------------
  > feature=py_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ NHI1_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(30052):tid(0x7fcf21591bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcf2157cc20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30052):tid(0x7fcf21591bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcf2157cc20):statistics                    }:                          --bfl :    57814.8 [   231260 / 4.000015   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30052):tid(0x7fcf21591bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcf2157cc20):PerfClientExec                }: end: ----------------------------------------
  > feature=rb_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ NHI1_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(30070):tid(0x7f5dd4e95bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f5dd4e80c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30070):tid(0x7f5dd4e95bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f5dd4e80c20):statistics                    }:                          --bfl :    61243.5 [   244975 / 4.000015   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30070):tid(0x7f5dd4e95bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f5dd4e80c20):PerfClientExec                }: end: ----------------------------------------
  > feature=tcl_pipe
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --bfl --sec 4 @ NHI1_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(30099):tid(0x7f96165d0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f96165bbc20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30099):tid(0x7f96165d0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f96165bbc20):statistics                    }:                          --bfl :    38639.9 [   154560 / 4.000012   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30099):tid(0x7f96165d0bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f96165bbc20):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(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:                 --send-nothing :   377713.3 [  1511108 / 4.000674   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:                         --send :   110658.9 [   442651 / 4.000138   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:            --send-and-callback :   125465.2 [   501947 / 4.000687   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:                --send-and-wait :    60181.0 [   240725 / 4.000015   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:                       --parent :       21.0 [       84 / 4.006610   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:                        --child :     2489.4 [     9958 / 4.000088   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:                          --bus :    32599.4 [   130398 / 4.000017   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):statistics                    }:                          --bfl :    34422.2 [   137689 / 4.000001   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30172):tid(0x7f920d1fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f920d1e8c20):PerfClientExec                }: end: ----------------------------------------
      S> {perfserver          :pid(30173):tid(0x7f8f94f6f2c0):L:dlv(0):ctxId( 0):rc(2):ctx(0x56175b609080):MkSelfDeleteForce_RT          }: Warning: HARD RESET with: 0x56175b60dda0->self == NULL
    > mv 'NHI1_BUILD/x86_64-suse-linux-gnu/debug2/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(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:                 --send-nothing :   410596.2 [  1642623 / 4.000580   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:                         --send :   264756.0 [  1059216 / 4.000726   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:            --send-and-callback :   145140.5 [   580669 / 4.000737   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:                --send-and-wait :    64445.8 [   257784 / 4.000014   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:                       --parent :       15.5 [       62 / 4.000201   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:                        --child :     2395.6 [     9584 / 4.000714   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:                          --bus :    33995.9 [   135984 / 4.000010   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):statistics                    }:                          --bfl :    37542.9 [   150177 / 4.000148   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(30460):tid(0x7fcac67fdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fcac67e8c20):PerfClientExec                }: end: ----------------------------------------
    > mv 'NHI1_BUILD/x86_64-suse-linux-gnu/debug2/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=atl_uds_thread
    > NHI1_EXT/x86_64-suse-linux-gnu/release/bin/tclsh8.5 .../perf-release/inst/sbin/atl/x86_64-suse-linux-gnu-perfserver.atl --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(31697):tid(0x7f62f87cebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f62f87b9c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(31697):tid(0x7f62f87cebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f62f87b9c20):statistics                    }:                       --parent :       39.5 [      158 / 4.000162   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(31697):tid(0x7f62f87cebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f62f87b9c20):statistics                    }:                        --child :     2312.1 [     9250 / 4.000640   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(31697):tid(0x7f62f87cebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f62f87b9c20):PerfClientExec                }: end: ----------------------------------------
  > feature=cc_uds_thread
    > .../perf-release/inst/sbin/cc/x86_64-suse-linux-gnu-perfserver --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(31893):tid(0x7f32a2ccebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f32a2cb9c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(31893):tid(0x7f32a2ccebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f32a2cb9c20):statistics                    }:                       --parent :     8472.2 [    33890 / 4.000126   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(31893):tid(0x7f32a2ccebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f32a2cb9c20):statistics                    }:                        --child :     2372.9 [     9493 / 4.000642   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(31893):tid(0x7f32a2ccebc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f32a2cb9c20):PerfClientExec                }: end: ----------------------------------------
  > feature=cs_uds_thread
    > /usr/bin/mono .../perf-release/inst/share/NHI1/perfserver.exe --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(67019):tid(0x7f6931ffdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f6931fe8c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(67019):tid(0x7f6931ffdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f6931fe8c20):statistics                    }:                       --parent :     8463.0 [    33853 / 4.000125   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(67019):tid(0x7f6931ffdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f6931fe8c20):statistics                    }:                        --child :     2571.7 [    10288 / 4.000390   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(67019):tid(0x7f6931ffdbc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f6931fe8c20):PerfClientExec                }: end: ----------------------------------------
  > feature=c_uds_thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfserver --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(67059):tid(0x7fa6d9f88bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fa6d9f73c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(67059):tid(0x7fa6d9f88bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fa6d9f73c20):statistics                    }:                       --parent :    10575.7 [    42304 / 4.000123   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(67059):tid(0x7fa6d9f88bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fa6d9f73c20):statistics                    }:                        --child :     2644.6 [    10579 / 4.000181   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(67059):tid(0x7fa6d9f88bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fa6d9f73c20):PerfClientExec                }: end: ----------------------------------------
  > feature=jv_uds_thread
    > /usr/bin/java -jar .../perf-release/inst/share/NHI1/perfserver.jar --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(36847):tid(0x7f24792e8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f24792d3c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(36847):tid(0x7f24792e8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f24792d3c20):statistics                    }:                       --parent :    10884.9 [    43541 / 4.000115   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(36847):tid(0x7f24792e8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f24792d3c20):statistics                    }:                        --child :     2380.7 [     9524 / 4.000515   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(36847):tid(0x7f24792e8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7f24792d3c20):PerfClientExec                }: end: ----------------------------------------
  > feature=tcl_uds_thread
    > NHI1_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.5 --thread
    > .../perf-release/inst/sbin/c/x86_64-suse-linux-gnu-perfclient --timeout 2 --parent --child --sec 4 --uds --file ./socket.uds.5
      C> {x86_64-suse-linux-gnu-perfclient:pid(36886):tid(0x7fe493dd8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fe493dc3c20):PerfClientExec                }: start ------------------------ :     result [    count / sec        ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(36886):tid(0x7fe493dd8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fe493dc3c20):statistics                    }:                       --parent :       36.7 [      147 / 4.000161   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(36886):tid(0x7fe493dd8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fe493dc3c20):statistics                    }:                        --child :     2328.6 [     9315 / 4.000272   ]
      C> {x86_64-suse-linux-gnu-perfclient:pid(36886):tid(0x7fe493dd8bc0):L:dlv(0):ctxId( 0):rc(1):ctx(0x7fe493dc3c20):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.