Skip to content

[FEATURE] faster number conversion to String using Boost::Karma - #3969

Merged
timosachsenberg merged 11 commits into
OpenMS:developfrom
cbielow:num2string_fast
Feb 20, 2019
Merged

timosachsenberg merged 11 commits into
OpenMS:developfrom
cbielow:num2string_fast

Conversation

@cbielow

@cbielow cbielow commented Feb 13, 2019 •

Copy link
Copy Markdown
Contributor

solves #3962

here are some additional benchmarks for writing larger idXML and featureXML files:

IDFileConverter on 320 MB IdXML file

Win:
old: 20.89 s
new: 12.59 s (-40%, 6% size increase)

Linux:
old: 14.21 s
new: 10.63 s (-26%, 6% size increase)

FileConverter on 192 MB FeatureXML file

Win:
old: 31.16 s
new: 25.78 s (-18%, 3.5% size increase)

Linux:
old: 27.96 s
new: 25.85 s (-8%, 3.5% size increase)

The increase in featureXML is simply not that large because I did not look at the writer code (i.e. using the new String conversion instead of default ... << double << ...). All benefits are implicit.

Windows benefits the most, since the stream operators were very inefficient. Its not that bad with GCC, but the speed still increases.

Edit: FuzzyDiff runs about 3x faster (Release build) now as well, after switching to Boost::Qi instead of stringstream::operator >> (which was required since we hit an AppleClang compiler bug which makes clang interpret 5e6 as 5 and then stop reading from the stream; this was not a problem before since all our output looked like this. Now with Boost::Karma we write 5.0e6 which clang reads in full; Boost::Qi just reads both input formats just fine).

After this PR is merged, it is advised to maximize writing speed when outputting files like this:

os << String(int/float/double) << ... instead of just the slower os << int/float/double << ....
This will give you full precision by default for float and doubles. If you only need up to three fractional digits use String(my_number, false), i.e. full_precision = false.

@hroest

hroest commented Feb 13, 2019 •

Copy link
Copy Markdown
Contributor

looks great, that should be a real improvement!

Can you look at these failed tests: https://travis-ci.org/OpenMS/OpenMS/jobs/492738641

The following tests FAILED:
	142 - ConsensusXMLFile_test (Failed)
	156 - IdXMLFile_test (Failed)
	160 - InspectInfile_test (Failed)
	201 - SequestInfile_test (Failed)
	211 - TraMLFile_test (Failed)
	1877 - TOPP_InspectAdapter_1 (Failed)
	1878 - TOPP_InspectAdapter_1_out1 (Failed)
	1879 - TOPP_InspectAdapter_2 (Failed)
	1880 - TOPP_InspectAdapter_2_out1 (Failed)
	2131 - TOPP_MaRaClusterAdapter_1_out_1 (Failed)
	2133 - TOPP_MaRaClusterAdapter_2_out_1 (Failed)

and the pyOpenMS tests https://abibuilder.informatik.uni-tuebingen.de/jenkins/job/openms_pr_docker_pyopenms/1320/testReport/junit/projectroot/pyOpenMS/pyopenms_unittest_test000_py/

@cbielow

cbielow commented Feb 14, 2019

Copy link
Copy Markdown
Contributor Author

fun fact:
calling maracluster.exe -p 20ppm ... yields a slightly different result than maracluster.exe -p 20.0ppm ..., even though the parameter is specified as double in their help section explicitly. And integers are perfectly representable as doubles (no rounding error)... go figure...

@cbielow

cbielow commented Feb 15, 2019 •

Copy link
Copy Markdown
Contributor Author

more fun facts:
appleclang cannot parse 5e-06 as double using stringstream >> d (it will read 5 and then stop). All other compilers are just fine (and appleclang is also fine when reading 5.5e-06....
see:

in1:  /Users/builder/jenkins/ws/openms_pr_ci/c797036f/build/src/tests/class_tests/openms/MascotXMLFile_test_249.tmp   (line: 646, position/column: 49/78)
				<UserParam type="float" name="EValue" value="!
				                                             5.0e-06"/>

in2:  /Users/builder/jenkins/ws/openms_pr_ci/c797036f/source/src/tests/class_tests/openms/data/MascotXMLFile_test_out_3.idXML   (line: 646, position/column: 49/78)
				<UserParam type="float" name="EValue" value="!
				                                             5e-06"/>

@cbielow

cbielow commented Feb 20, 2019

Copy link
Copy Markdown
Contributor Author

ok, this is ready for merge.

@timosachsenberg
timosachsenberg merged commit 8b730e7 into OpenMS:develop Feb 20, 2019
@timosachsenberg

Copy link
Copy Markdown
Contributor

I am a bit afraid of hitting the merge button ;) ...
YOLO

hroest added a commit to hroest/OpenMS that referenced this pull request Mar 11, 2019
- fix bug introduced in OpenMS#3969 which changes meaning of AASequence
  strings
hroest added a commit to hroest/OpenMS that referenced this pull request Mar 11, 2019
- fix bug introduced in OpenMS#3969 which changes meaning of AASequence
  strings
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.

3 participants