platform refactor
Move core logic to platform.rs.
Depends on #436 and #445.
Sanity Checking
- [ ] I have updated the changelog as per my changes
- [ ] I have tested, and self-reviewed my code
- Style and consistency
- [ ] I ran
nix fmtto format my Nix code - [ ] I ran
cargo fmtto format my Rust code - [ ] I have added appropriate documentation to new code
- [ ] My changes are consistent with the rest of the codebase
- [ ] I ran
- Correctness
- [ ] I ran
cargo clippyand fixed any new linter warnings.
- [ ] I ran
- If new changes are particularly complex:
- [ ] My code includes comments in particularly complex areas to explain the logic
- [ ] I have documented the motive for those changes in the PR body or commit description.
- Tested on platform(s)
- [ ]
x86_64-linux - [ ]
aarch64-linux - [ ]
x86_64-darwin - [ ]
aarch64-darwin
- [ ]
Add a :+1: reaction to pull requests you find important.
[!IMPORTANT]
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
โจ Finishing touches
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Performance Comparison โ
Total Elapsed Time: 343.05ms โ 261.40ms (-23.8%) ๐
Profiling Mode: timing - Execution duration of functions.
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| Function | Calls | Avg | P95 | Total | % Total |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| main | 1 โ 1 (+0.0%) | 342.37ms โ 260.73ms (-23.8%) ๐ | 342.62ms โ 260.83ms (-23.9%) ๐ | 342.37ms โ 260.73ms (-23.8%) ๐ | 100.00% โ 100.00% (+0.0%) |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::search::run | 1 โ 1 (+0.0%) | 291.10ms โ 204.16ms (-29.9%) ๐ | 291.24ms โ 204.21ms (-29.9%) ๐ | 291.10ms โ 204.16ms (-29.9%) ๐ | 85.02% โ 78.30% (-7.9%) |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| http_request | 1 โ 1 (+0.0%) | 226.98ms โ 199.18ms (-12.2%) | 227.02ms โ 199.23ms (-12.2%) | 226.98ms โ 199.18ms (-12.2%) | 66.29% โ 76.39% (+15.2%) |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::checks::check_nix_version | 1 โ 1 (+0.0%) | 50.68ms โ 55.94ms (+10.4%) | 50.69ms โ 55.97ms (+10.4%) | 50.68ms โ 55.94ms (+10.4%) | 14.80% โ 21.45% (+44.9%) โ ๏ธ |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::checks::verify_nix_environment | 1 โ 1 (+0.0%) | 50.68ms โ 55.94ms (+10.4%) | 50.69ms โ 55.97ms (+10.4%) | 50.68ms โ 55.94ms (+10.4%) | 14.80% โ 21.45% (+44.9%) โ ๏ธ |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::util::get_nix_version | 1 โ 1 (+0.0%) | 23.97ms โ 26.55ms (+10.8%) | 23.97ms โ 26.56ms (+10.8%) | 23.97ms โ 26.55ms (+10.8%) | 7.00% โ 10.18% (+45.4%) โ ๏ธ |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| ๏ธ๐๏ธ json_parse | 1 โ 0 (-100.0%) ๐ | 32.23ms โ 0.00ns (-100.0%) ๐ | 32.23ms โ 0.00ns (-100.0%) ๐ | 32.23ms โ 0.00ns (-100.0%) ๐ | 9.41% โ 0.00% (-100.0%) ๐ |
+------------------------------------+---------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
Generated with hotpath
๐ View Raw JSON Metrics
PR Metrics
{
"hotpath_profiling_mode": "timing",
"total_elapsed": 261399948,
"description": "Execution duration of functions.",
"caller_name": "main",
"output": {
"http_request": {
"calls": 1,
"avg": 199182376,
"p95": 199229439,
"total": 199182376,
"percent_total": 7639
},
"main": {
"calls": 1,
"avg": 260729287,
"p95": 260833279,
"total": 260729287,
"percent_total": 10000
},
"nh::checks::check_nix_version": {
"calls": 1,
"avg": 55936954,
"p95": 55967743,
"total": 55936954,
"percent_total": 2145
},
"nh::checks::verify_nix_environment": {
"calls": 1,
"avg": 55942454,
"p95": 55967743,
"total": 55942454,
"percent_total": 2145
},
"nh::util::get_nix_version": {
"calls": 1,
"avg": 26554078,
"p95": 26558463,
"total": 26554078,
"percent_total": 1018
},
"nh::search::run": {
"calls": 1,
"avg": 204158395,
"p95": 204210175,
"total": 204158395,
"percent_total": 7830
}
}
}
Main Branch Metrics
{
"hotpath_profiling_mode": "timing",
"total_elapsed": 343053759,
"description": "Execution duration of functions.",
"caller_name": "main",
"output": {
"json_parse": {
"calls": 1,
"avg": 32225480,
"p95": 32227327,
"total": 32225480,
"percent_total": 941
},
"nh::search::run": {
"calls": 1,
"avg": 291102049,
"p95": 291241983,
"total": 291102049,
"percent_total": 8502
},
"nh::util::get_nix_version": {
"calls": 1,
"avg": 23967247,
"p95": 23969791,
"total": 23967247,
"percent_total": 700
},
"nh::checks::verify_nix_environment": {
"calls": 1,
"avg": 50683244,
"p95": 50692095,
"total": 50683244,
"percent_total": 1480
},
"main": {
"calls": 1,
"avg": 342373131,
"p95": 342622207,
"total": 342373131,
"percent_total": 10000
},
"http_request": {
"calls": 1,
"avg": 226979558,
"p95": 227016703,
"total": 226979558,
"percent_total": 6629
},
"nh::checks::check_nix_version": {
"calls": 1,
"avg": 50675489,
"p95": 50692095,
"total": 50675489,
"percent_total": 1480
}
}
}
Performance Comparison โ
Total Elapsed Time: 333.47ms โ 348.01ms (+4.4%)
Profiling Mode: alloc_bytes_total - Cumulative bytes allocated during each function call (including nested calls).
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| Function | Calls | Avg | P95 | Total | % Total |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| main | 1 โ 1 (+0.0%) | 2.3 MB โ 2.3 MB (+0.0%) | 2.3 MB โ 2.3 MB (+0.0%) | 2.3 MB โ 2.3 MB (+0.0%) | 100.00% โ 100.00% (+0.0%) |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::checks::check_nix_version | 1 โ 1 (+0.0%) | 1017.8 KB โ 1017.8 KB (+0.0%) | 1018.0 KB โ 1018.0 KB (+0.0%) | 1017.8 KB โ 1017.8 KB (+0.0%) | 44.00% โ 44.00% (+0.0%) |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::checks::verify_nix_environment | 1 โ 1 (+0.0%) | 1017.8 KB โ 1017.8 KB (+0.0%) | 1018.0 KB โ 1018.0 KB (+0.0%) | 1017.8 KB โ 1017.8 KB (+0.0%) | 44.00% โ 44.00% (+0.0%) |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::search::run | 1 โ 1 (+0.0%) | 372.4 KB โ 372.4 KB (+0.0%) | 372.5 KB โ 372.5 KB (+0.0%) | 372.4 KB โ 372.4 KB (+0.0%) | 16.09% โ 16.09% (+0.0%) |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| json_parse | 1 โ 1 (+0.0%) | 152.3 KB โ 152.3 KB (+0.0%) | 152.4 KB โ 152.4 KB (+0.0%) | 152.3 KB โ 152.3 KB (+0.0%) | 6.58% โ 6.58% (+0.0%) |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| nh::util::get_nix_version | 1 โ 1 (+0.0%) | 824 B โ 824 B (+0.0%) | 824 B โ 824 B (+0.0%) | 824 B โ 824 B (+0.0%) | 0.03% โ 0.03% (+0.0%) |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
| http_request | 1 โ 1 (+0.0%) | 325 B โ 325 B (+0.0%) | 325 B โ 325 B (+0.0%) | 325 B โ 325 B (+0.0%) | 0.01% โ 0.01% (+0.0%) |
+------------------------------------+------------------+----------------------------------+----------------------------------+----------------------------------+------------------------------+
Generated with hotpath
๐ View Raw JSON Metrics
PR Metrics
{
"hotpath_profiling_mode": "alloc-bytes-total",
"total_elapsed": 348010696,
"description": "Cumulative bytes allocated during each function call (including nested calls).",
"caller_name": "main",
"output": {
"http_request": {
"calls": 1,
"avg": 325,
"p95": 325,
"total": 325,
"percent_total": 1
},
"nh::util::get_nix_version": {
"calls": 1,
"avg": 824,
"p95": 824,
"total": 824,
"percent_total": 3
},
"nh::checks::check_nix_version": {
"calls": 1,
"avg": 1042176,
"p95": 1042431,
"total": 1042176,
"percent_total": 4400
},
"nh::checks::verify_nix_environment": {
"calls": 1,
"avg": 1042176,
"p95": 1042431,
"total": 1042176,
"percent_total": 4400
},
"json_parse": {
"calls": 1,
"avg": 155968,
"p95": 156031,
"total": 155968,
"percent_total": 658
},
"main": {
"calls": 1,
"avg": 2368512,
"p95": 2369535,
"total": 2368512,
"percent_total": 10000
},
"nh::search::run": {
"calls": 1,
"avg": 381312,
"p95": 381439,
"total": 381312,
"percent_total": 1609
}
}
}
Main Branch Metrics
{
"hotpath_profiling_mode": "alloc-bytes-total",
"total_elapsed": 333466042,
"description": "Cumulative bytes allocated during each function call (including nested calls).",
"caller_name": "main",
"output": {
"nh::checks::verify_nix_environment": {
"calls": 1,
"avg": 1042176,
"p95": 1042431,
"total": 1042176,
"percent_total": 4400
},
"json_parse": {
"calls": 1,
"avg": 155968,
"p95": 156031,
"total": 155968,
"percent_total": 658
},
"main": {
"calls": 1,
"avg": 2368512,
"p95": 2369535,
"total": 2368512,
"percent_total": 10000
},
"nh::checks::check_nix_version": {
"calls": 1,
"avg": 1042176,
"p95": 1042431,
"total": 1042176,
"percent_total": 4400
},
"nh::search::run": {
"calls": 1,
"avg": 381312,
"p95": 381439,
"total": 381312,
"percent_total": 1609
},
"nh::util::get_nix_version": {
"calls": 1,
"avg": 824,
"p95": 824,
"total": 824,
"percent_total": 3
},
"http_request": {
"calls": 1,
"avg": 325,
"p95": 325,
"total": 325,
"percent_total": 1
}
}
}