Re: can we optimize STACK_DEPTH_SLOP

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: can we optimize STACK_DEPTH_SLOP
Дата
Msg-id 6102.1468193655@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: can we optimize STACK_DEPTH_SLOP  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I wrote:
> So, agreed, let's commit some temporary debug code and see what the
> buildfarm can teach us.  Will go work on that in a bit.

After reviewing the buildfarm results, I'm feeling nervous about this
whole idea again.  For the most part, the unaccounted-for daylight between
the maximum stack depth measured by check_stack_depth and the actually
dirtied stack space reported by pmap is under 100K.  But there are a
pretty fair number of exceptions.  The worst cases I found were on
"dunlin", which approached 200K extra space in a couple of places:
dunlin        | 2016-07-09 22:05:09 | check.log                                      | 00007ffff2667000     268     208
   208 rw---   [ stack ]dunlin        | 2016-07-09 22:05:09 | check.log                                      | max
measuredstack depth 14kBdunlin        | 2016-07-09 22:05:09 | install-check-C.log                            |
00007fffee650000    268     200     200 rw---   [ stack ]dunlin        | 2016-07-09 22:05:09 | install-check-C.log
                     | max measured stack depth 14kB
 

This appears to be happening in the tsdicts test script.  Other machines
also show a significant discrepancy between pmap and check_stack_depth
results for that test, which suggests that maybe the tsearch code is being
overly reliant on large local variables.  But I haven't dug through it.

Another area of concern is PLs.  For instance, on capybara, a machine
otherwise pretty unexceptional in stack-space appetite, quite a few of the
PL tests ate ~100K of unaccounted-for space:
capybara      | 2016-07-09 21:15:56 | pl-install-check-C.log                         | 00007ffc61bbe000     132     104
   104 rw---    [ stack ]capybara      | 2016-07-09 21:15:56 | pl-install-check-C.log                         |
00007ffc61bbe000    132       0       0 rw---    [ stack ]capybara      | 2016-07-09 21:15:56 | pl-install-check-C.log
                      | max measured stack depth 8kBcapybara      | 2016-07-09 21:15:56 | pl-install-check-C.log
                | 00007ffc61bbd000     136     136     136 rw---    [ stack ]capybara      | 2016-07-09 21:15:56 |
pl-install-check-C.log                        | 00007ffc61bbd000     136       0       0 rw---    [ stack ]capybara
| 2016-07-09 21:15:56 | pl-install-check-C.log                         | max measured stack depth 0kBcapybara      |
2016-07-0921:15:56 | pl-install-check-C.log                         | 00007ffc61bbe000     132     104     104 rw---
[stack ]capybara      | 2016-07-09 21:15:56 | pl-install-check-C.log                         | 00007ffc61bbe000     132
     0       0 rw---    [ stack ]capybara      | 2016-07-09 21:15:56 | pl-install-check-C.log                         |
maxmeasured stack depth 5kBcapybara      | 2016-07-09 21:15:56 | pl-install-check-C.log                         |
00007ffc61bbe000    132     116     116 rw---    [ stack ]capybara      | 2016-07-09 21:15:56 | pl-install-check-C.log
                      | 00007ffc61bbe000     132       0       0 rw---    [ stack ]capybara      | 2016-07-09 21:15:56
|pl-install-check-C.log                         | max measured stack depth 7kB
 

Presumably that reflects some oddity of the local version of perl or
python, but I have no idea what.

So while we could possibly get away with reducing STACK_DEPTH_SLOP
to 256K, there is good reason to think that that would be leaving
little or no safety margin.

At this point I'm inclined to think we should leave well enough alone.
At the very least, if we were to try to reduce that number, I'd want
to have some plan for tracking our stack space consumption better than
we have done in the past.
        regards, tom lane


PS: for amusement's sake, here are some numbers I extracted concerning
the relative stack-hungriness of different buildfarm members.  First,
the number of recursion levels each machine could accomplish before
hitting "stack too deep" in the errors.sql regression test (measured by
counting the number of CONTEXT lines in the relevant error message):
   sysname    |      snapshot       | count 
---------------+---------------------+-------protosciurus  | 2016-07-10 12:03:06 |   731chub          | 2016-07-10
15:10:01|  1033quokka        | 2016-07-10 02:17:31 |  1033hornet        | 2016-07-09 23:42:32 |  1156clam          |
2016-07-0922:00:01 |  1265anole         | 2016-07-09 22:41:40 |  1413spoonbill     | 2016-07-09 23:00:05 |
1535sungazer     | 2016-07-09 23:51:33 |  1618gaur          | 2016-07-09 04:53:13 |  1634kouprey       | 2016-07-10
04:58:00|  1653nudibranch    | 2016-07-10 09:18:10 |  1664grouse        | 2016-07-10 08:43:02 |  1708sprat         |
2016-07-1008:43:55 |  1717pademelon     | 2016-07-09 06:12:10 |  1814mandrill      | 2016-07-10 00:10:02 |  2093gharial
     | 2016-07-10 01:15:50 |  2248francolin     | 2016-07-10 13:00:01 |  2379piculet       | 2016-07-10 13:00:01 |
