-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor and optimize archive and manifest handling with benchmarks #2
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
Open
thesprockee
wants to merge
12
commits into
main
Choose a base branch
from
enhance/performance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ba4a7c4
Add benchmark tests for optimization analysis
thesprockee d704874
Refactor to idiomatic Go project structure
thesprockee 5982968
Optimize binary encoding/decoding for major performance gains
thesprockee ea9445e
Optimize extraction and reduce allocations (iteration 2)
thesprockee 8530f5d
Reduce allocations with buffer reuse (iteration 3)
thesprockee 5435f23
Remove obsolete benchmark log files to streamline performance analysis
thesprockee 7b9ef79
Reorganize to idiomatic Go project structure
thesprockee d79bb7f
Add option to use decimal filenames instead of hex
thesprockee 50a4eed
Add extracted directory to .gitignore
thesprockee 02919a6
Update .gitignore to include 'bin/' and remove 'extracted/' directory…
thesprockee 19bdc30
Use uint64 for hex filename formatting
thesprockee 67e01c7
Fix code review issues
thesprockee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,44 @@ | ||
| # If you prefer the allow list template instead of the deny list, see community template: | ||
| # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
| # | ||
| # Binaries for programs and plugins | ||
| *.exe | ||
| *.exe~ | ||
| *.dll | ||
| *.so | ||
| *.dylib | ||
|
|
||
| # Test binary, built with `go test -c` | ||
| *.test | ||
|
|
||
| # Code coverage profiles and other test artifacts | ||
| *.out | ||
| coverage.* | ||
| *.coverprofile | ||
| profile.cov | ||
|
|
||
| # Dependency directories (remove the comment below to include it) | ||
| # vendor/ | ||
|
|
||
| # Go workspace file | ||
| go.work | ||
| go.work.sum | ||
|
|
||
| # env file | ||
| .env | ||
|
|
||
| # Editor/IDE | ||
| # .idea/ | ||
| # .vscode/ | ||
|
|
||
|
|
||
| Editing/ | ||
| debugging/ | ||
| manifests/ | ||
| unusual/ | ||
| norm/ | ||
| *.exe | ||
| *.json | ||
| output/ | ||
| /extracted/ | ||
| bin/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| .PHONY: help build test bench clean install fmt lint check | ||
|
|
||
| # Default target - show help | ||
| .DEFAULT_GOAL := help | ||
|
|
||
| # Show available targets | ||
| help: | ||
| @echo "evrFileTools - EVR package/manifest tool" | ||
| @echo "" | ||
| @echo "Usage: make [target]" | ||
| @echo "" | ||
| @echo "Targets:" | ||
| @echo " build Build the CLI tool to bin/evrtools" | ||
| @echo " test Run all tests" | ||
| @echo " bench Run benchmarks" | ||
| @echo " bench-compare Run benchmarks with multiple iterations" | ||
| @echo " clean Remove build artifacts" | ||
| @echo " install Install CLI tool via go install" | ||
| @echo " fmt Format code" | ||
| @echo " lint Run go vet" | ||
| @echo " check Run fmt, lint, and test" | ||
|
|
||
| # Build the CLI tool | ||
| build: | ||
| go build -o bin/evrtools ./cmd/evrtools | ||
|
|
||
| # Run all tests | ||
| test: | ||
| go test -v ./pkg/... | ||
|
|
||
| # Run benchmarks | ||
| bench: | ||
| go test -bench=. -benchmem -benchtime=1s ./pkg/... | ||
|
|
||
| # Run benchmarks with comparison | ||
| bench-compare: | ||
| go test -bench=. -benchmem -count=5 ./pkg/... | ||
|
|
||
| # Clean build artifacts | ||
| clean: | ||
| rm -rf bin/ | ||
|
|
||
| # Install the CLI tool | ||
| install: | ||
| go install ./cmd/evrtools | ||
|
|
||
| # Format code | ||
| fmt: | ||
| go fmt ./... | ||
|
|
||
| # Lint code | ||
| lint: | ||
| go vet ./... | ||
|
|
||
| # Check for common issues | ||
| check: fmt lint test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,155 @@ | ||
| thank you Exhibitmark for doing the hard work and making [carnation](https://github.com/Exhibitmark/carnation), saved me a lot of headache reversing the manifest format :) | ||
| # evrFileTools | ||
|
|
||
| tool i ~~not so~~ quickly threw together to modify any file(s) in an EVR manifest/package combo. | ||
| Barely in a working state, please cut me some slack while i clean this up | ||
| A Go library and CLI tool for working with EVR (Echo VR) package and manifest files. | ||
|
|
||
| extracting files example: | ||
| > Thanks to [Exhibitmark](https://github.com/Exhibitmark) for [carnation](https://github.com/Exhibitmark/carnation) which helped with reversing the manifest format! | ||
| ## Features | ||
|
|
||
| - Extract files from EVR packages | ||
| - Build new packages from extracted files | ||
| - Read and write EVR manifest files | ||
| - ZSTD compression/decompression with optimized context reuse | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| go install github.com/EchoTools/evrFileTools/cmd/evrtools@latest | ||
| ``` | ||
|
|
||
| Or build from source: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/EchoTools/evrFileTools.git | ||
| cd evrFileTools | ||
| make build | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Extract files from a package | ||
|
|
||
| ```bash | ||
| evrtools -mode extract \ | ||
| -data ./ready-at-dawn-echo-arena/_data/5932408047/rad15/win10 \ | ||
| -package 48037dc70b0ecab2 \ | ||
| -output ./extracted | ||
| ``` | ||
| evrFileTools -mode extract -packageName 48037dc70b0ecab2 -dataDir ./ready-at-dawn-echo-arena/_data/5932408047/rad15/win10 -outputDir ./output/ | ||
|
|
||
| This extracts all files from the package. Output structure: | ||
| - `./output/<typeSymbol>/<fileSymbol>` | ||
|
|
||
| With `-preserve-groups`, frames are preserved: | ||
| - `./output/<frameIndex>/<typeSymbol>/<fileSymbol>` | ||
|
|
||
| ### Build a package from files | ||
|
|
||
| ```bash | ||
| evrtools -mode build \ | ||
| -input ./files \ | ||
| -output ./output \ | ||
| -package mypackage | ||
| ``` | ||
| this will extract and write out every file contained in the package to outputFolder. | ||
| the names of the subfolders created in outputFolder are the filetype symbols, the files contained within are named with their respective symbols. | ||
|
|
||
| If the `-outputPreserveGroups` flag is provided, there will be folders created to seperate each frame. This is currently the directory structure that `-mode build` expects. | ||
| Expected input structure: `./input/<frameIndex>/<typeSymbol>/<fileSymbol>` | ||
|
|
||
| ### CLI Options | ||
|
|
||
| | Flag | Description | | ||
| |------|-------------| | ||
| | `-mode` | Operation mode: `extract` or `build` | | ||
| | `-data` | Path to _data directory containing manifests/packages | | ||
| | `-package` | Package name (e.g., `48037dc70b0ecab2`) | | ||
| | `-input` | Input directory for build mode | | ||
| | `-output` | Output directory | | ||
| | `-preserve-groups` | Preserve frame grouping in extract output | | ||
| | `-force` | Allow non-empty output directory | | ||
|
|
||
| ## Library Usage | ||
|
|
||
| ```go | ||
| package main | ||
|
|
||
| replacing files example: | ||
| import ( | ||
| "log" | ||
| "github.com/EchoTools/evrFileTools/pkg/manifest" | ||
| ) | ||
|
|
||
| func main() { | ||
| // Read a manifest | ||
| m, err := manifest.ReadFile("/path/to/manifests/packagename") | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| log.Printf("Manifest: %d files in %d packages", m.FileCount(), m.PackageCount()) | ||
|
|
||
| // Open the package files | ||
| pkg, err := manifest.OpenPackage(m, "/path/to/packages/packagename") | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| defer pkg.Close() | ||
|
|
||
| // Extract all files | ||
| if err := pkg.Extract("./output"); err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| } | ||
| ``` | ||
| echoFileTools -mode replace -outputDir ./output/ -packageName 48037dc70b0ecab2 -dataDir ./ready-at-dawn-echo-arena/_data/5932408047/rad15/win10 -inputDir ./input/ | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| evrFileTools/ | ||
| ├── cmd/ | ||
| │ └── evrtools/ # CLI application | ||
| ├── pkg/ | ||
| │ ├── archive/ # ZSTD archive format | ||
| │ │ ├── header.go # Archive header (24 bytes) | ||
| │ │ ├── reader.go # Streaming decompression | ||
| │ │ └── writer.go # Streaming compression | ||
| │ └── manifest/ # EVR manifest/package handling | ||
| │ ├── manifest.go # Manifest types and binary encoding | ||
| │ ├── package.go # Multi-part package extraction | ||
| │ ├── builder.go # Package building from files | ||
| │ └── scanner.go # Input directory scanning | ||
| ├── Makefile | ||
| └── go.mod | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ```bash | ||
| # Build | ||
| make build | ||
|
|
||
| # Run tests | ||
| make test | ||
|
|
||
| # Run benchmarks | ||
| make bench | ||
|
|
||
| # Format and lint | ||
| make check | ||
| ``` | ||
| Directory structure of inputDir while using `-mode replace` should be `./inputFolder/0/...`, where ... is the structure of `-mode extract` *without* the `-outputPreserveGroups` flag. | ||
|
|
||
| e.g. if replacing the Echo VR logo DDS, the stucture would be as follows: `./input/0/-4707359568332879775/-3482028914369150717` | ||
| ## Performance | ||
|
|
||
| The library uses several optimizations: | ||
|
|
||
| - **Direct binary encoding** instead of reflection-based `binary.Read/Write` | ||
| - **Pre-allocated buffers** for zero-allocation encoding paths | ||
| - **ZSTD context reuse** for ~4x faster decompression with zero allocations | ||
| - **Frame index maps** for O(1) file lookups during extraction | ||
| - **Directory caching** to minimize syscalls | ||
|
|
||
| Run benchmarks to see current performance: | ||
|
|
||
| ```bash | ||
| go test -bench=. -benchmem ./pkg/... | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| if a file with the same filetype symbol & filename symbol exists in the manifest, it will edit the manifest & package file to match, and write out the contents of both to outputDir. | ||
| MIT License - see LICENSE file | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /mnt/c/OculusLibrary/Software/ready-at-dawn-echo-arena/_data/5932408047/rad15/win10/ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.