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

New functionality to allow a pathway for writes with minimal overhead. #133

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ntdavidson
Copy link

Hi,

I've added a new function to allow developers to bypass the not insignificant overheads of (for example) using mongo_batch_insert and have a more direct path to mongo_env_write_socket. This, if used, can make significant savings in overhead by avoiding redundant calls such as memcpy and various other checks.

update: added a new commit with a test for mongo_fast_with_write_concern() and updated the benchmark to provide a comparison between mongo_batch_insert() and mongo_fast_with_write_concern().

Results on my system as follows; I expect with properly tuned network settings the results should be improved further.

serialize_small_test 8,051,529.790660
serialize_medium_test 2,258,355.916893
serialize_large_test 45,062.095568

serialize_small_test_fast 80,645,161.290323
serialize_medium_test_fast 48,076,923.076923
serialize_large_test_fast 124,134.164205

batch_insert_small_test_fast 155,593.589544
batch_insert_medium_test_fast 39,410.109481
batch_insert_large_test_fast 10,624.237711

batch_insert_small_test 34,433.838822
batch_insert_medium_test 47,975.436576
batch_insert_large_test 8,638.025278

@ntdavidson
Copy link
Author

make test
sh runtests.sh
./test_unix_socket
./test_examples
0 : 3
name : 2 John Coltrane: Impressions
price : 16 1099

    1 : 3    
            name : 2         Larry Young: Unity
            price : 16       1199

./test_gridfs
./test_cpp
./test_sizes
./test_bson_alloc
./test_oid
./test_count_delete
./test_resize
./test_fast
./test_auth
./test_env_posix
./test_connect
./test_bson_subobject
./test_bcon
./test_update
./test_write_concern
./test_endian_swap
./test_simple
./test_cursors
./test_bson
d : 1 3.140000
s : 2 hello
s_n : 2 goodbye
o : 3
a : 4
0 : 5 BSON_BINDATA

    u : 6    BSON_UNDEFINED
    oid : 7          010203040506070809101112
    b : 8    true
    date : 9         72623859790382856
    n : 10   BSON_NULL
    r : 11   BSON_REGEX: ^asdf
    c : 13   BSON_CODE: function(){}
    c_n : 13         BSON_CODE: function(){}
    symbol : 14      SYMBOL: symbol
    symbol_n : 14    SYMBOL: symbol
    cws : 15         BSON_CODE_W_SCOPE: function(){return i}
     SCOPE:         i : 16   123

    timestamp : 17   i: 1, t: 2
    l : 18   1234605616436508552

sizeof(time_t) is 8

./test_helpers
v : 16 1
key : 3
foo : 16 -1

    unique : 8       true
    ns : 2   test.bar
    name : 2         foo_-1
    sparse : 8       true

./test_errors
./test_commands
./test_functions
Test printf 0
Test fprintf 0
Test sprintf 0
./test_validate

@ntdavidson
Copy link
Author

scons test
scons: Reading SConscript files ...
Compiling for amd64
Checking for C library json... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
gcc -o test/fast_test.o -c -std=c99 -pedantic -Wall -ggdb -DMONGO_HAVE_STDINT -D_POSIX_SOURCE -D_DARWIN_C_SOURCE -O3 -DMONGO_DLL_BUILD -DTEST_SERVER="127.0.0.1" -DSEED_START_PORT=30000 -Isrc test/fast_test.c
gcc -o test_fast test/fast_test.o -L. libmongoc.a libbson.a
/mnt/mongo-c-driver/test_write_concern 2> /dev/null
/mnt/mongo-c-driver/test_commands 2> /dev/null
/mnt/mongo-c-driver/test_sizes 2> /dev/null
/mnt/mongo-c-driver/test_resize 2> /dev/null
/mnt/mongo-c-driver/test_endian_swap 2> /dev/null
/mnt/mongo-c-driver/test_bson_alloc 2> /dev/null
/mnt/mongo-c-driver/test_bson 2> /dev/null
d : 1 3.140000
s : 2 hello
s_n : 2 goodbye
o : 3
a : 4
0 : 5 BSON_BINDATA

    u : 6    BSON_UNDEFINED
    oid : 7          010203040506070809101112
    b : 8    true
    date : 9         72623859790382856
    n : 10   BSON_NULL
    r : 11   BSON_REGEX: ^asdf
    c : 13   BSON_CODE: function(){}
    c_n : 13         BSON_CODE: function(){}
    symbol : 14      SYMBOL: symbol
    symbol_n : 14    SYMBOL: symbol
    cws : 15         BSON_CODE_W_SCOPE: function(){return i}
     SCOPE:         i : 16   123

    timestamp : 17   i: 1, t: 2
    l : 18   1234605616436508552

sizeof(time_t) is 8

/mnt/mongo-c-driver/test_bson_subobject 2> /dev/null
/mnt/mongo-c-driver/test_simple 2> /dev/null
/mnt/mongo-c-driver/test_update 2> /dev/null
/mnt/mongo-c-driver/test_errors 2> /dev/null
/mnt/mongo-c-driver/test_count_delete 2> /dev/null
/mnt/mongo-c-driver/test_auth 2> /dev/null
/mnt/mongo-c-driver/test_gridfs 2> /dev/null
/mnt/mongo-c-driver/test_validate 2> /dev/null
/mnt/mongo-c-driver/test_examples 2> /dev/null
0 : 3
name : 2 John Coltrane: Impressions
price : 16 1099

    1 : 3    
            name : 2         Larry Young: Unity
            price : 16       1199

/mnt/mongo-c-driver/test_helpers 2> /dev/null
v : 16 1
key : 3
foo : 16 -1

    unique : 8       true
    ns : 2   test.bar
    name : 2         foo_-1
    sparse : 8       true

/mnt/mongo-c-driver/test_oid 2> /dev/null
/mnt/mongo-c-driver/test_functions 2> /dev/null
Test printf 0
Test fprintf 0
Test sprintf 0
/mnt/mongo-c-driver/test_cursors 2> /dev/null
/mnt/mongo-c-driver/test_fast 2> /dev/null
/mnt/mongo-c-driver/test_bcon 2> /dev/null
/mnt/mongo-c-driver/test_env_posix 2> /dev/null
/mnt/mongo-c-driver/test_unix_socket 2> /dev/null
/mnt/mongo-c-driver/test_cpp 2> /dev/null
scons: done building targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant