[ASK] Huge performance problem: C++ is faster than C++ 64 bit!
Difference between en2 and en3, changed 0 character(s)
Hello!↵

Recently I've faced a confusing problem:↵

I've accidentally re-submitted my solution for problem [problem:1554E] on different compiler. Suddenly I've noticed that its running time has significantly increased. ↵

- This solution [submission:128134170] takes 1263 ms under GNU C++17 compiler.↵
- This solution [submission:128134185] takes 2277 ms under GNU C++17 (64) compiler.↵
- You can see that their codes are fully identical.↵

So, common code with some vectors, self-written modular class and lambdas causes that much time difference — approximately 2 times. The memory also increased (1.5x times), it is also kinda suspicious because I haven't used any pointers.↵

I've re-written it without lambdas — lifted `dfs` out of `solve` ([submission:128134438] and [submission:128134426]), both execution times have increased in about 200 ms. ↵

I had somewhere heard that `vector<bool>` is very problematic structure. I even have changed it to `vector<int>` and resubmitted again ([submission:128141354] and [submission:128141276]). The execution times have increased a lot and gone closer, but the gap is still quite big (2105 ms / 2807 ms).↵

So, I am quite at loss, why would 64-bit compiled program take (2 times) more time to execute. Can anyone help me and explain the reason?↵

P. S. I can hardly think of any good query for googling. [This comment](https://codeforces.com/blog/entry/91824?#comment-804477) is talking about something similiar; however, it isn't answered.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English LeoPro 2021-09-10 21:10:44 0 (published)
en2 English LeoPro 2021-09-10 21:10:16 6 (saved to drafts)
en1 English LeoPro 2021-09-10 21:08:49 1563 Initial revision (published)