Skip to content
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

Benchmarks: Fix compile error caused by custom std::string allocator. #490

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

mwl4
Copy link
Contributor

@mwl4 mwl4 commented Jul 27, 2023

It is possible to set custom allocator for std::string in Include/RmlUi/Config/Config.h:

using String = std::basic_string<char, std::char_traits<char>, MyAllocator<char>>;

ankerl::nanobench::Bench::run expects as first parameter either char const* or std::string const&.
With custom allocator, String type cannot be implicitly converted to std::string.

…it is impossible to pass it to nanobench library as value.
@mikke89 mikke89 added the build Build system and compilation label Jul 27, 2023
@mikke89 mikke89 merged commit 7d8fc2b into mikke89:master Jul 27, 2023
13 checks passed
@mikke89
Copy link
Owner

mikke89 commented Jul 27, 2023

Thanks again! I'm curios to ask, is there any specific reason you are running the benchmarks with your own config file?

@mwl4
Copy link
Contributor Author

mwl4 commented Jul 27, 2023

@mikke89 As comment in Config.h says:

 * This file provides the means to configure various types used across RmlUi. It is possible to override container
 * types with your own, provided they are compatible with STL, or customize STL containers, for example by setting
 * custom allocators.

If I am allowed to override container type with my own, then performance of the whole library will be different. It is good to know how different.

@mikke89
Copy link
Owner

mikke89 commented Jul 27, 2023

That's a very good reason! Do you have some results you could share perhaps, found anything that improves it significantly?

@mwl4
Copy link
Contributor Author

mwl4 commented Jul 28, 2023

During frame profiling I have noticed that updating data model triggers update that takes 6 ms on high-spec hardware. In most of the samples (callstacks) allocation is apparent. I walked through the code, and there is a lot of strings involved in layout update.

For now I will try two things:

  1. larger String SSO capacity - MSVC std::string implementation allows up to 15 characters being held in SSO buffer. I can try to implement my own String with larger buffer and see if it helps anything.
  2. custom allocator for String - Rml is single threaded library, allocator might take advantage of this fact and return required buffer faster than standard operator new.

@mwl4 mwl4 deleted the benchmark_compile_error branch August 22, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system and compilation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants