Skip to content

Conversation

@MisterPuma80
Copy link

Replaced slow binary tree search with simpler/faster hash map lookup. This also updates the ucaps_fetch.py script that generates the ucaps.h file.

Benchmark String to_lower/to_upper TLDR:

~27% faster small strings
~209% faster medium strings
~280% faster long strings

Replaced slow binary tree search with simpler/faster hash map lookup.
@MisterPuma80
Copy link
Author

Benchmarks 4.5 before changes

String::to_lower short string, average ns: 42
String::to_lower medium string, average ns: 138
String::to_lower long, average ns: 830

String::to_upper short string, average ns: 40
String::to_upper medium string, average ns: 122
String::to_upper long string, average ns: 721

Benchmarks 4.5 with changes

String::to_lower short string, average ns: 33
String::to_lower medium string, average ns: 66
String::to_lower long string, average ns: 296

String::to_upper short string, average ns: 33
String::to_upper medium string, average ns: 63
String::to_upper long string, average ns: 270

@MisterPuma80
Copy link
Author

Here is the benchmark script in a C++ GDExtention app.
example_gdextention.zip

@MisterPuma80
Copy link
Author

When I want to run the benchmark, I essentially run a shellscript like this to build everything. Obviously this will depend on your setup.

# Download blazium
git clone https://github.com/blazium-engine/blazium
cd blazium
git checkout blazium-4.5
git submodule update --init --remote --recursive
# FIXME: Add any changes to the engine here ......
cd ..

# Download export templates
git clone https://github.com/blazium-engine/blazium-cpp

# Build engine and release templates
cd blazium
scons platform=linuxbsd target=editor dev_build=no dev_mode=no use_llvm=yes linker=mold tests=yes execinfo=yes scu_build=yes dotnet=yes -j 25
scons platform=linuxbsd target=template_release dev_build=no dev_mode=no use_llvm=yes linker=mold scu_build=yes -j 25
cd ..

# Dump fresh API json file and header from Blazium Editor
cd blazium-cpp/gdextension
rm -f extension_api.json
rm -f gdextension_interface.h
../../blazium/bin/blazium.linuxbsd.editor.x86_64.llvm --headless --dump-extension-api --dump-gdextension-interface
cd ../..

# Build benchmark extention
scons platform=linux target=template_release dev_build=no use_llvm=yes -j 25
./blazium/bin/blazium.linuxbsd.editor.x86_64.llvm --headless --export-release "Benchmarks Headless Linux" ./demo/project.godot

# Run benchmark
./demo/export/demo.x86_64 --no-header --headless --single-threaded-scene --fixed-fps 60 --delta-smoothing disable --disable-vsync --disable-render-loop

@jss2a98aj
Copy link

I wonder if bit manipulation on certain ranges might be any faster. Regardless, will run some benchmarks on my system after I do the next round of cherry-picks.

@MisterPuma80
Copy link
Author

I bet we can make it way faster, but I didn't want to change the structure too much from upstream. Not yet anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants