Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-4954

rand() isn't random

    XMLWordPrintableJSON

Details

    • Task
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • Impala 2.9.0
    • None
    • Backend
    • None

    Description

      rand() is not a very good random number generator. For some use cases, http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine would be a better choice.

      Places to audit:

      git grep -E '[^a-zA-Z0-9]rand\(\)' be | grep -vE '^[^ ]*benchmark.*' | grep -vE '^[^ ]*test'
      
      be/src/exec/hdfs-table-sink.cc:  const string& query_suffix = Substitute("$0_$1_data", unique_id_str_, rand());
      be/src/exec/hdfs-table-sink.cc:      Substitute("$0/.$1_$2_dir/", staging_dir_, unique_id_str_, rand());
      be/src/experiments/data-provider.cc:    ptr[i] = rand() * (max_char - min_char) + min_char;
      be/src/exprs/aggregate-functions-ir.cc:    int r = rand() % state->num_samples;
      be/src/exprs/math-functions-ir.cc:        ctx->SetError("Seed argument to rand() must be constant");
      be/src/gutil/port.h:#define random() rand()
      be/src/runtime/disk-io-mgr-stress.cc:  int rand_len = rand() % (MAX_FILE_LEN - MIN_FILE_LEN) + MIN_FILE_LEN;
      be/src/runtime/disk-io-mgr-stress.cc:    char c = rand() % 26 + 'a';
      be/src/runtime/disk-io-mgr-stress.cc:  int rand_client = rand() % num_clients_;
      be/src/runtime/disk-io-mgr-stress.cc:  client.file_idx = rand() % files_.size();
      be/src/runtime/disk-io-mgr-stress.cc:    float rand_value = rand() / (float)RAND_MAX;
      be/src/runtime/disk-io-mgr-stress.cc:      client.abort_at_byte = rand() % file_len;
      be/src/runtime/disk-io-mgr-stress.cc:    int range_len = rand() % (MAX_READ_LEN - MIN_READ_LEN) + MIN_READ_LEN;
      be/src/runtime/plan-fragment-executor.cc:  int report_fragment_offset = rand() % FLAGS_status_report_interval;
      be/src/runtime/tmp-file-mgr.cc:  next_allocation_index_ = rand() % tmp_files_.size();
      be/src/scheduling/simple-scheduler.cc:  std::mt19937 g(rand());
      be/src/util/network-util.cc:    int port = LOWER + rand() % (UPPER - LOWER);
      be/src/util/pprof-path-handlers.cc:  tmp_prof_file_name << "/tmp/impala_cpu_profile." << getpid() << "." << rand();
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jbapple Jim Apple
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: