Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-279

cursor configuration performance

    • Type: Icon: Task Task
    • Resolution: Done
    • WT1.3
    • Affects Version/s: None
    • Component/s: None

      Here's a simple test program measuring cursor configuration performance. You can run it with different objects (files or tables), and with/without the "overwrite" flag.

      % ./t -t file:xx
      start run... 1M: 3.55
      % ./t -t table:xx
      start run... 1M: 3.70
      % ./t -t file:xx -o
      start run... 1M: 48.46
      % ./t -t table:xx -o
      start run... 1M: 48.64
      

      Tables are competitive with files now (almost certainly due to the changes Michael pushed last night), but requiring configuration string parsing is a real problem.

      Here's the sources.

      #include <assert.h>
      #include <inttypes.h>
      #include <stdio.h>
      #include <stdlib.h>
      #include <string.h>
      #include <time.h>
      #include <unistd.h>
      
      #include <wiredtiger.h>
      
      #define MILLION         1000000
      
      int
      main(int argc, char *argv[])
      {
              WT_CONNECTION *conn;
              WT_CURSOR *cursor;
              WT_SESSION *session;
              clock_t ce, cs;
              int ch, i, ops; 
              char *progname, *overwrite, kbuf[64]; 
              const char *obj = "file:xx";
      
              if ((progname = strrchr(argv[0], '/')) == NULL)
                      progname = argv[0];
              else
                      ++progname;
      
              overwrite = NULL;
              ops = 1;
              while ((ch = getopt(argc, argv, "not:")) != EOF)
                      switch (ch) {
                      case 'n':
                              ops = atoi(optarg);
                              break;
                      case 'o':
                              overwrite = "overwrite";
                              break;
                      case 't':
                              obj = optarg;
                              break;
                      case '?':
                      default:
                              (void)fprintf(stderr,
                                  "usage: %s [-o] [-n ops] [-t uri]\n", progname);
                              return (1);
                      }
              argc -= optind;
              argv += optind;
      
              ops *= MILLION;                 /* Ops is millions of ops. */
      
              (void)system("rm -f WiredTiger WiredTiger.* *xx*");
      
              assert(wiredtiger_open(NULL, NULL, "create", &conn) == 0);
              assert(conn->open_session(conn, NULL, NULL, &session) == 0);
              assert(
                  session->create(session, obj, "key_format=S,value_format=S") == 0);
              assert(session->open_cursor(session, obj, NULL, NULL, &cursor) == 0);
              for (i = 0; i < 1000; ++i) {
                      snprintf(kbuf, sizeof(kbuf), "%010d KEY------", i);
                      cursor->set_key(cursor, kbuf);
                      cursor->set_value(cursor, "========== VALUE =======");
                      assert(cursor->insert(cursor) == 0);
              }
              /* Force to disk. */
              assert(conn->close(conn, 0) == 0);
      
              assert(wiredtiger_open(NULL, NULL, "create", &conn) == 0);
              assert(conn->open_session(conn, NULL, NULL, &session) == 0);
      
              printf("start run... "); fflush(stdout);
              cs = clock();
              for (i = 0; i < ops; ++i) {
                      assert(session->begin_transaction(session, NULL) == 0);
                      assert(session->open_cursor(
                          session, obj, NULL, overwrite, &cursor) == 0);
                      snprintf(kbuf, sizeof(kbuf), "%010d KEY------", i % 100);
                      cursor->set_key(cursor, kbuf);
                      cursor->set_value(cursor, "========== VALUE =======");
                      assert(cursor->update(cursor) == 0);
                      assert(session->commit_transaction(session, NULL) == 0);
              }
              ce = clock();
              printf("%dM: %.2lf\n",
                  ops / MILLION, (ce - cs) / (double)CLOCKS_PER_SEC);
      
              assert(conn->close(conn, 0) == 0);
              return (0);
      }
      

            Assignee:
            alexander.gorrod@mongodb.com Alexander Gorrod
            Reporter:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: