Skip to content

Use std::from_chars in IO::stod function - #4482

Closed
alexbeattie42 wants to merge 2 commits into
opensim-org:mainfrom
gateway240:alex/io-stod-v2
Closed

alexbeattie42 wants to merge 2 commits into
opensim-org:mainfrom
gateway240:alex/io-stod-v2

Conversation

@alexbeattie42

@alexbeattie42 alexbeattie42 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes issue #3924

Brief summary of changes

Previously in this PR, I implemented the IO::stod method using std::istringstream. Today I was working on code that processes many trials in parallel and heavily uses the TimeSeriesTable class to read in files. In my environment it was painfully slow, and after some profiling I found it was spending most of the time in IO::stod. I implemented the same functionality using std::from_chars which is much lighter and is not location sensitive for numerics (the point of the original issue). I timed it and running the same code (processing ~1200 files in parallel) produced the following results:
Currently: 2,620 seconds (~43 minutes)
With std::from_chars (this PR): 90 seconds
For this system, using std::from_chars was around 30x faster.

Testing I've completed

  • Tested locally
  • CI tests already cover this

Looking for feedback on...

  • Apple Clang on macos-15 does not support std::from_chars for floating point. Others have done shims for this. The clang version in the macos-26 runner appears to have the support.

AI/LLM use

None. Followed this cppreference example for implementation.

CHANGELOG.md (choose one)

  • no need to update because...
  • updated.

Please review the CONTRIBUTING.md file for detailed contributing guidelines.


This change is Reviewable

@alexbeattie42

alexbeattie42 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

As of now, std::from_chars is not supported on macOS.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant