Re: Parallel tuplesort (for parallel B-Tree index creation)
Peter Geoghegan <pg@heroku.com>
On Wed, Sep 7, 2016 at 2:36 PM, Heikki Linnakangas <hlinnaka@iki.fi> wrote: > 3. If we do that, we'll still have to reserve the tape buffers for all the > tapes that we use during merge. So after we've built the initial runs, we'll > need to reserve memory for those buffers. That might require shrinking > memtuples. But that's OK: after building the initial runs, memtuples is > empty, so we can shrink it. Do you really think all this is worth the effort? Given how things are going to improve for merging anyway, I tend to doubt it. I'd rather just apply the cap (not necessarily 501 tapes, but something), and be done with it. As you know, Knuth never advocated more than 7 tapes at once, which I don't think had anything to do with the economics of tape drives in the 1970s (or problems with tape operators getting repetitive strange injuries). There is a chart in volume 3 about this. Senior hackers talked about a cap like this from day one, back in 2006, when Simon and Tom initially worked on scaling the number of tapes. Alternatively, we could make MERGE_BUFFER_SIZE much larger, which I think would be a good idea independent of whatever waste logically allocation of never-used tapes presents us with. It's currently 1/4 of 1MiB, which is hardly anything these days, and doesn't seem to have much to do with OS read ahead trigger sizes. If we were going to do something like you describe here, I'd prefer it to be driven by an observable benefit in performance, rather than a theoretical benefit. Not doing everything in one pass isn't necessarily worse than having a less cache efficient heap -- it might be quite a bit better, in fact. You've seen how hard it can be to get a sort that is I/O bound. (Sorting will tend to not be completely I/O bound, unless perhaps parallelism is used). Anyway, this patch (patch 0001-*) is by far the least important of the 3 that you and Claudio are signed up to review. I don't think it's worth bending over backwards to do better. If you're not comfortable with a simple cap like this, than I'd suggest that we leave it at that, since our time is better spent elsewhere. We can just shelve it for now -- "returned with feedback". I wouldn't make any noise about it (although, I actually don't think that the cap idea is at all controversial). -- Peter Geoghegan
Commits
-
Support parallel btree index builds.
- 9da0cc35284b 11.0 landed
-
Report an ERROR if a parallel worker fails to start properly.
- 2badb5afb89c 11.0 cited
-
Transfer state pertaining to pending REINDEX operations to workers.
- 29d58fd3adae 11.0 landed
-
Add a barrier primitive for synchronizing backends.
- 1145acc70deb 11.0 cited
-
Allow DML commands that create tables to use parallel query.
- e9baa5e9fa14 11.0 cited
-
Refactor GetOldestXmin() to use flags
- af4b1a0869bd 10.0 cited
-
Fix regression in parallel planning against inheritance tables.
- 2609e91fcf9d 10.0 cited
-
Don't create "holes" in BufFiles, in the new logtape code.
- 7ac4a389a7db 10.0 cited
-
Simplify the code for logical tape read buffers.
- b75f467b6eec 10.0 cited
-
Fix excessive memory consumption in the new sort pre-reading code.
- b56fb691b003 10.0 cited
-
Implement binary heap replace-top operation in a smarter way.
- 24598337c8d2 10.0 cited
-
Cosmetic code cleanup in commands/extension.c.
- 25794e841e5b 10.0 cited
-
Speed up planner's scanning for parallel-query hazards.
- da1c91631e35 10.0 cited
-
Read from the same worker repeatedly until it returns no tuple.
- bc7fcab5e36b 9.6.0 cited
-
Improve tuplesort.c to support variable merge order. The original coding
- df700e6b4019 8.2.0 cited