Open spiderkeys opened 4 months ago
That doesn't look right. I tested the time SDL_INIT_HAPTIC
takes and it was under 64ms. Try SDL_InitSubSystem
to separate the init process.
Which platform are you running this on?
Also, SDL_INIT_GAMEPAD
took 57ms to complete on my low-end Windows system .
This is on Ubuntu 22.04.
SDL_INIT_GAMEPAD only exists in main
, not the SDL2 branch. Also, I think the libudev issues/changes would have only ever affected Linux.
I re-ran the tests using SDL_InitSubSystem
and got (roughly) the same results:
spdlog::info("a" );
// Initialize SDL
auto ret = SDL_Init(0);
if (ret < 0) {
throw std::runtime_error(std::string("Failed to initialize SDL: ") + std::string(SDL_GetError()));
}
spdlog::info("b" );
ret = SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
if (ret < 0) {
throw std::runtime_error(std::string("Failed to initialize SDL game controller: ") + std::string(SDL_GetError()));
}
spdlog::info("c" );
ret = SDL_InitSubSystem(SDL_INIT_HAPTIC);
if (ret < 0) {
throw std::runtime_error(std::string("Failed to initialize SDL haptic: ") + std::string(SDL_GetError()));
}
spdlog::info("d" );
[04:35:57.102][info]: a
[04:35:57.102][info]: b
[04:35:57.503][info]: c
[04:35:58.642][info]: d
401ms for GAME_CONTROLLER, 1.139s for HAPTIC.
Looking at the haptic code it looks like it would benefit from the same speedup approach that we used with joysticks. I'll throw this on the 3.2 list. Feel free to submit a PR if you get to it before we do!
We are scoping work for the SDL 3.2.0 release, so please let us know if this is a showstopper for you.
I was testing performance improvements made by PR #9450 , and noticed that there is also a significant initialization block when you initialize
SDL_INIT_HAPTIC
.I performed tests using:
and
Tests were performed on the
2.28.5
release (pre-libudev PR) and my patched version of the SDL2 branch (#10411).Results:
This showed the expected speedup when it came to Joystick initialization/device enumeration, but I was surprised to see the Haptic initialization adding another second to the init time. This may be expected, or may be a case for another performance improvement, similar to the joystick init. Just wanted to share this observation either way, as it is a significant amount of time that can delay your app in non-trivial ways.