Add profiling#199
Conversation
| get_size () { | ||
| local filesize_mb=$(python -c "import os;size=os.path.getsize('${GEN_DIR}/default.db') / (1024 * 1024);print(f'{size:.4f}')") | ||
| echo $filesize_mb | ||
| GEN_DIR="${GEN_DIR}" GEN_DB_PATH="${GEN_DIR}/gen.db" DEFAULT_DB_PATH="${GEN_DIR}/default.db" ${PYTHON_BIN} -c "import os |
There was a problem hiding this comment.
Is it possible to do all this with system commands, instead of invoking python?
There was a problem hiding this comment.
i think it's this way just for portability of code between systems
|
|
||
| time_taken() { | ||
| local start_time=$(python -c "import time;print(round(time.time()*1000))") | ||
| local start_time=$(${PYTHON_BIN} -c "import time;print(round(time.time()*1000))") |
There was a problem hiding this comment.
Looks like the system command date +%s%N gives time in nanoseconds?
There was a problem hiding this comment.
it's not natively supported in osx
| read -r BOTH_SIZE BOTH_GEN_DB_SIZE BOTH_DEFAULT_DB_SIZE <<< "$(get_size)" | ||
| record_result "HG00096 + HG00097 Update" "${SUM}" "${BOTH_SIZE}" "${BOTH_GEN_DB_SIZE}" "${BOTH_DEFAULT_DB_SIZE}" | ||
|
|
||
| # echo "switch branch benchmark" |
There was a problem hiding this comment.
Why are these commented out? Is the idea to uncomment to benchmark specific ones?
| .iter() | ||
| .map(|(stack, stat)| (stack_frames(stack), stat.calls, stat.total)) | ||
| .collect::<Vec<_>>(); | ||
| rows.sort_by(|left, right| right.2.cmp(&left.2).then_with(|| left.0.cmp(&right.0))); |
There was a problem hiding this comment.
It'd be good to add a comment saying what fields 0 and 2 are
| where | ||
| S: Subscriber + for<'span> LookupSpan<'span>, | ||
| { | ||
| fn on_new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>) { |
| starts: Vec<Instant>, | ||
| } | ||
|
|
||
| impl Profiler { |
There was a problem hiding this comment.
Is there a comment somewhere saying what the difference is between the Profiler and the SampleProfiler? Maybe add a docstring to each class?
dkhofer
left a comment
There was a problem hiding this comment.
Overall LGTM, just a few comments
Adds a profiling command to identify slow points in the codebase. Adds instrumentation for some functions so they can be profiled. There are 2 profile modes: instrumentation which tracks things with the cfg profile attribute, and a sample based profiler.
profiler is enabled by building with
--features profiling