Changeset: b12abff3e942 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b12abff3e942
Modified Files:
gdk/shared_memory.c
monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
monetdb5/extras/pyapi/pyapi.c
monetdb5/extras/pyapi/pyapi.h
monetdb5/extras/pyapi/pyapi.mal
Branch: pyapi
Log Message:
Don't use ftok for generating shared memory keys.
diffs (128 lines):
diff --git a/gdk/shared_memory.c b/gdk/shared_memory.c
--- a/gdk/shared_memory.c
+++ b/gdk/shared_memory.c
@@ -27,8 +27,10 @@ static int shm_unique_id = 1;
static int shm_current_id = 0;
static int shm_max_id = 32;
static int shm_is_initialized = false;
-static char shm_keystring[] = ".";
+static char shm_keystring[] = BINDIR;
static MT_Lock release_memory_lock;
+static key_t base_key = 800000000;
+
str init_shared_memory(int id, size_t size, void **ptr, int flags);
void store_shared_memory(int memory_id, void *ptr);
@@ -84,7 +86,6 @@ void store_shared_memory(int memory_id,
shm_max_id *= 2;
}
-
shm_memory_ids[shm_current_id] = memory_id;
shm_ptrs[shm_current_id] = ptr;
shm_current_id++;
@@ -110,17 +111,24 @@ str get_shared_memory(int id, size_t siz
return init_shared_memory(id, size, return_ptr, 0);
}
+str ftok_enhanced(int id, key_t *return_key);
+str ftok_enhanced(int id, key_t *return_key)
+{
+ *return_key = base_key + id;
+ return MAL_SUCCEED;
+}
+
str init_shared_memory(int id, size_t size, void **return_ptr, int flags)
{
int shmid;
void *ptr;
int i;
- int key = ftok(shm_keystring, id);
- if (key == (key_t) -1)
+ key_t key;
+
+ str msg = ftok_enhanced(id, &key);
+ if (msg != MAL_SUCCEED)
{
- char *err = strerror(errno);
- errno = 0;
- return createException(MAL, "shared_memory.get", "Error calling
ftok(keystring:%s,id:%d): %s", shm_keystring, id, err);
+ return msg;
}
assert(shm_is_initialized);
diff --git a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
--- a/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
+++ b/monetdb5/extras/pyapi/Benchmarks/pyapi_test.sh
@@ -11,7 +11,7 @@ export MSERVERTEST='netstat -ant | grep
# Testing parameters
# Input test (zero copy vs copy)
# The input sizes to test (in MB)
-export INPUT_TESTING_SIZES="0.1 1 10 100 1000"
+export INPUT_TESTING_SIZES="10"
# Amount of tests to run for each size
export INPUT_TESTING_NTESTS=10
@@ -130,6 +130,11 @@ function pyapi_build() {
fi
}
+function pyapi_run_single_test_echo() {
+ echo \$PYAPI_BUILD_DIR/bin/mserver5 --set mapi_port=\$MSERVER_PORT --set
embedded_py=true --set enable_pyverbose=true --set
pyapi_benchmark_output=\$PYAPI_OUTPUT_DIR/temp_output.tsv $2
+ echo python \$PYAPI_TESTFILE $3 $4 $5 \$MSERVER_PORT $6
+}
+
function pyapi_run_single_test() {
echo "Beginning Test $1"
if [ $SETSID -eq 1 ]; then
@@ -155,6 +160,7 @@ function pyapi_run_single_test() {
return 1
}
+
function pyapi_test_input() {
echo "Beginning Input Testing (Copy vs Zero Copy)"
pyapi_run_single_test "Input Testing (Zero Copy)" "" "INPUT"
input_zerocopy "$INPUT_TESTING_NTESTS" "$INPUT_TESTING_SIZES"
diff --git a/monetdb5/extras/pyapi/pyapi.c b/monetdb5/extras/pyapi/pyapi.c
--- a/monetdb5/extras/pyapi/pyapi.c
+++ b/monetdb5/extras/pyapi/pyapi.c
@@ -618,7 +618,9 @@ str PyAPIeval(MalBlkPtr mb, MalStkPtr st
if (descr->bat_size == 0) {
msg = createException(MAL, "pyapi.eval", "Failure in child
process with unknown error.");
} else {
+ MT_lock_set(&pyapiLock, "pyapi.evaluate");
msg = get_shared_memory(shm_id + 1, descr->bat_size,
(void**) &err_ptr);
+ MT_lock_unset(&pyapiLock, "pyapi.evaluate");
if (msg == MAL_SUCCEED)
{
msg = createException(MAL, "pyapi.eval", "%s",
err_ptr);
@@ -1149,7 +1151,6 @@ returnvalues:
VERBOSE_MESSAGE("Cleaning up.\n");
-
// Actual cleanup
// Cleanup input BATs
for (i = pci->retc + 2; i < pci->argc; i++)
diff --git a/monetdb5/extras/pyapi/pyapi.h b/monetdb5/extras/pyapi/pyapi.h
--- a/monetdb5/extras/pyapi/pyapi.h
+++ b/monetdb5/extras/pyapi/pyapi.h
@@ -26,6 +26,7 @@
#define _PYAPI_WARNINGS_
// Enable debug mode, does literally nothing right now, but hey we have this
nice #define here anyway
#define _PYAPI_DEBUG_
+ #define _PYAPI_TESTING_
#endif
#ifdef _PYAPI_VERBOSE_
diff --git a/monetdb5/extras/pyapi/pyapi.mal b/monetdb5/extras/pyapi/pyapi.mal
--- a/monetdb5/extras/pyapi/pyapi.mal
+++ b/monetdb5/extras/pyapi/pyapi.mal
@@ -29,7 +29,6 @@ comment "grouped aggregates through Pyth
command prelude() :void address PyAPIprelude;
pyapi.prelude();
-
# The SQL compiler needs these functions for bat-wise operations
module batpyapi;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list