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.

drh 2010-10-09 13:04 trunk
Commit 712988286e20198a26ecde3cde8d50f597b6f029
1 file changed +20 -4
+20 -4
--- src/manifest.c
+++ src/manifest.c
@@ -163,10 +163,15 @@
163163
}
164164
}
165165
memset(&manifestCache, 0, sizeof(manifestCache));
166166
}
167167
168
+#ifdef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
169
+# define md5sum_init(X)
170
+# define md5sum_step_text(X,Y)
171
+#endif
172
+
168173
/*
169174
** Parse a blob into a Manifest object. The Manifest object
170175
** takes over the input blob and will free it when the
171176
** Manifest object is freed. Zeros are inserted into the blob
172177
** as string terminators so that blob should not be used again.
@@ -635,20 +640,24 @@
635640
** This card is required for all control file types except for
636641
** Manifest. It is not required for manifest only for historical
637642
** compatibility reasons.
638643
*/
639644
case 'Z': {
645
+#ifndef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
640646
int rc;
641647
Blob hash;
648
+#endif
642649
if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
643650
if( blob_token(&line, &a2)!=0 ) goto manifest_syntax_error;
644651
if( blob_size(&a1)!=32 ) goto manifest_syntax_error;
645652
if( !validate16(blob_buffer(&a1), 32) ) goto manifest_syntax_error;
653
+#ifndef FOSSIL_DONT_VERIFY_MANIFEST_MD5SUM
646654
md5sum_finish(&hash);
647655
rc = blob_compare(&hash, &a1);
648656
blob_reset(&hash);
649657
if( rc!=0 ) goto manifest_syntax_error;
658
+#endif
650659
seenZ = 1;
651660
break;
652661
}
653662
default: {
654663
goto manifest_syntax_error;
@@ -752,24 +761,31 @@
752761
}
753762
754763
/*
755764
** COMMAND: test-parse-manifest
756765
**
757
-** Usage: %fossil test-parse-manifest FILENAME
766
+** Usage: %fossil test-parse-manifest FILENAME ?N?
758767
**
759768
** Parse the manifest and discarded. Use for testing only.
760769
*/
761770
void manifest_test_parse_cmd(void){
762771
Manifest m;
763772
Blob b;
764
- if( g.argc!=3 ){
773
+ int i;
774
+ int n = 1;
775
+ if( g.argc!=3 && g.argc!=4 ){
765776
usage("FILENAME");
766777
}
767778
db_must_be_within_tree();
768779
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
+ }
771787
}
772788
773789
/*
774790
** Translate a filename into a filename-id (fnid). Create a new fnid
775791
** if no previously exists.
776792
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button