Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Various small performance enhancements. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
4c37130fde6b2e84f367343afa2f9ae4 |
| User & Date: | drh 2009-08-27 18:33:43.000 |
Context
|
2009-08-27
| ||
| 18:56 | Still more speed improvements to the "rebuild" command. ... (check-in: a9a27f8aaa user: drh tags: trunk) | |
| 18:33 | Various small performance enhancements. ... (check-in: 4c37130fde user: drh tags: trunk) | |
| 15:00 | Performance improvements on the compute_leavs() routine. There is opportunity for further improvement in this area. ... (check-in: 6953ca813c user: drh tags: trunk) | |
Changes
Changes to src/blob.c.
| ︙ | ︙ | |||
77 78 79 80 81 82 83 |
#endif
/*
** We find that the built-in isspace() function does not work for
** some international character sets. So here is a substitute.
*/
static int blob_isspace(char c){
| | > > > > > > > > > | > > > > > > | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
#endif
/*
** We find that the built-in isspace() function does not work for
** some international character sets. So here is a substitute.
*/
static int blob_isspace(char c){
return c==' ' || (c<='\r' && c>='\t');
}
/*
** COMMAND: test-isspace
*/
void isspace_cmd(void){
int i;
for(i=0; i<=255; i++){
if( i==' ' || i=='\n' || i=='\t' || i=='\v'
|| i=='\f' || i=='\r' ){
assert( blob_isspace((char)i) );
}else{
assert( !blob_isspace((char)i) );
}
}
printf("All 256 characters OK\n");
}
/*
** This routine is called if a blob operation fails because we
** have run out of memory.
*/
static void blob_panic(void){
|
| ︙ | ︙ |
Changes to src/content.c.
| ︙ | ︙ | |||
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
int nx = db_column_int(&q, 0);
bag_insert(&pending, nx);
}
db_finalize(&q);
}
bag_clear(&pending);
}
/*
** Extract the content for ID rid and put it into the
** uninitialized blob. Return 1 on success. If the record
** is a phantom, zero pBlob and return 0.
*/
int content_get(int rid, Blob *pBlob){
| > > > > > > > > > > > > > > > > > > > < | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
int nx = db_column_int(&q, 0);
bag_insert(&pending, nx);
}
db_finalize(&q);
}
bag_clear(&pending);
}
/*
** Get the blob.content value for blob.rid=rid. Return 1 on success or
** 0 on failure.
*/
static int content_of_blob(int rid, Blob *pBlob){
static Stmt q;
int rc = 0;
db_static_prepare(&q, "SELECT content FROM blob WHERE rid=:rid AND size>=0");
db_bind_int(&q, ":rid", rid);
if( db_step(&q)==SQLITE_ROW ){
db_ephemeral_blob(&q, 0, pBlob);
blob_uncompress(pBlob, pBlob);
rc = 1;
}
db_reset(&q);
return rc;
}
/*
** Extract the content for ID rid and put it into the
** uninitialized blob. Return 1 on success. If the record
** is a phantom, zero pBlob and return 0.
*/
int content_get(int rid, Blob *pBlob){
Blob src;
int srcid;
int rc = 0;
int i;
static Bag inProcess;
assert( g.repositoryOpen );
|
| ︙ | ︙ | |||
181 182 183 184 185 186 187 |
if( contentCache.a[i].rid==rid ){
*pBlob = contentCache.a[i].content;
blob_zero(&contentCache.a[i].content);
contentCache.n--;
if( i<contentCache.n ){
contentCache.a[i] = contentCache.a[contentCache.n];
}
| | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
if( contentCache.a[i].rid==rid ){
*pBlob = contentCache.a[i].content;
blob_zero(&contentCache.a[i].content);
contentCache.n--;
if( i<contentCache.n ){
contentCache.a[i] = contentCache.a[contentCache.n];
}
CONTENT_TRACE(("%*scache: %d\n",
bag_count(&inProcess), "", rid))
return 1;
}
}
/* See if we need to apply a delta to find this artifact */
srcid = findSrcid(rid);
|
| ︙ | ︙ | |||
208 209 210 211 212 213 214 |
);
blob_zero(pBlob);
return 0;
}
bag_insert(&inProcess, srcid);
if( content_get(srcid, &src) ){
| < < | | < < | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
);
blob_zero(pBlob);
return 0;
}
bag_insert(&inProcess, srcid);
if( content_get(srcid, &src) ){
Blob delta;
if( content_of_blob(rid, &delta) ){
blob_init(pBlob,0,0);
blob_delta_apply(&src, &delta, pBlob);
blob_reset(&delta);
rc = 1;
}
/* Save the srcid artifact in the cache */
if( contentCache.n<MX_CACHE_CNT ){
i = contentCache.n++;
}else if( ((contentCache.skipCnt++)%EXPELL_INTERVAL)!=0 ){
i = -1;
}else{
|
| ︙ | ︙ | |||
252 253 254 255 256 257 258 |
}else{
blob_reset(&src);
}
}
bag_remove(&inProcess, srcid);
}else{
/* No delta required. Read content directly from the database */
| < < | < < | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
}else{
blob_reset(&src);
}
}
bag_remove(&inProcess, srcid);
}else{
/* No delta required. Read content directly from the database */
if( content_of_blob(rid, pBlob) ){
rc = 1;
}
}
if( rc==0 ){
bag_insert(&contentCache.missing, rid);
}else{
bag_insert(&contentCache.available, rid);
}
return rc;
|
| ︙ | ︙ |
Changes to src/encode.c.
| ︙ | ︙ | |||
421 422 423 424 425 426 427 428 429 430 431 432 433 434 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 64, 64, 64, 64, 64, 64, 64, 10, 11, 12, 13, 14, 15, 64, 64, 1, 64, 64, 1, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 10, 11, 12, 13, 14, 15, 64, 64, 1, 64, 64, 1, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, }; /* ** Decode a N-character base-16 number into base-256. N must be a ** multiple of 2. The output buffer must be at least N/2 characters ** in length */ | > > > > > > > > | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 64, 64, 64, 64, 64, 64, 64, 10, 11, 12, 13, 14, 15, 64, 64, 1, 64, 64, 1, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 10, 11, 12, 13, 14, 15, 64, 64, 1, 64, 64, 1, 64, 64, 0, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, }; /* ** Decode a N-character base-16 number into base-256. N must be a ** multiple of 2. The output buffer must be at least N/2 characters ** in length */ |
| ︙ | ︙ | |||
448 449 450 451 452 453 454 |
/*
** Return true if the input string contains only valid base-16 digits.
** If any invalid characters appear in the string, return false.
*/
int validate16(const char *zIn, int nIn){
| | | | | > | 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
/*
** Return true if the input string contains only valid base-16 digits.
** If any invalid characters appear in the string, return false.
*/
int validate16(const char *zIn, int nIn){
int i;
for(i=0; i<nIn; i++, zIn++){
if( zDecode[zIn[0]&0xff]>63 ){
return zIn[0]==0;
}
}
return 1;
}
/*
** The input string is a base16 value. Convert it into its canonical
** form. This means that digits are all lower case and that conversions
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
Stmt s;
int errCnt = 0;
char *zTable;
bag_init(&bagDone);
ttyOutput = doOut;
processCnt = 0;
db_multi_exec(zSchemaUpdates);
for(;;){
zTable = db_text(0,
"SELECT name FROM sqlite_master"
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user',"
"'config','shun','private','reportfmt',"
| > | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
Stmt s;
int errCnt = 0;
char *zTable;
bag_init(&bagDone);
ttyOutput = doOut;
processCnt = 0;
printf("0 (0%%)...\r"); fflush(stdout);
db_multi_exec(zSchemaUpdates);
for(;;){
zTable = db_text(0,
"SELECT name FROM sqlite_master"
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user',"
"'config','shun','private','reportfmt',"
|
| ︙ | ︙ |