MCPcopy Index your code
hub / github.com/blukai/haste

github.com/blukai/haste @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
422 symbols 894 edges 37 files 89 documented · 21%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

haste

world's fastest dota 2 and deadlock (the game) replay parser. more then two times faster than comically fast.

haste attempts to squeeze maximum single-core performance from the cpu, which enables efficient utilization of all cores for parsing multiple replays simultaneously.

haste does not want to be very user-friendly, it provides you with a relatively low-level access to correct usable data. it up to you how you structure your programs. you may choose to build your own nice api layer. anything is possible, theoretically even something as silly (i love silly) as ecs is doable (think of bevy game engine).

[!WARNING] there are many unsafes in the codebase, some are rational and explained, some need to be let go; public api isn't great and can be considered very unstable (e.g. it is not final and parts of it may change dramatically).

how to

examples

notable examples to check out for detailed usage:

  • deadlock-position demonstrates how to work with entities and how to get player (or any other entity, if desired) positions in deadlock (the game);
  • deadlock-gametime also demonstrates how to work with entities and how to compute game time (not a very straightforward thing to do, thanks valve).
  • dota2-allchat shows how to work with packet messages.

to run these examples navigate to haste directory and run

$ cargo run --example <example-name> -- <path-to-dem-file>

usage

to use haste in your project, you'll need either: - protoc (protocol buffer compiler) in your $PATH, or $PROTOC environment variable needs point to it - or cmake (if you don't have protoc, it will be compiled for you) and protobuf-src feature flag enabled

haste is not published to crates.io (yet?). you can add it to your Cargo.toml as a git dependency,

[dependencies]
haste = { git = "https://github.com/blukai/haste.git" }

haste's entity representatin is not debugger / print friendly, you would want to use haste-inspector (replay dev tools) to explore all the entities that are present in replays.

feature flags

  • broadcast: enables http broadcasts.
  • deadlock: enables deadlock protos and some utilities.
  • dota2: enabled dota2 protos and some utilities.
  • protobuf-src: enables protobuf_src crate which builds protoc.

benchmarks

TODO: benchmarks and comparisons with other projects such as clarity and manta.

to tease a bit.. as of 25-09-2024 in standard release build with no extra optimizations nor non-stadard memory allocators:

  • 31 minutes deadlock match can be parsed in ~660 ms with ~17.5 mb peak memory consumtion;
  • 38 minutes dota 2 captains mode match - in ~650 ms with ~18 mb peak memory consumtion.

run time is an average from 10 runs with no warmups. peak memory consumtion is time's maximum resident set size stat.

motivation, huh?

why create another replay parser? to prove myself that i'm right (long story; the proof was found quicly, but then i fell down the rabbit hole of further performance optimizations).

credits / references

valve's official repos and wiki provide quite a handful of useful information, but special credits go to invokr who worked on dotabuff/manta and to spheenik the creator of skadistats/clarity (i have not personally interacted with either of them).

other notable resources:

performance / profiling

and some more can probably be found across comments in the codebase.

Extension points exported contracts — how you extend this code

Visitor (Interface)
(no doc) [7 implementers]
crates/haste_core/src/parser.rs
MessageHandler (Interface)
(no doc) [1 implementers]
examples/messagehandler-experiment/handler.rs
HttpClient (Interface)
(no doc) [1 implementers]
crates/haste_broadcast/src/httpclient.rs
FieldDecode (Interface)
(no doc) [18 implementers]
crates/haste_core/src/fielddecoder.rs
Handler (Interface)
(no doc) [1 implementers]
examples/messagehandler-experiment/handler.rs
InternalFieldDecode (Interface)
(no doc) [6 implementers]
crates/haste_core/src/fielddecoder.rs
DemoStream (Interface)
(no doc) [3 implementers]
crates/haste_core/src/demostream.rs

Core symbols most depended-on inside this repo

push
called by 51
crates/haste_core/src/fieldpath.rs
read_ubit64
called by 42
crates/haste_core/src/bitreader.rs
get
called by 32
crates/haste_core/src/entities.rs
read_bool
called by 31
crates/haste_core/src/bitreader.rs
read_ubitvarfp
called by 28
crates/haste_core/src/bitreader.rs
inc_last
called by 28
crates/haste_core/src/fieldpath.rs
iter
called by 22
crates/haste_core/src/entities.rs
pop
called by 15
crates/haste_core/src/fieldpath.rs

Shape

Method 224
Function 92
Class 76
Enum 23
Interface 7

Languages

Rust100%

Modules by API surface

crates/haste_core/src/fieldpath.rs61 symbols
crates/haste_broadcast/src/broadcasthttp.rs32 symbols
crates/haste_core/src/parser.rs31 symbols
crates/haste_core/src/fielddecoder.rs31 symbols
crates/haste_core/src/entities.rs29 symbols
crates/haste_core/src/bitreader.rs25 symbols
crates/haste_core/src/stringtables.rs21 symbols
crates/haste_vartype/src/tokenizer.rs18 symbols
crates/haste_core/src/demofile.rs17 symbols
crates/haste_core/src/flattenedserializers.rs15 symbols
tools/huffmanfieldpath/src/main.rs14 symbols
crates/haste_broadcast/src/broadcastfile.rs12 symbols

For agents

$ claude mcp add haste \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact