Fossil SCM
Add a compile-time option to ignore the control file checksum (for a modest performance increase while parsing control files.) Enhance the test-parse-manifest command to facilitate performance studies.
Commit
712988286e20198a26ecde3cde8d50f597b6f029
Parent
0a55d162275a417…
1 file changed
+20
-4
+20
-4
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -163,10 +163,15 @@ | ||
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | memset(&manifestCache, 0, sizeof(manifestCache)); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | +#ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM | |
| 169 | +# define md5sum_init(X) | |
| 170 | +# define md5sum_step_text(X,Y) | |
| 171 | +#endif | |
| 172 | + | |
| 168 | 173 | /* |
| 169 | 174 | ** Parse a blob into a Manifest object. The Manifest object |
| 170 | 175 | ** takes over the input blob and will free it when the |
| 171 | 176 | ** Manifest object is freed. Zeros are inserted into the blob |
| 172 | 177 | ** as string terminators so that blob should not be used again. |
| @@ -635,20 +640,24 @@ | ||
| 635 | 640 | ** This card is required for all control file types except for |
| 636 | 641 | ** Manifest. It is not required for manifest only for historical |
| 637 | 642 | ** compatibility reasons. |
| 638 | 643 | */ |
| 639 | 644 | case 'Z': { |
| 645 | +#ifndef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM | |
| 640 | 646 | int rc; |
| 641 | 647 | Blob hash; |
| 648 | +#endif | |
| 642 | 649 | if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error; |
| 643 | 650 | if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error; |
| 644 | 651 | if( blob_size(&a1)!=32 ) goto manifest_syntax_error; |
| 645 | 652 | if( !validate16(blob_buffer(&a1), 32) ) goto manifest_syntax_error; |
| 653 | +#ifndef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM | |
| 646 | 654 | md5sum_finish(&hash); |
| 647 | 655 | rc = blob_compare(&hash, &a1); |
| 648 | 656 | blob_reset(&hash); |
| 649 | 657 | if( rc!=0 ) goto manifest_syntax_error; |
| 658 | +#endif | |
| 650 | 659 | seenZ = 1; |
| 651 | 660 | break; |
| 652 | 661 | } |
| 653 | 662 | default: { |
| 654 | 663 | goto manifest_syntax_error; |
| @@ -752,24 +761,31 @@ | ||
| 752 | 761 | } |
| 753 | 762 | |
| 754 | 763 | /* |
| 755 | 764 | ** COMMAND: test-parse-manifest |
| 756 | 765 | ** |
| 757 | -** Usage: %fossil test-parse-manifest FILENAME | |
| 766 | +** Usage: %fossil test-parse-manifest FILENAME ?N? | |
| 758 | 767 | ** |
| 759 | 768 | ** Parse the manifest and discarded. Use for testing only. |
| 760 | 769 | */ |
| 761 | 770 | void manifest_test_parse_cmd(void){ |
| 762 | 771 | Manifest m; |
| 763 | 772 | Blob b; |
| 764 | - if( g.argc!=3 ){ | |
| 773 | + int i; | |
| 774 | + int n = 1; | |
| 775 | + if( g.argc!=3 && g.argc!=4 ){ | |
| 765 | 776 | usage("FILENAME"); |
| 766 | 777 | } |
| 767 | 778 | db_must_be_within_tree(); |
| 768 | 779 | blob_read_from_file(&b, g.argv[2]); |
| 769 | - manifest_parse(&m, &b); | |
| 770 | - manifest_clear(&m); | |
| 780 | + if( g.argc>3 ) n = atoi(g.argv[3]); | |
| 781 | + for(i=0; i<n; i++){ | |
| 782 | + Blob b2; | |
| 783 | + blob_copy(&b2, &b); | |
| 784 | + manifest_parse(&m, &b2); | |
| 785 | + manifest_clear(&m); | |
| 786 | + } | |
| 771 | 787 | } |
| 772 | 788 | |
| 773 | 789 | /* |
| 774 | 790 | ** Translate a filename into a filename-id (fnid). Create a new fnid |
| 775 | 791 | ** if no previously exists. |
| 776 | 792 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -163,10 +163,15 @@ | |
| 163 | } |
| 164 | } |
| 165 | memset(&manifestCache, 0, sizeof(manifestCache)); |
| 166 | } |
| 167 | |
| 168 | /* |
| 169 | ** Parse a blob into a Manifest object. The Manifest object |
| 170 | ** takes over the input blob and will free it when the |
| 171 | ** Manifest object is freed. Zeros are inserted into the blob |
| 172 | ** as string terminators so that blob should not be used again. |
| @@ -635,20 +640,24 @@ | |
| 635 | ** This card is required for all control file types except for |
| 636 | ** Manifest. It is not required for manifest only for historical |
| 637 | ** compatibility reasons. |
| 638 | */ |
| 639 | case 'Z': { |
| 640 | int rc; |
| 641 | Blob hash; |
| 642 | if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error; |
| 643 | if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error; |
| 644 | if( blob_size(&a1)!=32 ) goto manifest_syntax_error; |
| 645 | if( !validate16(blob_buffer(&a1), 32) ) goto manifest_syntax_error; |
| 646 | md5sum_finish(&hash); |
| 647 | rc = blob_compare(&hash, &a1); |
| 648 | blob_reset(&hash); |
| 649 | if( rc!=0 ) goto manifest_syntax_error; |
| 650 | seenZ = 1; |
| 651 | break; |
| 652 | } |
| 653 | default: { |
| 654 | goto manifest_syntax_error; |
| @@ -752,24 +761,31 @@ | |
| 752 | } |
| 753 | |
| 754 | /* |
| 755 | ** COMMAND: test-parse-manifest |
| 756 | ** |
| 757 | ** Usage: %fossil test-parse-manifest FILENAME |
| 758 | ** |
| 759 | ** Parse the manifest and discarded. Use for testing only. |
| 760 | */ |
| 761 | void manifest_test_parse_cmd(void){ |
| 762 | Manifest m; |
| 763 | Blob b; |
| 764 | if( g.argc!=3 ){ |
| 765 | usage("FILENAME"); |
| 766 | } |
| 767 | db_must_be_within_tree(); |
| 768 | blob_read_from_file(&b, g.argv[2]); |
| 769 | manifest_parse(&m, &b); |
| 770 | manifest_clear(&m); |
| 771 | } |
| 772 | |
| 773 | /* |
| 774 | ** Translate a filename into a filename-id (fnid). Create a new fnid |
| 775 | ** if no previously exists. |
| 776 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -163,10 +163,15 @@ | |
| 163 | } |
| 164 | } |
| 165 | memset(&manifestCache, 0, sizeof(manifestCache)); |
| 166 | } |
| 167 | |
| 168 | #ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM |
| 169 | # define md5sum_init(X) |
| 170 | # define md5sum_step_text(X,Y) |
| 171 | #endif |
| 172 | |
| 173 | /* |
| 174 | ** Parse a blob into a Manifest object. The Manifest object |
| 175 | ** takes over the input blob and will free it when the |
| 176 | ** Manifest object is freed. Zeros are inserted into the blob |
| 177 | ** as string terminators so that blob should not be used again. |
| @@ -635,20 +640,24 @@ | |
| 640 | ** This card is required for all control file types except for |
| 641 | ** Manifest. It is not required for manifest only for historical |
| 642 | ** compatibility reasons. |
| 643 | */ |
| 644 | case 'Z': { |
| 645 | #ifndef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM |
| 646 | int rc; |
| 647 | Blob hash; |
| 648 | #endif |
| 649 | if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error; |
| 650 | if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error; |
| 651 | if( blob_size(&a1)!=32 ) goto manifest_syntax_error; |
| 652 | if( !validate16(blob_buffer(&a1), 32) ) goto manifest_syntax_error; |
| 653 | #ifndef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM |
| 654 | md5sum_finish(&hash); |
| 655 | rc = blob_compare(&hash, &a1); |
| 656 | blob_reset(&hash); |
| 657 | if( rc!=0 ) goto manifest_syntax_error; |
| 658 | #endif |
| 659 | seenZ = 1; |
| 660 | break; |
| 661 | } |
| 662 | default: { |
| 663 | goto manifest_syntax_error; |
| @@ -752,24 +761,31 @@ | |
| 761 | } |
| 762 | |
| 763 | /* |
| 764 | ** COMMAND: test-parse-manifest |
| 765 | ** |
| 766 | ** Usage: %fossil test-parse-manifest FILENAME ?N? |
| 767 | ** |
| 768 | ** Parse the manifest and discarded. Use for testing only. |
| 769 | */ |
| 770 | void manifest_test_parse_cmd(void){ |
| 771 | Manifest m; |
| 772 | Blob b; |
| 773 | int i; |
| 774 | int n = 1; |
| 775 | if( g.argc!=3 && g.argc!=4 ){ |
| 776 | usage("FILENAME"); |
| 777 | } |
| 778 | db_must_be_within_tree(); |
| 779 | blob_read_from_file(&b, g.argv[2]); |
| 780 | if( g.argc>3 ) n = atoi(g.argv[3]); |
| 781 | for(i=0; i<n; i++){ |
| 782 | Blob b2; |
| 783 | blob_copy(&b2, &b); |
| 784 | manifest_parse(&m, &b2); |
| 785 | manifest_clear(&m); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | /* |
| 790 | ** Translate a filename into a filename-id (fnid). Create a new fnid |
| 791 | ** if no previously exists. |
| 792 |