mongo/buildscripts/cost_model/README.md

1.6 KiB

Cost Model Calibrator

Getting Started

1) Setup Mongod

First, prepare the MongoDB server:

  1. Activate the standard virtual environment:
source python3-venv/bin/activate
  1. Build server with optimizations (makes doc insertion faster):
(python3-venv) bazel build --config=opt install-devcore
  1. Run mongod instance:
(python3-venv) bazel-bin/install-mongod/bin/mongod --setParameter internalMeasureQueryExecutionTimeInNanoseconds=true

2) Setup Cost Model Calibrator

In another terminal:

  1. Navigate to the cost model directory:
cd buildscripts/cost_model
  1. Set up Python alias to use MongoDB toolchain:
alias python=/opt/mongodbtoolchain/v4/bin/python3
  1. Deactivate any existing Python environment (if needed):
deactivate
  1. Create new virtual environment:
/opt/mongodbtoolchain/v4/bin/python3 -m venv cm
  1. Activate the new environment:
source cm/bin/activate
  1. Install required packages:
(cm) python -m pip install -r requirements.txt
  1. Run the calibrator:
(cm) python start.py

Note: For the first time it will take a while since it has to generate the data. Afterwards, as long as you aren't modifying the collections, you can comment out await generator.populate_collections() in start.py - this will make it a lot faster.

  1. When done, deactivate the environment:
(cm) deactivate

Install New Packages

  1. Install the package:
(cm) python -m pip install <package_name>
  1. Update requirements.txt:
(cm) python -m pip freeze > requirements.txt