Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the --nocheckpoint and --multitrans options to kvtest. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5828633c2392274b6863b50eaffbb2a1 |
User & Date: | drh 2017-06-03 15:17:21.324 |
Context
2017-06-03
| ||
17:24 | In kvtest, add the ability to work with a hierarchy of files on disk, in addition to having all files in the same directory. (check-in: f568f666c8 user: drh tags: trunk) | |
15:17 | Add the --nocheckpoint and --multitrans options to kvtest. (check-in: 5828633c23 user: drh tags: trunk) | |
2017-06-02
| ||
23:32 | Add the --fsync flag to kvtest, and document the --nosync flag. (check-in: 7fdc78a672 user: drh tags: trunk) | |
Changes
Changes to test/kvtest.c.
︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 | " --cache-size N Database cache size\n" " --count N Read N blobs\n" " --desc Read blobs in descending order\n" " --fsync Synchronous file writes\n" " --integrity-check Run \"PRAGMA integrity_check\" after test\n" " --max-id N Maximum blob key to use\n" " --mmap N Mmap as much as N bytes of DBFILE\n" " --nosync Set \"PRAGMA synchronous=OFF\"\n" " --jmode MODE Set MODE journal mode prior to starting\n" " --random Read blobs in a random order\n" " --start N Start reading with this blob key\n" " --stats Output operating stats before exiting\n" | > > | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | " --cache-size N Database cache size\n" " --count N Read N blobs\n" " --desc Read blobs in descending order\n" " --fsync Synchronous file writes\n" " --integrity-check Run \"PRAGMA integrity_check\" after test\n" " --max-id N Maximum blob key to use\n" " --mmap N Mmap as much as N bytes of DBFILE\n" " --multitrans Each read or write in its own transaction\n" " --nocheckpoint Omit the checkpoint on WAL mode writes\n" " --nosync Set \"PRAGMA synchronous=OFF\"\n" " --jmode MODE Set MODE journal mode prior to starting\n" " --random Read blobs in a random order\n" " --start N Start reading with this blob key\n" " --stats Output operating stats before exiting\n" " --update Do an overwrite test\n" ; /* Reference resources used */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> |
︙ | ︙ | |||
738 739 740 741 742 743 744 745 746 747 748 749 750 751 | int bBlobApi = 0; /* Use the incremental blob I/O API */ int bStats = 0; /* Print stats before exiting */ int eOrder = ORDER_ASC; /* Access order */ int isUpdateTest = 0; /* Do in-place updates rather than reads */ int doIntegrityCk = 0; /* Run PRAGMA integrity_check after the test */ int noSync = 0; /* Disable synchronous mode */ int doFsync = 0; /* Update disk files synchronously */ sqlite3 *db = 0; /* Database connection */ sqlite3_stmt *pStmt = 0; /* Prepared statement for SQL access */ sqlite3_blob *pBlob = 0; /* Handle for incremental Blob I/O */ sqlite3_int64 tmStart; /* Start time */ sqlite3_int64 tmElapsed; /* Elapsed time */ int mmapSize = 0; /* --mmap N argument */ int nData = 0; /* Bytes of data */ | > > | 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | int bBlobApi = 0; /* Use the incremental blob I/O API */ int bStats = 0; /* Print stats before exiting */ int eOrder = ORDER_ASC; /* Access order */ int isUpdateTest = 0; /* Do in-place updates rather than reads */ int doIntegrityCk = 0; /* Run PRAGMA integrity_check after the test */ int noSync = 0; /* Disable synchronous mode */ int doFsync = 0; /* Update disk files synchronously */ int doMultiTrans = 0; /* Each operation in its own transaction */ int noCheckpoint = 0; /* Omit the checkpoint in WAL mode */ sqlite3 *db = 0; /* Database connection */ sqlite3_stmt *pStmt = 0; /* Prepared statement for SQL access */ sqlite3_blob *pBlob = 0; /* Handle for incremental Blob I/O */ sqlite3_int64 tmStart; /* Start time */ sqlite3_int64 tmElapsed; /* Elapsed time */ int mmapSize = 0; /* --mmap N argument */ int nData = 0; /* Bytes of data */ |
︙ | ︙ | |||
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | eType = pathType(zDb); if( eType==PATH_OTHER ) fatalError("unknown object type: \"%s\"", zDb); if( eType==PATH_NEXIST ) fatalError("object does not exist: \"%s\"", zDb); for(i=3; i<argc; i++){ char *z = argv[i]; if( z[0]!='-' ) fatalError("unknown argument: \"%s\"", z); if( z[1]=='-' ) z++; if( strcmp(z, "-count")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); nCount = integerValue(argv[++i]); if( nCount<1 ) fatalError("the --count must be positive"); continue; } if( strcmp(z, "-mmap")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); mmapSize = integerValue(argv[++i]); if( nCount<0 ) fatalError("the --mmap must be non-negative"); continue; } if( strcmp(z, "-max-id")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); iMax = integerValue(argv[++i]); continue; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < | < | < | | < | | | | < | < < < < < < < < < < < < < < < < < | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 | eType = pathType(zDb); if( eType==PATH_OTHER ) fatalError("unknown object type: \"%s\"", zDb); if( eType==PATH_NEXIST ) fatalError("object does not exist: \"%s\"", zDb); for(i=3; i<argc; i++){ char *z = argv[i]; if( z[0]!='-' ) fatalError("unknown argument: \"%s\"", z); if( z[1]=='-' ) z++; if( strcmp(z, "-asc")==0 ){ eOrder = ORDER_ASC; continue; } if( strcmp(z, "-blob-api")==0 ){ bBlobApi = 1; continue; } if( strcmp(z, "-cache-size")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); iCache = integerValue(argv[++i]); continue; } if( strcmp(z, "-count")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); nCount = integerValue(argv[++i]); if( nCount<1 ) fatalError("the --count must be positive"); continue; } if( strcmp(z, "-desc")==0 ){ eOrder = ORDER_DESC; continue; } if( strcmp(z, "-fsync")==0 ){ doFsync = 1; continue; } if( strcmp(z, "-integrity-check")==0 ){ doIntegrityCk = 1; continue; } if( strcmp(z, "-jmode")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); zJMode = argv[++i]; continue; } if( strcmp(z, "-mmap")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); mmapSize = integerValue(argv[++i]); if( nCount<0 ) fatalError("the --mmap must be non-negative"); continue; } if( strcmp(z, "-max-id")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); iMax = integerValue(argv[++i]); continue; } if( strcmp(z, "-multitrans")==0 ){ doMultiTrans = 1; continue; } if( strcmp(z, "-nocheckpoint")==0 ){ noCheckpoint = 1; continue; } if( strcmp(z, "-nosync")==0 ){ noSync = 1; continue; } if( strcmp(z, "-random")==0 ){ eOrder = ORDER_RANDOM; continue; } if( strcmp(z, "-start")==0 ){ if( i==argc-1 ) fatalError("missing argument on \"%s\"", argv[i]); iKey = integerValue(argv[++i]); if( iKey<1 ) fatalError("the --start must be positive"); continue; } if( strcmp(z, "-stats")==0 ){ bStats = 1; continue; } if( strcmp(z, "-update")==0 ){ isUpdateTest = 1; continue; } fatalError("unknown option: \"%s\"", argv[i]); } if( eType==PATH_DB ){ /* Recover any prior crashes prior to starting the timer */ sqlite3_open(zDb, &db); sqlite3_exec(db, "SELECT rowid FROM sqlite_master LIMIT 1", 0, 0, 0); sqlite3_close(db); |
︙ | ︙ | |||
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 | } sqlite3_finalize(pStmt); pStmt = 0; if( zJMode ){ zSql = sqlite3_mprintf("PRAGMA journal_mode=%Q", zJMode); sqlite3_exec(db, zSql, 0, 0, 0); sqlite3_free(zSql); } sqlite3_prepare_v2(db, "PRAGMA journal_mode", -1, &pStmt, 0); if( sqlite3_step(pStmt)==SQLITE_ROW ){ zJMode = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0)); }else{ zJMode = "???"; } sqlite3_finalize(pStmt); if( iMax<=0 ){ sqlite3_prepare_v2(db, "SELECT max(k) FROM kv", -1, &pStmt, 0); if( sqlite3_step(pStmt)==SQLITE_ROW ){ iMax = sqlite3_column_int(pStmt, 0); } sqlite3_finalize(pStmt); } pStmt = 0; | > > > | | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | } sqlite3_finalize(pStmt); pStmt = 0; if( zJMode ){ zSql = sqlite3_mprintf("PRAGMA journal_mode=%Q", zJMode); sqlite3_exec(db, zSql, 0, 0, 0); sqlite3_free(zSql); if( noCheckpoint ){ sqlite3_exec(db, "PRAGMA wal_autocheckpoint=0", 0, 0, 0); } } sqlite3_prepare_v2(db, "PRAGMA journal_mode", -1, &pStmt, 0); if( sqlite3_step(pStmt)==SQLITE_ROW ){ zJMode = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0)); }else{ zJMode = "???"; } sqlite3_finalize(pStmt); if( iMax<=0 ){ sqlite3_prepare_v2(db, "SELECT max(k) FROM kv", -1, &pStmt, 0); if( sqlite3_step(pStmt)==SQLITE_ROW ){ iMax = sqlite3_column_int(pStmt, 0); } sqlite3_finalize(pStmt); } pStmt = 0; if( !doMultiTrans ) sqlite3_exec(db, "BEGIN", 0, 0, 0); } if( iMax<=0 ) iMax = 1000; for(i=0; i<nCount; i++){ if( eType==PATH_DIR ){ /* CASE 1: Reading blobs out of separate files */ char *zKey; zKey = sqlite3_mprintf("%s/%06d", zDb, iKey); |
︙ | ︙ | |||
986 987 988 989 990 991 992 | if( nAlloc ) sqlite3_free(pData); if( pStmt ) sqlite3_finalize(pStmt); if( pBlob ) sqlite3_blob_close(pBlob); if( bStats ){ display_stats(db, 0); } if( db ){ | | > | > | > > > > > | 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | if( nAlloc ) sqlite3_free(pData); if( pStmt ) sqlite3_finalize(pStmt); if( pBlob ) sqlite3_blob_close(pBlob); if( bStats ){ display_stats(db, 0); } if( db ){ if( !doMultiTrans ) sqlite3_exec(db, "COMMIT", 0, 0, 0); if( !noCheckpoint ){ sqlite3_close(db); db = 0; } } tmElapsed = timeOfDay() - tmStart; if( db && noCheckpoint ){ sqlite3_close(db); db = 0; } if( nExtra ){ printf("%d cycles due to %d misses\n", nCount, nExtra); } if( eType==PATH_DB ){ printf("SQLite version: %s\n", sqlite3_libversion()); if( doIntegrityCk ){ sqlite3_open(zDb, &db); |
︙ | ︙ |