Skip to content

Conversation

@elinor-fung
Copy link
Member

@elinor-fung elinor-fung commented Jun 2, 2021

Cut out a bunch of unnecessary string copies:

  • Avoid string building for logging versions when logging isn't enabled
  • Switch to pal::char_t* for some static string literals
  • Switch to pal::char_t* for pal::to_lower (that's actually what the callers had - we were just forcing them all to create an extra string for no reason)

On Windows, this was about ~3k fewer allocations for launching a console app.

Tried some really rough printf timing on Windows - not sure the best way to do this - I just used std::chrono::system_clock to add print lines and averaged over 30 launches. So all grains of salt with these numbers, but it seemed a bit improved on my machine:

corehost_main to coreclr_t::create before loading coreclr (us) hostfxr_main_startupinfo to coreclr_t::create before loading coreclr (us)
before 15,710.33 18,556.77
after 13,611.60 16,600.07

@ghost
Copy link

ghost commented Jun 2, 2021

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details

Cut out a bunch of unnecessary string copies:

  • Avoid string building for logging versions when logging isn't enabled
  • Switch to pal::char_t* for same static string literals
  • Switch to pal::char_t* for pal::to_lower (that's actually what the callers had - we were just forcing them all to create an extra string for no reason)

On Windows, this was about ~3k allocations for launching a console app.

Author: elinor-fung
Assignees: -
Labels:

area-Host

Milestone: -

@elinor-fung elinor-fung requested a review from vitek-karas June 2, 2021 20:06
@elinor-fung elinor-fung merged commit 483fc90 into dotnet:main Jun 2, 2021
@elinor-fung elinor-fung deleted the lessStrings branch June 2, 2021 22:40
@ghost ghost locked as resolved and limited conversation to collaborators Jul 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants