mirror of https://github.com/mongodb/mongo
SERVER-85932 Update README for cost model calibration setup (#40665)
GitOrigin-RevId: 3775c3777c1a5bf15e639925e834b08ab65d1868
This commit is contained in:
parent
23c043a325
commit
7a3ab132d2
|
|
@ -1,30 +1,93 @@
|
|||
# Cost Model Calibrator
|
||||
|
||||
## Python virtual environment
|
||||
## Getting Started
|
||||
|
||||
The following assumes you are using python from the MongoDB toolchain.
|
||||
### 1) Setup Mongod
|
||||
|
||||
```
|
||||
/opt/mongodbtoolchain/v4/bin/python3
|
||||
```
|
||||
First, prepare the MongoDB server:
|
||||
|
||||
### Getting started
|
||||
|
||||
Make sure before running `start.py`, you have a locally running `mongod` instance (this must be run using the `mongo-python3` virtual environment, so do it before step 1 below).
|
||||
1. Activate the standard virtual environment:
|
||||
|
||||
```sh
|
||||
(mongo-python3) deactivate # only if you have another python env activated
|
||||
sh> /opt/mongodbtoolchain/v4/bin/python3 -m venv cm # create new env
|
||||
sh> source cm/bin/activate # activate new env
|
||||
(cm) python -m pip install -r requirements.txt # install required packages
|
||||
(cm) python start.py # run the calibrator
|
||||
(cm) deactivate # back to bash
|
||||
sh>
|
||||
source python3-venv/bin/activate
|
||||
```
|
||||
|
||||
### Install new packages
|
||||
2. Build server with optimizations (makes doc insertion faster):
|
||||
|
||||
```sh
|
||||
(cm) python -m pip install <package_name> # install <package_name>
|
||||
(cm) python -m pip freeze > requirements.txt # do not forget to update requirements.txt
|
||||
(python3-venv) bazel build --config=opt install-devcore
|
||||
```
|
||||
|
||||
3. Run mongod instance:
|
||||
|
||||
```sh
|
||||
(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:
|
||||
|
||||
```sh
|
||||
cd buildscripts/cost_model
|
||||
```
|
||||
|
||||
2. Set up Python alias to use MongoDB toolchain:
|
||||
|
||||
```sh
|
||||
alias python=/opt/mongodbtoolchain/v4/bin/python3
|
||||
```
|
||||
|
||||
3. Deactivate any existing Python environment (if needed):
|
||||
|
||||
```sh
|
||||
deactivate
|
||||
```
|
||||
|
||||
4. Create new virtual environment:
|
||||
|
||||
```sh
|
||||
/opt/mongodbtoolchain/v4/bin/python3 -m venv cm
|
||||
```
|
||||
|
||||
5. Activate the new environment:
|
||||
|
||||
```sh
|
||||
source cm/bin/activate
|
||||
```
|
||||
|
||||
6. Install required packages:
|
||||
|
||||
```sh
|
||||
(cm) python -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
7. Run the calibrator:
|
||||
|
||||
```sh
|
||||
(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.
|
||||
|
||||
8. When done, deactivate the environment:
|
||||
|
||||
```sh
|
||||
(cm) deactivate
|
||||
```
|
||||
|
||||
## Install New Packages
|
||||
|
||||
1. Install the package:
|
||||
|
||||
```sh
|
||||
(cm) python -m pip install <package_name>
|
||||
```
|
||||
|
||||
2. Update requirements.txt:
|
||||
|
||||
```sh
|
||||
(cm) python -m pip freeze > requirements.txt
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in New Issue