2379lorikeet     | 2016-07-10 08:04:19 |  2422caecilian     | 2016-07-09 19:31:50 |  2423jacana        | 2016-07-09
22:36:38|  2515bowerbird     | 2016-07-10 02:13:47 |  2617locust        | 2016-07-09 21:50:26 |  2838prairiedog    |
2016-07-0922:44:58 |  2838dromedary     | 2016-07-09 20:48:06 |  2840damselfly     | 2016-07-10 10:27:09 |
2880curculio     | 2016-07-09 21:30:01 |  2905mylodon       | 2016-07-09 20:50:01 |  2974tern          | 2016-07-09
23:51:23|  3015burbot        | 2016-07-10 03:30:45 |  3042magpie        | 2016-07-09 21:38:02 |  3043reindeer      |
2016-07-1004:00:05 |  3043friarbird     | 2016-07-10 04:20:01 |  3187nightjar      | 2016-07-09 21:17:52 |
3187sittella     | 2016-07-09 21:46:29 |  3188crake         | 2016-07-09 22:06:09 |  3267guaibasaurus  | 2016-07-10
00:17:01|  3267ibex          | 2016-07-09 20:59:06 |  3267mule          | 2016-07-09 23:30:02 |  3267spurfowl      |
2016-07-0921:06:39 |  3267anchovy       | 2016-07-09 21:41:04 |  3268blesbok       | 2016-07-09 21:17:46 |
3268capybara     | 2016-07-09 21:15:56 |  3268conchuela     | 2016-07-09 21:00:01 |  3268handfish      | 2016-07-09
04:37:57|  3268macaque       | 2016-07-08 21:25:06 |  3268minisauripus  | 2016-07-10 03:19:42 |  3268rhinoceros    |
2016-07-0921:45:01 |  3268sidewinder    | 2016-07-09 21:45:00 |  3272jaguarundi    | 2016-07-10 06:52:05 |  3355loach
     | 2016-07-09 21:15:00 |  3355okapi         | 2016-07-10 06:15:02 |  3425fulmar        | 2016-07-09 23:47:57 |
3436longfin      | 2016-07-09 21:10:17 |  3444brolga        | 2016-07-10 09:40:46 |  3537dunlin        | 2016-07-09
22:05:09|  3616coypu         | 2016-07-09 22:20:46 |  3626hyrax         | 2016-07-09 19:52:03 |  3635treepie       |
2016-07-0922:41:37 |  3635frogmouth     | 2016-07-10 02:00:09 |  3636narwhal       | 2016-07-10 10:00:05 |
3966rover_firefly| 2016-07-10 15:01:45 |  4084lapwing       | 2016-07-09 21:15:01 |  4085cockatiel     | 2016-07-10
13:40:47|  4362currawong     | 2016-07-10 05:16:03 |  5136mastodon      | 2016-07-10 11:00:01 |  5136termite       |
2016-07-0921:01:30 |  5452hamster       | 2016-07-09 16:00:06 |  5685dangomushi    | 2016-07-09 18:00:27 |  5692gull
     | 2016-07-10 04:48:28 |  5692mereswine     | 2016-07-10 10:40:57 |  5810axolotl       | 2016-07-09 22:12:12 |
5811chipmunk     | 2016-07-10 08:18:07 |  5949grison        | 2016-07-09 21:00:02 |  5949
 
(74 rows)

(coypu gets a gold star for this one, since it makes a good showing
despite having max_stack_depth set to 1536kB --- everyone else seems
to be using 2MB.)

Second, the stack space consumed for the regex regression test --- here,
smaller is better:
currawong     | 2016-07-10 05:16:03 | max measured stack depth 213kBmastodon      | 2016-07-10 11:00:01 | max measured
stackdepth 213kBaxolotl       | 2016-07-09 22:12:12 | max measured stack depth 240kBhamster       | 2016-07-09 16:00:06
|max measured stack depth 240kBmereswine     | 2016-07-10 10:40:57 | max measured stack depth 240kBbrolga        |
2016-07-1009:40:46 | max measured stack depth 284kBnarwhal       | 2016-07-10 10:00:05 | max measured stack depth
284kBcockatiel    | 2016-07-10 13:40:47 | max measured stack depth 285kBfrancolin     | 2016-07-10 13:00:01 | max
measuredstack depth 285kBhyrax         | 2016-07-09 19:52:03 | max measured stack depth 285kBmagpie        | 2016-07-09
21:38:02| max measured stack depth 285kBpiculet       | 2016-07-10 13:00:01 | max measured stack depth 285kBreindeer
 | 2016-07-10 04:00:05 | max measured stack depth 285kBtreepie       | 2016-07-09 22:41:37 | max measured stack depth
