| | @@ -488,18 +488,22 @@ |
| 488 | 488 | */ |
| 489 | 489 | #define N_NEIGHBOR 5 |
| 490 | 490 | |
| 491 | 491 | /* |
| 492 | 492 | ** Attempt to convert more full-text blobs into delta-blobs for |
| 493 | | -** storage efficiency. |
| 493 | +** storage efficiency. Return the number of bytes of storage space |
| 494 | +** saved. |
| 494 | 495 | */ |
| 495 | | -void extra_deltification(void){ |
| 496 | +i64 extra_deltification(int *pnDelta){ |
| 496 | 497 | Stmt q; |
| 497 | 498 | int aPrev[N_NEIGHBOR]; |
| 498 | 499 | int nPrev; |
| 499 | 500 | int rid; |
| 500 | 501 | int prevfnid, fnid; |
| 502 | + int nDelta = 0; |
| 503 | + i64 nByte = 0; |
| 504 | + int nSaved; |
| 501 | 505 | db_begin_transaction(); |
| 502 | 506 | |
| 503 | 507 | /* Look for manifests that have not been deltaed and try to make them |
| 504 | 508 | ** children of one of the 5 chronologically subsequent check-ins |
| 505 | 509 | */ |
| | @@ -512,11 +516,15 @@ |
| 512 | 516 | ); |
| 513 | 517 | nPrev = 0; |
| 514 | 518 | while( db_step(&q)==SQLITE_ROW ){ |
| 515 | 519 | rid = db_column_int(&q, 0); |
| 516 | 520 | if( nPrev>0 ){ |
| 517 | | - content_deltify(rid, aPrev, nPrev, 0); |
| 521 | + nSaved = content_deltify(rid, aPrev, nPrev, 0); |
| 522 | + if( nSaved>0 ){ |
| 523 | + nDelta++; |
| 524 | + nByte += nSaved; |
| 525 | + } |
| 518 | 526 | } |
| 519 | 527 | if( nPrev<N_NEIGHBOR ){ |
| 520 | 528 | aPrev[nPrev++] = rid; |
| 521 | 529 | }else{ |
| 522 | 530 | int i; |
| | @@ -543,11 +551,15 @@ |
| 543 | 551 | rid = db_column_int(&q, 0); |
| 544 | 552 | fnid = db_column_int(&q, 1); |
| 545 | 553 | if( fnid!=prevfnid ) nPrev = 0; |
| 546 | 554 | prevfnid = fnid; |
| 547 | 555 | if( nPrev>0 ){ |
| 548 | | - content_deltify(rid, aPrev, nPrev, 0); |
| 556 | + nSaved = content_deltify(rid, aPrev, nPrev, 0); |
| 557 | + if( nSaved>0 ){ |
| 558 | + nDelta++; |
| 559 | + nByte += nSaved; |
| 560 | + } |
| 549 | 561 | } |
| 550 | 562 | if( nPrev<N_NEIGHBOR ){ |
| 551 | 563 | aPrev[nPrev++] = rid; |
| 552 | 564 | }else{ |
| 553 | 565 | int i; |
| | @@ -556,10 +568,12 @@ |
| 556 | 568 | } |
| 557 | 569 | } |
| 558 | 570 | db_finalize(&q); |
| 559 | 571 | |
| 560 | 572 | db_end_transaction(0); |
| 573 | + if( pnDelta!=0 ) *pnDelta = nDelta; |
| 574 | + return nByte; |
| 561 | 575 | } |
| 562 | 576 | |
| 563 | 577 | |
| 564 | 578 | /* Reconstruct the private table. The private table contains the rid |
| 565 | 579 | ** of every manifest that is tagged with "private" and every file that |
| | @@ -636,11 +650,11 @@ |
| 636 | 650 | showStats = find_option("stats",0,0)!=0; |
| 637 | 651 | optIndex = find_option("index",0,0)!=0; |
| 638 | 652 | optNoIndex = find_option("noindex",0,0)!=0; |
| 639 | 653 | optIfNeeded = find_option("ifneeded",0,0)!=0; |
| 640 | 654 | compressOnlyFlag = find_option("compress-only",0,0)!=0; |
| 641 | | - if( compressOnlyFlag ) runCompress = runVacuum = 1; |
| 655 | + if( compressOnlyFlag ) runCompress = 1; |
| 642 | 656 | if( zPagesize ){ |
| 643 | 657 | newPagesize = atoi(zPagesize); |
| 644 | 658 | if( newPagesize<512 || newPagesize>65536 |
| 645 | 659 | || (newPagesize&(newPagesize-1))!=0 |
| 646 | 660 | ){ |
| | @@ -688,17 +702,25 @@ |
| 688 | 702 | errCnt |
| 689 | 703 | ); |
| 690 | 704 | db_end_transaction(1); |
| 691 | 705 | }else{ |
| 692 | 706 | if( runCompress ){ |
| 707 | + i64 nByte = 0; |
| 708 | + int nDelta = 0; |
| 693 | 709 | fossil_print("Extra delta compression... "); fflush(stdout); |
| 694 | | - extra_deltification(); |
| 695 | | - runVacuum = 1; |
| 710 | + nByte = extra_deltification(&nDelta); |
| 711 | + if( nDelta>0 ){ |
| 712 | + fossil_print("%d new deltas save %,lld bytes", nDelta, nByte); |
| 713 | + runVacuum = 1; |
| 714 | + }else{ |
| 715 | + fossil_print("no additional compression found"); |
| 716 | + } |
| 717 | + fflush(stdout); |
| 696 | 718 | } |
| 697 | 719 | if( omitVerify ) verify_cancel(); |
| 698 | 720 | db_end_transaction(0); |
| 699 | | - if( runCompress ) fossil_print("done\n"); |
| 721 | + if( runCompress ) fossil_print("\n"); |
| 700 | 722 | db_close(0); |
| 701 | 723 | db_open_repository(g.zRepositoryName); |
| 702 | 724 | if( newPagesize ){ |
| 703 | 725 | db_multi_exec("PRAGMA page_size=%d", newPagesize); |
| 704 | 726 | runVacuum = 1; |
| 705 | 727 | |