Usenet comp.unix.osf.misc (1992-2004)
 help / color / mirror / Atom feed
* poor DCE RPC performance
@ 1994-10-25  6:54 Mr Mike James Lijewski
  1994-10-26  0:31 ` Mr Mike James Lijewski
  1994-11-03 10:04 ` Elliot Jaffe
  0 siblings, 2 replies; 3+ messages in thread
From: Mr Mike James Lijewski @ 1994-10-25  6:54 UTC (permalink / raw)



Appended is a shar file of a simple DCE RPC application.  It exhibits
what I consider very poor performance when both client and server are
run on the same machine.  If I run one server and three clients on a
four processor DEC Alpha 2100/500 I only see about 800 RPCs/second.
This is no higher than if I run the server on the 2100/500 and a
client on each of three separate workstations.  It would appear that
the RPC runtime together with the networking code in the kernel is
the bottleneck.  Anyone care to comment?



# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by bs928186 on Tue Oct 25 14:21:23 HKT 1994
# Contents:  Makefile nRPC.idl nRPC.acf server.c client.c
 
echo x - Makefile
sed 's/^@//' > "Makefile" <<'@//E*O*F Makefile//'
IDL = /bin/idl

CC = cc

CFLAGS = -I.  -O

LIBS = -ldce -lpthreads -lc_r -lmach -lm

default: nRPC nRPCd

nRPC: client.o nRPC_cstub.o
	cc $(CFLAGS) -o nRPC client.o nRPC_cstub.o $(LIBS)

nRPCd: server.o nRPC_sstub.o
	cc $(CFLAGS) -o nRPCd server.o nRPC_sstub.o $(LIBS)

clean:
	rm -f nRPC nRPCd *.o nRPC_*stub.c *.h *.dat

client.o server.o : nRPC.h

nRPC_cstub.c nRPC_sstub.c nRPC.h : nRPC.idl
	$(IDL) -keep both nRPC.idl

nRPC.idl: nRPC.acf

shar:
	shar Makefile nRPC.idl nRPC.acf server.c client.c > nRPC.shar
@//E*O*F Makefile//
chmod u=r,g=r,o=r Makefile
 
echo x - nRPC.idl
sed 's/^@//' > "nRPC.idl" <<'@//E*O*F nRPC.idl//'
[
uuid(f9f6be80-2ba7-11c9-89fd-08002b13d56d),
version(1)
]

interface nRPC
{

    const long DIM = 1400;

    void vector_sum
    (
        [in]  handle_t                                          binding_handle,
        [in]  long                                              first,
        [in]  long                                              length,
        [in,  first_is(first), length_is(length)] unsigned char array[DIM],
        [out] unsigned char*                                    sum,
        [out] error_status_t*                                   status
    );

}
@//E*O*F nRPC.idl//
chmod u=r,g=r,o=r nRPC.idl
 
echo x - nRPC.acf
sed 's/^@//' > "nRPC.acf" <<'@//E*O*F nRPC.acf//'
interface nRPC
{

    vector_sum
    (
        [comm_status, fault_status] status
    );

}
@//E*O*F nRPC.acf//
chmod u=r,g=r,o=r nRPC.acf
 
echo x - server.c
sed 's/^@//' > "server.c" <<'@//E*O*F server.c//'
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <dce/rpc.h>
#include <dce/dce_error.h>

#include "nRPC.h"

static unsigned long   nRPC;     /* Number of RPCs */

static pthread_mutex_t nRPC_MT;  /* Mutex on nRPC  */

void vector_sum (handle_t client_handle, idl_long_int first,
                 idl_long_int length, idl_char* array,
                 idl_char* sum, error_status_t* status)
{
    *sum = array[first] + array[first+length-1];

    if (pthread_mutex_lock (&nRPC_MT) < 0)
        perror("pthread_mutex_lock"), exit(1);

    nRPC++; /* Update RPC counter. */

    if (pthread_mutex_unlock (&nRPC_MT) < 0)
        perror("pthread_mutex_unlock"), exit(1);
}

static void report_dce_error (unsigned long status)
{
    int  error_status;
    char error_text[dce_c_error_string_len];
    dce_error_inq_text (status, error_text, &error_status);
    if (error_status != -1)
        (void) printf(">>> rpc runtime error: %s.\n", error_text);
    else
        (void) printf(">>> rpc runtime error: no error text translation.\n");
    exit (EXIT_FAILURE);
}

static void* rpc_counter (pthread_addr_t ignore)
{
    const int Seconds = 5;    /* Output RPC rate every five seconds */

    struct timespec interval; 

    interval.tv_sec  = 5L, interval.tv_nsec = 0L;

    for (;;)
    { 
        if (pthread_mutex_lock (&nRPC_MT) < 0)
            perror("pthread_mutex_lock"), exit(1);

        (void) printf ("*** RPC rate = %lu per second.\n", nRPC/Seconds);

        nRPC = 0;
        
        if (pthread_mutex_unlock (&nRPC_MT) < 0)
            perror("pthread_mutex_unlock"), exit(1);

        if (pthread_delay_np (&interval))
            perror("pthread_delay_np"), exit(1);
    }

    return 0;
}

static void* sigint_handler (pthread_addr_t ignore)
{
    sigset_t set;
    if (sigemptyset(&set) < 0)
        perror("sigemptyset"), exit(1);
    if (sigaddset(&set, SIGINT) < 0)
        perror("sigemptyset"), exit(1);
    if (sigwait(&set) < 0)
        perror("sigwait"), exit(1);
    (void) fprintf(stderr, "caught a SIGINT, exiting ...\n");
    exit(1);
}

