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

Larson sized deallocation test #25

Merged
merged 8 commits into from
Nov 1, 2021
Merged

Larson sized deallocation test #25

merged 8 commits into from
Nov 1, 2021

Conversation

jq-rs
Copy link
Contributor

@jq-rs jq-rs commented Mar 4, 2021

Larson sized deallocation test. This will call delete[] operator with size to test sized deallocation path.

The test can be run with following:

../../bench.sh alla larson-sized

@mjp41
Copy link
Collaborator

mjp41 commented Mar 4, 2021

Looks interesting to me as a test. I have posted a diff here to make it easier to see what you have changed.

--- larson\larson.cpp   2021-02-26 10:16:01.360644200 +0000
+++ larson_sized\larson.cpp     2021-03-04 11:20:20.151509500 +0000
@@ -29,7 +29,6 @@
 #include <pthread.h>
 #endif

-
 typedef void * LPVOID;
 typedef long long LONGLONG;
 typedef long DWORD;
@@ -177,7 +176,7 @@
   int    max_size ;

   char * *array ;
-  int    *blksize ;
+  size_t *blksize ;
   int     asize ;

   long   cAllocs ;
@@ -200,7 +199,7 @@
 ULONG CountReservedSpace() ;

 char *          blkp[MAX_BLOCKS] ;
-int             blksize[MAX_BLOCKS] ;
+size_t          blksize[MAX_BLOCKS] ;
 long            seqlock=0 ;
 struct lran2_st rgen ;
 int             min_size=10, max_size=500 ;
@@ -353,7 +352,7 @@
 {
   int     cblks ;
   int     victim ;
-  int     blk_size ;
+  size_t  blk_size ;
 #ifdef __WIN32__
        _LARGE_INTEGER ticks_per_sec, start_cnt, end_cnt;
 #else
@@ -388,7 +387,7 @@
     for( cblks=0; cblks<num_chunks; cblks++){
       victim = lran2(&rgen)%num_chunks ;
 #if defined(CPP)
-    delete[] blkp[victim] ;
+    operator delete[] (blkp[victim], blksize[victim]);
 #elif defined(USE_MALLOC)
     free(blkp[victim]);
 #else
@@ -578,7 +577,7 @@
   thread_data  *pdea;
   int           cblks=0 ;
   int           victim ;
-  long          blk_size ;
+  size_t        blk_size;
   int           range ;

   if( stopflag ) return 0;
@@ -592,7 +591,7 @@
   for( cblks=0; cblks<pdea->NumBlocks; cblks++){
     victim = lran2(&pdea->rgen)%pdea->asize ;
 #ifdef CPP
-    delete[] pdea->array[victim] ;
+    operator delete[] (pdea->array[victim], pdea->blksize[victim]);
 #else
     CUSTOM_FREE(pdea->array[victim]) ;
 #endif
@@ -652,8 +651,9 @@
 {
   int     cblks ;
   int     victim ;
-  int     blk_size ;
+  size_t  blk_size ;
   LPVOID  tmp ;
+  size_t  tmp_sz;


   for( cblks=0; cblks<num_chunks; cblks++){
@@ -675,14 +675,17 @@
   for( cblks=num_chunks; cblks > 0 ; cblks--){
     victim = lran2(&rgen)%cblks ;
     tmp = blkp[victim] ;
+    tmp_sz = blksize[victim];
     blkp[victim]  = blkp[cblks-1] ;
+    blksize[victim] = blksize[cblks-1];
     blkp[cblks-1] = (char *) tmp ;
+    blksize[cblks-1] = tmp_sz;
   }

   for( cblks=0; cblks<4*num_chunks; cblks++){
     victim = lran2(&rgen)%num_chunks ;
 #ifdef CPP
-    delete[] blkp[victim] ;
+    operator delete[] (blkp[victim], blksize[victim]);
 #else
     CUSTOM_FREE(blkp[victim]) ;
 #endif

@jq-rs
Copy link
Contributor Author

jq-rs commented Mar 4, 2021

Just realized that we could have used the same source file even though there are two tests. I'll fix this, then the diff will be obvious.

@jq-rs
Copy link
Contributor Author

jq-rs commented Mar 4, 2021

Below is an example test run. Especially tc gets a boost with sized deallocation in my environment.

larsonN-sized sys 3.917 256496 194.51 2.79 0 68867
larsonN-sized mi 3.085 322616 198.25 0.58 0 86489
larsonN-sized smi 4.060 314540 198.56 0.51 0 82905
larsonN-sized tc 2.987 171368 198.02 0.42 0 42174
larsonN-sized je 3.113 263092 196.99 1.04 0 126367
larsonN-sized tbb 5.473 352276 198.70 0.82 0 109019
larsonN-sized sn 2.959 336252 199.19 0.42 0 83373
larsonN-sized rp 3.226 303708 197.73 0.37 0 75941
larsonN-sized hd 6.198 209420 198.90 0.29 0 51741

larsonN sys 3.792 262788 193.92 3.12 0 72135
larsonN mi 2.985 321508 198.27 0.57 0 86728
larsonN smi 4.023 317756 198.01 0.50 0 84125
larsonN tc 3.347 170608 198.28 0.41 0 41942
larsonN je 2.927 265116 198.16 1.04 0 130669
larsonN tbb 5.355 352916 198.90 0.84 0 109238
larsonN sn 2.907 332660 198.27 0.43 0 82496
larsonN rp 3.188 305736 198.86 0.42 0 76505
larsonN hd 6.381 204472 198.82 0.24 0 50544

@daanx
Copy link
Owner

daanx commented Oct 19, 2021

Apologies for the super late reply :-( I remember being a tad hesitant when I first saw this as Larson is used in many papers and if we change it we should perhaps rename it? So, I think it would be better as larson2 or something? not sure

@jq-rs
Copy link
Contributor Author

jq-rs commented Oct 22, 2021

I have already renamed this to Larson-sized. The original Larson-test remains there. I can change this to Larson2, if you prefer that one, but I personally cannot see how it is better. Naming is always hard :)

@daanx
Copy link
Owner

daanx commented Nov 1, 2021

I have already renamed this to Larson-sized. The original Larson-test remains there. I can change this to Larson2, if you prefer that one, but I personally cannot see how it is better. Naming is always hard :)

Ah, I did not notice that -- this is great. Thanks so much!

@daanx daanx merged commit af8f0a6 into daanx:master Nov 1, 2021
@jq-rs jq-rs deleted the larson_sized_test branch November 5, 2021 07:17
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.

3 participants