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

Improve performance when writing lp and reading sol files #9

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

mbiggio
Copy link

@mbiggio mbiggio commented Mar 19, 2024

We improve the performance of the solution file parser in the case of cplex, by making use of the more performant quick-xml crate and buffering the reads through BufReader.
quick-xml indeed requires the reader to be buffered, probably to avoid making too many read syscalls.

Buffering is also applied to writing the lp file. Manual benchmarks are showing significant improvements over non-buffered read/writes for problem sizes of several thousands of variables

@mbiggio mbiggio force-pushed the wip/mbiggio/improve-io-perf branch from f9c60eb to 606552d Compare March 19, 2024 16:54
@mbiggio
Copy link
Author

mbiggio commented Mar 19, 2024

Lemme know if it might be worth adding some specific benchmark, maybe with some non-trivial .sol file to parse.

Anyway, just to provide some numbers, on my machine (Intel i5 processor, 10 cores, 32 GB RAM), solving a problem with:

  • 184047 variables
  • 306801 constraints

takes:

  • ~13s without this commit
  • ~8s with this commit

so a considerable amount of time was spent in IO, and this IO time is probably going to be proportional to the problem size

@mbiggio mbiggio force-pushed the wip/mbiggio/improve-io-perf branch from 606552d to 7bd14f8 Compare March 19, 2024 17:29
Copy link
Contributor

@lovasoa lovasoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great ! But could you remove the dependency to xml-rs completely ?

We improve the performance of the solution file parser in the case of
cplex, by making use of the more performant quick-xml crate and
buffering the reads through `BufReader`. quick-xml indeed requires the
reader to be buffered, probably to avoid making too many read syscalls.

Buffering is also applied to writing the lp file. Manual benchmarks are
showing significant improvements over non-buffered read/writes for
problem sizes of several thousands of variables
@mbiggio mbiggio force-pushed the wip/mbiggio/improve-io-perf branch from 7bd14f8 to 2b1e5af Compare March 19, 2024 17:33
@lovasoa lovasoa merged commit 29d3b13 into rust-or:master Mar 19, 2024
2 checks passed
@lovasoa
Copy link
Contributor

lovasoa commented Mar 19, 2024

Merged; thank you!

@mbiggio
Copy link
Author

mbiggio commented Mar 20, 2024

Merged; thank you!

You're welcome!

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.

2 participants