perf(findr): Added spall support.
This commit is contained in:
@@ -6,6 +6,9 @@ import "core:os"
|
|||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
|
prof_init()
|
||||||
|
defer prof_destroy()
|
||||||
|
|
||||||
args := os.args
|
args := os.args
|
||||||
|
|
||||||
opts: WalkOptions
|
opts: WalkOptions
|
||||||
|
|||||||
64
prof.odin
Normal file
64
prof.odin
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package findr
|
||||||
|
|
||||||
|
import "base:runtime"
|
||||||
|
import "core:prof/spall"
|
||||||
|
import "core:sync"
|
||||||
|
|
||||||
|
SPALL_ENABLED :: #config(SPALL_ENABLED, ODIN_DEBUG)
|
||||||
|
|
||||||
|
spall_ctx: spall.Context
|
||||||
|
|
||||||
|
@(thread_local) spall_buffer: spall.Buffer
|
||||||
|
@(thread_local) spall_backing: []u8
|
||||||
|
|
||||||
|
@(instrumentation_enter)
|
||||||
|
spall_enter :: proc "contextless" (
|
||||||
|
proc_address, call_site_return_address: rawptr,
|
||||||
|
loc: runtime.Source_Code_Location,
|
||||||
|
) {
|
||||||
|
when SPALL_ENABLED {
|
||||||
|
spall._buffer_begin(&spall_ctx, &spall_buffer, "", "", loc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@(instrumentation_exit)
|
||||||
|
spall_exit :: proc "contextless" (
|
||||||
|
proc_address, call_site_return_address: rawptr,
|
||||||
|
loc: runtime.Source_Code_Location,
|
||||||
|
) {
|
||||||
|
when SPALL_ENABLED {
|
||||||
|
spall._buffer_end(&spall_ctx, &spall_buffer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prof_init :: proc() {
|
||||||
|
when SPALL_ENABLED {
|
||||||
|
spall_ctx = spall.context_create_with_scale("findr.spall", false, 1.0)
|
||||||
|
spall_backing = make([]u8, spall.BUFFER_DEFAULT_SIZE)
|
||||||
|
spall_buffer = spall.buffer_create(spall_backing, u32(sync.current_thread_id()))
|
||||||
|
spall._buffer_name_thread(&spall_ctx, &spall_buffer, "main")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prof_destroy :: proc() {
|
||||||
|
when SPALL_ENABLED {
|
||||||
|
spall.buffer_destroy(&spall_ctx, &spall_buffer)
|
||||||
|
delete(spall_backing)
|
||||||
|
spall.context_destroy(&spall_ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prof_thread_init :: proc(name: string) {
|
||||||
|
when SPALL_ENABLED {
|
||||||
|
spall_backing = make([]u8, spall.BUFFER_DEFAULT_SIZE)
|
||||||
|
spall_buffer = spall.buffer_create(spall_backing, u32(sync.current_thread_id()))
|
||||||
|
spall._buffer_name_thread(&spall_ctx, &spall_buffer, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prof_thread_destroy :: proc() {
|
||||||
|
when SPALL_ENABLED {
|
||||||
|
spall.buffer_destroy(&spall_ctx, &spall_buffer)
|
||||||
|
delete(spall_backing)
|
||||||
|
}
|
||||||
|
}
|
||||||
13
profile.sh
Executable file
13
profile.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
|
||||||
|
echo "Building findr-prof..."
|
||||||
|
odin build "$DIR" -debug -out:"$DIR/findr-prof"
|
||||||
|
|
||||||
|
echo "Running profiler..."
|
||||||
|
"$DIR/findr-prof" -E .git -E .jj -HI ~/git.verticalaxion.com
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Spall trace: $DIR/findr.spall"
|
||||||
@@ -145,6 +145,9 @@ walk :: proc(roots: []string, results: ^[dynamic]string, opts: WalkOptions, thre
|
|||||||
walk_worker :: proc(t: ^thread.Thread) {
|
walk_worker :: proc(t: ^thread.Thread) {
|
||||||
pool := cast(^WalkerPool)t.data
|
pool := cast(^WalkerPool)t.data
|
||||||
|
|
||||||
|
prof_thread_init("walker")
|
||||||
|
defer prof_thread_destroy()
|
||||||
|
|
||||||
local_results := make([dynamic]string, 0, 256)
|
local_results := make([dynamic]string, 0, 256)
|
||||||
defer delete(local_results)
|
defer delete(local_results)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user