From 84eb2ca6f0a1b513d9893a6afc7b985d2ff23f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 4 Jul 2022 23:15:16 +0300 Subject: [PATCH] change allocator to raw_c_allocator --- README.md | 9 ++++----- src/unix2db.zig | 8 +++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d89517f..aa72ea9 100644 --- a/README.md +++ b/README.md @@ -384,9 +384,9 @@ Profiling Prepare `profile.data`: ``` -zig build -Drelease-small=true -perf record --call-graph=dwarf \ - zig-out/bin/turbo-unix2db --passwd passwd2 --group group2 +zig build -Drelease-small=true && \ + perf record --call-graph=dwarf \ + zig-out/bin/turbo-unix2db --passwd passwd2 --group group2 ``` Perf interactive: @@ -398,8 +398,7 @@ perf report -i perf.data Flame graph: ``` -perf script | inferno-collapse-perf > stacks.folded -inferno-flamegraph stacks.folded > profile.svg +perf script | inferno-collapse-perf | inferno-flamegraph > profile.svg ``` [git-subtrac]: https://apenwarr.ca/log/20191109 diff --git a/src/unix2db.zig b/src/unix2db.zig index 761b06b..05fbb92 100644 --- a/src/unix2db.zig +++ b/src/unix2db.zig @@ -3,9 +3,9 @@ const fs = std.fs; const io = std.io; const mem = std.mem; const os = std.os; +const heap = std.heap; const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; -const GeneralPurposeAllocator = std.heap.GeneralPurposeAllocator; const flags = @import("flags.zig"); const User = @import("User.zig"); @@ -26,14 +26,12 @@ const usage = pub fn main() !void { // This line is here because of https://github.com/ziglang/zig/issues/7807 const argv: []const [*:0]const u8 = os.argv; - var gpa = GeneralPurposeAllocator(.{}){}; - defer gpa.deinit(); - const allocator = gpa.allocator(); + const gpa = heap.raw_c_allocator; const stderr = io.getStdErr().writer(); const stdout = io.getStdOut().writer(); - const return_code = execute(allocator, stdout, stderr, argv[1..]); + const return_code = execute(gpa, stdout, stderr, argv[1..]); os.exit(return_code); }