tst2005googlecode2 / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

Reduce AsanThreadContext size #232

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
AsanThreadContext's are persistent, that is they exist even for finished 
thread. So it's critical to make it as small as possible.

1. We need to store stack depot's id instead of embed creation stack.
2. We need to allocate them more tightly. Currently each AsanThreadContext is 
mmap'ed, so consumes 4K regardless of size.

Original issue reported on code.google.com by dvyu...@google.com on 18 Oct 2013 at 2:18

GoogleCodeExporter commented 9 years ago

Original comment by konstant...@gmail.com on 18 Oct 2013 at 2:20

GoogleCodeExporter commented 9 years ago
Partially fixed in http://llvm.org/viewvc/llvm-project?rev=192980&view=rev
needs more investigation. 

Original comment by konstant...@gmail.com on 18 Oct 2013 at 3:14

GoogleCodeExporter commented 9 years ago
If the quarantine_size is set to 1, everything seems fine now.
After running 300000 threads the process is ~60Mb. 

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
static const int kNumThread = 1;
static const int kNumIter = 300000;
void *Thread(void *) { return 0; }
int main() {
  for (int i = 0; i < kNumIter; i++) {
    if ((i % 10000) == 0) printf("[%d]\n", i);
    pthread_t t[kNumThread];
    for (int j = 0; j < kNumThread; j++)
      pthread_create(&t[j], 0, Thread, 0);
    for (int j = 0; j < kNumThread; j++)
      pthread_join(t[j], 0);
  }
}

However with the default quarantine settings the process eats 1.6Gb after 
300000 threads, which is still surprising. 
at-exit stats:
  03 (48): total: 14080 K allocs: 19351536 remains: 300000
  18 (384): total: 64 K allocs: 128 remains: 128
  25 (1280): total: 192 K allocs: 2478 remains: 54
  37 (10240): total: 3000064 K allocs: 1050000 remains: 300000

Original comment by konstant...@gmail.com on 21 Oct 2013 at 7:38

GoogleCodeExporter commented 9 years ago
Should be fully fixed by  
http://llvm.org/viewvc/llvm-project?rev=193072&view=rev
We needed to count the size of QuarantineBatch in the total Quarantine size

Original comment by konstant...@gmail.com on 21 Oct 2013 at 8:43