285kBlapwing      | 2016-07-09 21:15:01 | max measured stack depth 287kBrover_firefly | 2016-07-10 15:01:45 | max
measuredstack depth 287kBcoypu         | 2016-07-09 22:20:46 | max measured stack depth 288kBfriarbird     | 2016-07-10
04:20:01| max measured stack depth 289kBnightjar      | 2016-07-09 21:17:52 | max measured stack depth 289kBgharial
 | 2016-07-10 01:15:50 | max measured stack depths 290kB, 384kBbowerbird     | 2016-07-10 02:13:47 | max measured stack
depth378kBcaecilian     | 2016-07-09 19:31:50 | max measured stack depth 378kBfrogmouth     | 2016-07-10 02:00:09 | max
measuredstack depth 378kBmylodon       | 2016-07-09 20:50:01 | max measured stack depth 378kBjaguarundi    | 2016-07-10
06:52:05| max measured stack depth 379kBloach         | 2016-07-09 21:15:00 | max measured stack depth 379kBlongfin
 | 2016-07-09 21:10:17 | max measured stack depth 379kBsidewinder    | 2016-07-09 21:45:00 | max measured stack depth
379kBanchovy      | 2016-07-09 21:41:04 | max measured stack depth 381kBblesbok       | 2016-07-09 21:17:46 | max
measuredstack depth 381kBcapybara      | 2016-07-09 21:15:56 | max measured stack depth 381kBconchuela     | 2016-07-09
21:00:01| max measured stack depth 381kBcrake         | 2016-07-09 22:06:09 | max measured stack depth 381kBcurculio
 | 2016-07-09 21:30:01 | max measured stack depth 381kBguaibasaurus  | 2016-07-10 00:17:01 | max measured stack depth
381kBhandfish     | 2016-07-09 04:37:57 | max measured stack depth 381kBibex          | 2016-07-09 20:59:06 | max
measuredstack depth 381kBmacaque       | 2016-07-08 21:25:06 | max measured stack depth 381kBminisauripus  | 2016-07-10
03:19:42| max measured stack depth 381kBmule          | 2016-07-09 23:30:02 | max measured stack depth 381kBrhinoceros
 | 2016-07-09 21:45:01 | max measured stack depth 381kBsittella      | 2016-07-09 21:46:29 | max measured stack depth
381kBspurfowl     | 2016-07-09 21:06:39 | max measured stack depth 381kBdromedary     | 2016-07-09 20:48:06 | max
measuredstack depth 382kBpademelon     | 2016-07-09 06:12:10 | max measured stack depth 382kBfulmar        | 2016-07-09
23:47:57| max measured stack depth 383kBdunlin        | 2016-07-09 22:05:09 | max measured stack depth 388kBokapi
 | 2016-07-10 06:15:02 | max measured stack depth 389kBmandrill      | 2016-07-10 00:10:02 | max measured stack depth
489kBtern         | 2016-07-09 23:51:23 | max measured stack depth 491kBdamselfly     | 2016-07-10 10:27:09 | max
measuredstack depth 492kBburbot        | 2016-07-10 03:30:45 | max measured stack depth 567kBlocust        | 2016-07-09
21:50:26| max measured stack depth 571kBprairiedog    | 2016-07-09 22:44:58 | max measured stack depth 571kBclam
 | 2016-07-09 22:00:01 | max measured stack depth 573kBjacana        | 2016-07-09 22:36:38 | max measured stack depth
661kBlorikeet     | 2016-07-10 08:04:19 | max measured stack depth 662kBgaur          | 2016-07-09 04:53:13 | max
measuredstack depth 756kBchub          | 2016-07-10 15:10:01 | max measured stack depth 856kBquokka        | 2016-07-10
02:17:31| max measured stack depth 856kBhornet        | 2016-07-09 23:42:32 | max measured stack depth 868kBgrouse
 | 2016-07-10 08:43:02 | max measured stack depth 944kBkouprey       | 2016-07-10 04:58:00 | max measured stack depth
944kBnudibranch   | 2016-07-10 09:18:10 | max measured stack depth 945kBsprat         | 2016-07-10 08:43:55 | max
measuredstack depth 946kBsungazer      | 2016-07-09 23:51:33 | max measured stack depth 963kBprotosciurus  | 2016-07-10
12:03:06| max measured stack depth 1432kB
 

The second list omits a couple of machines whose reports got garbled
by concurrent insertions into the log file.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Julien Rouhaud
Дата:
Сообщение: Re: Issue with bgworker, SPI and pgstat_report_stat
Следующее
От: Haribabu Kommi
Дата:
Сообщение: Re: pg_hba_lookup function to get all matching pg_hba.conf entries