int main ()
{
    unsigned32             status = 0;
    unsigned_char_t*       string_binding;
    rpc_binding_vector_p_t binding_vector;
    FILE*                  binding;
    pthread_t              counterID, sigintID;
    int                    i = 0, listen_count = 10;
    /*
    ** Set up transfer rate counter thread.
    */
    if (pthread_mutex_init (&nRPC_MT, pthread_mutexattr_default) < 0)
        perror("pthread_mutex_init"), exit(1);

    if (pthread_create(&counterID, pthread_attr_default, rpc_counter, 0) < 0)
        perror("pthread_create"), exit(1);
    /*
    ** Set up SIGINT handler thread.
    */
    if (pthread_create(&sigintID, pthread_attr_default, sigint_handler, 0) < 0)
        perror("pthread_create"), exit(1);
    /*
    ** Tell the server to use all available protocol sequences.
    */
    rpc_server_use_all_protseqs (rpc_c_protseq_max_reqs_default, &status);
    if (!(status == rpc_s_ok))
        (void) printf("No available protocol sequences.\n"),
        report_dce_error(status);
    /*
    ** Register the server interface.
    */
    rpc_server_register_if (nRPC_v1_0_s_ifspec, NULL, NULL, &status);
    if (!(status == rpc_s_ok))
        (void) printf ("Can't register interface.\n"),
        report_dce_error (status);
    /*
    ** Find out what binding information is actually available.
    */
    rpc_server_inq_bindings (&binding_vector, &status);
    if (!(status == rpc_s_ok))
        (void) printf ("Can't inquire binding information.\n"),
        report_dce_error (status);
    /*
    ** Walk the binding vector and output the information.
    */
    for (i = 0; i < binding_vector->count; i++)
    {
        unsigned_char_t *uuid, *protseq, *netaddr, *endpoint, *netopt;

        rpc_binding_to_string_binding (binding_vector->binding_h[i],
                                       &string_binding, &status);
        if (!(status == rpc_s_ok))
            (void) printf ("Can't get string binding\n"),
            report_dce_error(status);

        rpc_string_binding_parse (string_binding, &uuid, &protseq, &netaddr,
                                  &endpoint, &netopt, &status);
        if (!(status == rpc_s_ok))
            (void) printf ("Can't parse string binding\n"),
            report_dce_error (status);

        rpc_string_free (&string_binding, &status);
        if (!(status == rpc_s_ok))
            (void) printf ("Can't free string binding.\n"),
            report_dce_error (status);

        printf("%s %s %s\n", (char*)protseq, (char*)netaddr, (char*)endpoint);
    }
    /*
    ** Wait for incoming client requests.
    **
    ** Default maximum is `rpc_c_listen_max_calls_default'.
    **/
    (void) printf("Listen count = %d\n", listen_count);
    
    rpc_server_listen (listen_count, &status);
    if (!(status == rpc_s_ok))
        (void) printf ("Abnormal termination of server listener.\n"),
        report_dce_error (status);
}
@//E*O*F server.c//
chmod u=r,g=r,o=r server.c
 
echo x - client.c
sed 's/^@//' > "client.c" <<'@//E*O*F client.c//'
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <dce/dce_error.h>

#include "nRPC.h"

static void report_dce_error (unsigned long status)
{
    int  error_status;
    char error_text[dce_c_error_string_len];
    dce_error_inq_text (status, error_text, &error_status);
    if (error_status != -1)
        (void) printf(">>> rpc runtime error: %s.\n", error_text);
    else
        (void) printf(">>> rpc runtime error: no error text translation.\n");
    exit (EXIT_FAILURE);
}

int main (int argc, char* argv[])
{
    rpc_binding_handle_t binding_handle = NULL;
    unsigned_char_t*     string_binding;
    char*                server_name = "/.:/test1_server";
    idl_char             array[DIM];
    idl_long_int         first = 0, length = 0;
    unsigned32           status = 0;
    int                  failures = 0, k = 0;

    if (argc < 4)
        printf("usage: test1 <protseq> <netaddr> <endpoint>\n"), exit(1);

    srandom(13); /* Use same random seed for repeatability. */
    
    /*
    ** Compose a string binding from the command arguments.
    */
    rpc_string_binding_compose(NULL, (unsigned_char_t *) argv[1],
                               (unsigned_char_t *) argv[2],
                               (unsigned_char_t *) argv[3],
                               NULL, &string_binding, &status);
    if (!(status == rpc_s_ok))
        (void) printf("Can't compose string binding.\n"),
        report_dce_error(status);
    /*
    ** Convert the string binding to a binding handle.
    */
    rpc_binding_from_string_binding(string_binding, &binding_handle, &status);
    if (!(status == rpc_s_ok))
        (void) printf("*** Can't convert string binding to binding handle.\n"),
        report_dce_error(status);
    /*
    ** Initialize array to all ones.
    */
    for (k = 0; k < DIM; k++)
        array[k] = 1;
    /*
    ** Pass between 100 and DIM-1 bytes in array each time.
    */
    for (;;)
    {
        const int Count = 10;
        idl_long_int i = 0;
        idl_char sum = 0;
        error_status_t status;
        length = 100 + random()%(DIM-100);
        for (i = 0; i < Count; i++)
        {
            vector_sum(binding_handle, first, length, array, &sum, &status);
            if (!(status == rpc_s_ok))
                (void) printf("rpc1 failed.\n"), report_dce_error(status);
            if (!(sum == 2))
                (void) printf("sum != 2\n"), failures++;
        }
    }
    return 0;
}
@//E*O*F client.c//
chmod u=r,g=r,o=r client.c
 
exit 0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1994-11-03 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-10-25  6:54 poor DCE RPC performance Mr Mike James Lijewski
1994-10-26  0:31 ` Mr Mike James Lijewski
1994-11-03 10:04 ` Elliot Jaffe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox