Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Small performance tweaks for clone and rebuild. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
710a8ba9938a9fb08a9534dd23c34f1d |
| User & Date: | drh 2010-07-04 21:11:47.000 |
Context
|
2010-07-07
| ||
| 07:44 | Update private branch to latest trunk. ... (check-in: a87fbd3312 user: michael tags: ttmrichter) | |
|
2010-07-06
| ||
| 20:51 | Update the built-in SQLite to the latest beta of version 3.7.0. ... (check-in: 8733f07f0a user: drh tags: trunk) | |
|
2010-07-04
| ||
| 21:11 | Small performance tweaks for clone and rebuild. ... (check-in: 710a8ba993 user: drh tags: trunk) | |
|
2010-07-03
| ||
| 15:33 | Update SQLite to the latest beta of 3.7.0. This provides much better server concurrency when the repository database file is set to WAL mode. ... (check-in: fb5f0c2580 user: drh tags: trunk, release) | |
Changes
Changes to src/content.c.
| ︙ | ︙ | |||
124 125 126 127 128 129 130 |
/*
** Mark artifact rid as being available now. Update the cache to
** show that everything that was formerly unavailable because rid
** was missing is now available.
*/
static void content_mark_available(int rid){
Bag pending;
| | | > | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
/*
** Mark artifact rid as being available now. Update the cache to
** show that everything that was formerly unavailable because rid
** was missing is now available.
*/
static void content_mark_available(int rid){
Bag pending;
static Stmt q;
if( bag_find(&contentCache.available, rid) ) return;
bag_init(&pending);
bag_insert(&pending, rid);
while( (rid = bag_first(&pending))!=0 ){
bag_remove(&pending, rid);
bag_remove(&contentCache.missing, rid);
bag_insert(&contentCache.available, rid);
db_static_prepare(&q, "SELECT rid FROM delta WHERE srcid=:rid");
db_bind_int(&q, ":rid", rid);
while( db_step(&q)==SQLITE_ROW ){
int nx = db_column_int(&q, 0);
bag_insert(&pending, nx);
}
db_reset(&q);
}
bag_clear(&pending);
}
/*
** Get the blob.content value for blob.rid=rid. Return 1 on success or
** 0 on failure.
|
| ︙ | ︙ | |||
320 321 322 323 324 325 326 327 328 329 |
/*
** When a record is converted from a phantom to a real record,
** if that record has other records that are derived by delta,
** then call manifest_crosslink() on those other records.
*/
void after_dephantomize(int rid, int linkFlag){
Stmt q;
db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid);
while( db_step(&q)==SQLITE_ROW ){
int tid = db_column_int(&q, 0);
| > > > > > > > > | > > | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
/*
** When a record is converted from a phantom to a real record,
** if that record has other records that are derived by delta,
** then call manifest_crosslink() on those other records.
*/
void after_dephantomize(int rid, int linkFlag){
Stmt q;
int prevTid = 0;
/* The prevTid variable is used to delay invoking this routine
** recursively, if possible, until after the query has finalized,
** in order to avoid having an excessive number of prepared statements.
** This is most effective in the common case where the query returns
** just one row.
*/
db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid);
while( db_step(&q)==SQLITE_ROW ){
int tid = db_column_int(&q, 0);
if( prevTid ) after_dephantomize(prevTid, 1);
prevTid = tid;
}
db_finalize(&q);
if( prevTid ) after_dephantomize(prevTid, 1);
if( linkFlag ){
Blob content;
content_get(rid, &content);
manifest_crosslink(rid, &content);
blob_reset(&content);
}
}
|
| ︙ | ︙ |
Changes to src/file.c.
| ︙ | ︙ | |||
195 196 197 198 199 200 201 |
** * Does not contain any of these characters in the path: "\*[]?"
** * Does not end with "/".
** * Does not contain two or more "/" characters in a row.
** * Contains at least one character
*/
int file_is_simple_pathname(const char *z){
int i;
| > | | | | | | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
** * Does not contain any of these characters in the path: "\*[]?"
** * Does not end with "/".
** * Does not contain two or more "/" characters in a row.
** * Contains at least one character
*/
int file_is_simple_pathname(const char *z){
int i;
char c = z[0];
if( c=='/' || c==0 ) return 0;
if( c=='.' ){
if( z[1]=='/' || z[1]==0 ) return 0;
if( z[1]=='.' && (z[2]=='/' || z[2]==0) ) return 0;
}
for(i=0; (c=z[i])!=0; i++){
if( c=='\\' || c=='*' || c=='[' || c==']' || c=='?' ){
return 0;
}
if( c=='/' ){
if( z[i+1]=='/' ) return 0;
if( z[i+1]=='.' ){
if( z[i+2]=='/' || z[i+2]==0 ) return 0;
if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
}
}
}
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
96 97 98 99 100 101 102 |
/*
** Rebuild cross-referencing information for the artifact
** rid with content pBase and all of its descendants. This
** routine clears the content buffer before returning.
*/
static void rebuild_step(int rid, int size, Blob *pBase){
| | | > | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
/*
** Rebuild cross-referencing information for the artifact
** rid with content pBase and all of its descendants. This
** routine clears the content buffer before returning.
*/
static void rebuild_step(int rid, int size, Blob *pBase){
static Stmt q1;
Bag children;
Blob copy;
Blob *pUse;
int nChild, i, cid;
/* Fix up the "blob.size" field if needed. */
if( size!=blob_size(pBase) ){
db_multi_exec(
"UPDATE blob SET size=%d WHERE rid=%d", blob_size(pBase), rid
);
}
/* Find all children of artifact rid */
db_static_prepare(&q1, "SELECT rid FROM delta WHERE srcid=:rid");
db_bind_int(&q1, ":rid", rid);
bag_init(&children);
while( db_step(&q1)==SQLITE_ROW ){
int cid = db_column_int(&q1, 0);
if( !bag_find(&bagDone, cid) ){
bag_insert(&children, cid);
}
}
nChild = bag_count(&children);
db_reset(&q1);
/* Crosslink the artifact */
if( nChild==0 ){
pUse = pBase;
}else{
blob_copy(©, pBase);
pUse = ©
|
| ︙ | ︙ | |||
207 208 209 210 211 212 213 |
if (!g.fQuiet) {
printf("0 (0%%)...\r");
fflush(stdout);
}
db_multi_exec(zSchemaUpdates);
for(;;){
zTable = db_text(0,
| | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
if (!g.fQuiet) {
printf("0 (0%%)...\r");
fflush(stdout);
}
db_multi_exec(zSchemaUpdates);
for(;;){
zTable = db_text(0,
"SELECT name FROM sqlite_master /*scan*/"
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user',"
"'config','shun','private','reportfmt',"
"'concealed')"
" AND name NOT GLOB 'sqlite_*'"
);
if( zTable==0 ) break;
|
| ︙ | ︙ | |||
235 236 237 238 239 240 241 |
" WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
);
db_multi_exec(
"DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')"
);
totalSize = db_int(0, "SELECT count(*) FROM blob");
db_prepare(&s,
| | | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
" WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
);
db_multi_exec(
"DELETE FROM config WHERE name IN ('remote-code', 'remote-maxid')"
);
totalSize = db_int(0, "SELECT count(*) FROM blob");
db_prepare(&s,
"SELECT rid, size FROM blob /*scan*/"
" WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
" AND NOT EXISTS(SELECT 1 FROM delta WHERE rid=blob.rid)"
);
manifest_crosslink_begin();
while( db_step(&s)==SQLITE_ROW ){
int rid = db_column_int(&s, 0);
int size = db_column_int(&s, 1);
|
| ︙ | ︙ |