-
Notifications
You must be signed in to change notification settings - Fork 27
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
Performance optimizations #10
Conversation
This cuts runtime down from ~4.7s to ~3s.
This cuts ~3s down to ~2s.
No effect on my naive benchmark.
CRLF line endings should not validate, or if we think they should, that handling should happen in NEWLINE. This also makes it possible to do faster IO, by measuring the size of the input file before reading it.
I'm happy to review and merge it. I've looked at everything except the GMP/bigint commit so far: |
So hm, on second thought re the CRLF change, this might make it super annoying to use ctd on a Windows system, when most methods of generating test data output CRLF line endings, and it could be worth leaving CRLF validation to Unix systems... Convenience vs strictness, hmm. It's not strictly needed for fast IO -- Either way, it definitely would be good to have NEWLINE do some special-casing of CRLFs, e.g. printing a nicer error message for that case. Line endings are a subtle thing that's easy to be confused by. The C++ validator script we use for local IOI qualifiers has this logic: https://github.com/nordicolympiad/testdata_tools/blob/fbae58a0416f84ca9449b0536ef49c9f27b25711/input_format_validators/validator/validator.h#L345 Also, apparently I need to do something to handle the case when __builtin_saddl_overflow doesn't exist, for CI... (introduced in GCC 5) |
I don't quite understand how this would make using checktestdata on Windows annoying. Precisely what
So, I propose to not merge this particular commit for now, but I'm happy to consider it in the future (or even make some changes myself, time permitting). |
Ah yes, this would work.
Sounds good! Should I update the PR, or do you want to cherry-pick the other commits? |
Ok, I've cherry-picked and part of your commits. I've rewritten the compilation with Bisonc++ 6 fix a bit, since on my system it was still breaking because of changes to Flexc++ 2.03. Feel free to create new PRs for the outstanding issues, which if I'm not mistaken are:
|
I also reviewed the bigint code and added some tests to be confident it works fine. In principle it looks fine to me, but it would be nice to change the code a bit, so that it can be tranparently switched on/off depending on compiler support for the |
Merged in via #19 |
Not sure if this is wanted given the discussed rewrite in #3, but I spent an evening doing some obvious optimizations and got runtime for a naive ctd program
down from 4.7 seconds to 1.3 (on 5e6 ints).
Most of the PR is spent avoiding GMP, however I suspect a large part of that perf win can be achieved by just the
cachedLong
part of the relevant commit. Note the "Read input file as binary" behavior change, which is worth discussing in its own right. And of course, feel free to close this if it's not worth the review/testing burden given the rewrite, I was mostly doing this for my own curiosity.