Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chg: build.rs(for vc runtime) to rustflags in config.toml and replace default global memory allocator with mimalloc. #777

Merged
merged 10 commits into from
Oct 24, 2022
Merged
31 changes: 31 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[target.'cfg(all(target_os="windows", target_env = "msvc", target_arch = "x86_64"))']
rustflags = [
"-L", "link-search=native=./cargo/msvcrt.lib",
"-C", "link-arg=/NODEFAULTLIB:libvcruntimed.lib",
"-C", "link-arg=/NODEFAULTLIB:vcruntime.lib",
"-C", "link-arg=/NODEFAULTLIB:vcruntimed.lib",
"-C", "link-arg=/NODEFAULTLIB:libcmtd.lib",
"-C", "link-arg=/NODEFAULTLIB:msvcrt.lib",
"-C", "link-arg=/NODEFAULTLIB:msvcrtd.lib",
"-C", "link-arg=/NODEFAULTLIB:libucrt.lib",
"-C", "link-arg=/NODEFAULTLIB:libucrtd.lib",
"-C", "link-arg=/DEFAULTLIB:libcmt.lib",
"-C", "link-arg=/DEFAULTLIB:libvcruntime.lib",
"-C", "link-arg=/DEFAULTLIB:ucrt.lib",
]

[target.'cfg(all(target_os="windows", target_env = "msvc", target_arch = "x86"))']
rustflags = [
"-C", "target-feature=+crt-static",
"-C", "link-arg=/NODEFAULTLIB:libvcruntimed.lib",
"-C", "link-arg=/NODEFAULTLIB:vcruntime.lib",
"-C", "link-arg=/NODEFAULTLIB:vcruntimed.lib",
"-C", "link-arg=/NODEFAULTLIB:libcmtd.lib",
"-C", "link-arg=/NODEFAULTLIB:msvcrt.lib",
"-C", "link-arg=/NODEFAULTLIB:msvcrtd.lib",
"-C", "link-arg=/NODEFAULTLIB:libucrt.lib",
"-C", "link-arg=/NODEFAULTLIB:libucrtd.lib",
"-C", "link-arg=/DEFAULTLIB:libcmt.lib",
"-C", "link-arg=/DEFAULTLIB:libvcruntime.lib",
"-C", "link-arg=/DEFAULTLIB:ucrt.lib",
]
Binary file added .cargo/msvcrt.lib
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- {
os: "windows-latest",
target: "i686-pc-windows-msvc",
cross: false,
cross: true,
}
runs-on: ${{ matrix.info.os }}
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG-Japanese.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- JSONの出力の中にある各検知内容のオブジェクトを持つ不要な配列の構造を削除した。 (#766)(@hitenkoku)
- プロファイルで出力できる情報にルール作成者(`%RuleAuthor%`)、 ルール作成日(`%RuleCreationDate%`)、 ルール修正日(`%RuleModifiedDate%`)、ルールステータス(`%Status%`)を追加した。 (#761) (@hitenkoku)
- JSON出力のDetailsフィールドをオブジェクト形式で出力するように変更した。 (#773) (@hitenkoku)
- `build.rs`を削除し、メモリアロケータをmimallocに変更した。Intel系OSでは20-30%の速度向上が見込める。 (#657) (@fukusuket)
- プロファイルの`%RecordInformation%` エイリアスを `%AllFieldInfo%` に変更した。 AllFieldInfoフィールドをJSONオブジェクト形式で出力するように変更した。 (#750) (@hitenkoku)

**バグ修正:**
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Removed unnecessary array structure in the JSON output. (#766)(@hitenkoku)
- Added rule authors (`%RuleAuthor%`), rule creation date (`%RuleCreationDate%`), rule modified date (`%RuleModifiedDate%`), and rule status (`%Status%`) fields to output profiles. (#761) (@hitenkoku)
- Changed Details field in JSON output to object. (#773) (@hitenkoku)
- Removed `build.rs` and changed the memory allocator to mimalloc for a speed increase of 20-30% on Intel-based OSes. (#657) (@fukusuket)
- Replaced %RecordInformation% alias in profile to %AllFieldInfo%, and changed AllFieldInfo field in JSON output to object. (#750) (@hitenkoku)

**Bug Fixes:**
Expand Down
26 changes: 19 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ comfy-table = "6.*"
pulldown-cmark = { version = "0.9.*", default-features = false, features = ["simd"] }
reqwest = {version = "0.11.*", features = ["blocking", "json"]}
horrorshow = "0.8.*"

[build-dependencies]
static_vcruntime = "2.*"
mimalloc = { version = "*", default-features = false }

[dev-dependencies]
rand = "0.8.*"
Expand Down
4 changes: 0 additions & 4 deletions build.rs

This file was deleted.

4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use hayabusa::{afterfact::after_fact, detections::utils};
use hayabusa::{detections::configs, timeline::timelines::Timeline};
use hayabusa::{detections::utils::write_color_buffer, filter};
use hhmmss::Hhmmss;
use mimalloc::MiMalloc;
use pbr::ProgressBar;
use serde_json::Value;
use std::ffi::{OsStr, OsString};
Expand All @@ -49,6 +50,9 @@ use tokio::task::JoinHandle;
#[cfg(target_os = "windows")]
use is_elevated::is_elevated;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

// 一度にtimelineやdetectionを実行する行数
const MAX_DETECT_RECORDS: usize = 5000;

Expand Down