Add perf test for spawn+wait4

This commit is contained in:
Tate, Hongliang Tian 2019-01-08 21:23:41 +08:00
parent 71d119181e
commit d1731162eb
7 changed files with 56 additions and 2 deletions

@ -462,7 +462,9 @@ pub extern "C" fn occlum_exit(status: i32)
#[no_mangle] #[no_mangle]
pub extern "C" fn occlum_unknown(num: u32) pub extern "C" fn occlum_unknown(num: u32)
{ {
println!("[WARNING] Unknown syscall (num = {})", num); if cfg!(debug_assertions) {
//println!("[WARNING] Unknown syscall (num = {})", num);
}
} }
#[no_mangle] #[no_mangle]

@ -1,5 +1,7 @@
use super::*; use super::*;
// TODO: examine the ProcessVM code for memory leakage
lazy_static! { lazy_static! {
static ref DATA_SPACE: SgxMutex<VMSpace> = { static ref DATA_SPACE: SgxMutex<VMSpace> = {
let (addr, size) = { let (addr, size) = {

@ -372,9 +372,11 @@ impl PartialEq for VMRange {
impl Drop for VMRange { impl Drop for VMRange {
fn drop(&mut self) { fn drop(&mut self) {
if !self.is_dealloced() { if !self.is_dealloced() {
println!("VMRange::drop::panic1");
panic!("A range must be dealloc'ed before drop"); panic!("A range must be dealloc'ed before drop");
} }
if self.has_subranges() { if self.has_subranges() {
println!("VMRange::drop::panic2");
panic!("All sub-ranges must be removed explicitly before drop"); panic!("All sub-ranges must be removed explicitly before drop");
} }
} }

@ -1,6 +1,6 @@
#include <stddef.h> #include <stddef.h>
#define DATA_SPACE_SIZE (16*1024*1024) #define DATA_SPACE_SIZE (32*1024*1024)
static char __prealloced_data_space[DATA_SPACE_SIZE] static char __prealloced_data_space[DATA_SPACE_SIZE]
__attribute__ (( __attribute__ ((

@ -1,7 +1,14 @@
CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) CUR_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PROJECT_DIR := $(realpath $(CUR_DIR)/../) PROJECT_DIR := $(realpath $(CUR_DIR)/../)
# Whether test performance or not?
PERF = yes
ifeq ($(PERF),no)
TEST_SUITES := empty argv hello_world malloc file getpid spawn pipe time TEST_SUITES := empty argv hello_world malloc file getpid spawn pipe time
else
TEST_SUITES := empty perf_spawn_and_wait4
endif
BUILD_TEST_SUITES := $(TEST_SUITES:%=%) BUILD_TEST_SUITES := $(TEST_SUITES:%=%)
RUN_TEST_SUITES := $(TEST_SUITES:%=test-%) RUN_TEST_SUITES := $(TEST_SUITES:%=test-%)
CLEAN_TEST_SUITES := $(TEST_SUITES:%=clean-%) CLEAN_TEST_SUITES := $(TEST_SUITES:%=clean-%)

@ -0,0 +1,5 @@
include ../test_common.mk
EXTRA_C_FLAGS :=
EXTRA_LINK_FLAGS :=
BIN_ARGS :=

@ -0,0 +1,36 @@
#include <sys/syscall.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <spawn.h>
#define NREPEATS 5000
int main(int argc, const char* argv[]) {
struct timeval tv_start, tv_end;
gettimeofday(&tv_start, NULL);
for (unsigned long i = 0; i < NREPEATS; i++) {
int child_pid, status;
if (posix_spawn(&child_pid, "empty/bin.encrypted", NULL, NULL, NULL, NULL) <0) {
printf("ERROR: failed to spawn (# of repeats = %lu)\n", i);
return -1;
}
if (wait4(-1, &status, 0, NULL) < 0) {
printf("ERROR: failed to wait4 (# of repeats = %lu)\n", i);
return -1;
}
if (status != 0) {
printf("ERROR: child process exits with error\n");
return -1;
}
}
gettimeofday(&tv_end, NULL);
suseconds_t total_us = (tv_end.tv_sec - tv_start.tv_sec) * 1000000UL +
+ (tv_end.tv_usec - tv_start.tv_usec);
suseconds_t latency = total_us / NREPEATS;
printf("Latency of spawn/exit = %lu us\n", latency);
return 0;
}