public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ruben.laso at tuwien dot ac.at" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113504] New: High memory usage for parallel `std::sort` Date: Fri, 19 Jan 2024 14:17:41 +0000 [thread overview] Message-ID: <bug-113504-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113504 Bug ID: 113504 Summary: High memory usage for parallel `std::sort` Product: gcc Version: 12.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ruben.laso at tuwien dot ac.at Target Milestone: --- The memory usage of parallel `std::sort` is very high compared to the sequential version and even other parallel implementations. The attached code is a simple test case to compare the memory usage of parallel `std::sort`, `tbb::parallel_sort` and sequential `std::sort`. The test case has been replicated in several systems with versions of GCC 10, 11 and 12. An example of the results (and max. memory usage according to `/usr/bin/time`) is shown in the following table: | Executable | Size | Time | Max Resident Memory | | ------------------ | ----------- | -------- | ------------------- | | ./pstl_sort.out | 33554432 | 0:00.23 | 423776k | | ./tbb_sort.out | 33554432 | 0:00.44 | 143952k | | ./seq_sort.out | 33554432 | 0:03.32 | 134836k | | ./pstl_sort.out | 1073741824 | 0:05.68 | 14236656k | | ./tbb_sort.out | 1073741824 | 0:13.02 | 4207680k | | ./seq_sort.out | 1073741824 | 2:07.38 | 4198124k | In the example, the parallel `std::sort` (pstl_sort) uses ~3 times more memory than the `tbb::parallel_sort` (tbb_sort) and the sequential `std::sort` (seq_sort). It also runs faster, though. System specs in the example: CPU: AMD EPYC 7551 RAM: 256 GB DDR4 OS: Debian 10.10 Compilation with: g++ -std=c++17 -O3 -pedantic -Wall -Wextra -Werror -o pstl_sort.out main.cpp -ltbb -DPSTL_SORT g++ -std=c++17 -O3 -pedantic -Wall -Wextra -Werror -o tbb_sort.out main.cpp -ltbb -DTBB_SORT g++ -std=c++17 -O3 -pedantic -Wall -Wextra -Werror -o seq_sort.out main.cpp -ltbb Did I miss something in the code? Is that high memory usage a deliberate trade-off for performance? Is the algorithm still in development to improve memory usage?
next reply other threads:[~2024-01-19 14:17 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-19 14:17 ruben.laso at tuwien dot ac.at [this message] 2024-01-19 15:41 ` [Bug libstdc++/113504] " redi at gcc dot gnu.org 2024-01-22 8:18 ` ruben.laso at tuwien dot ac.at
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113504-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).