On Thu, Jul 1, 2021 at 2:35 PM tapi...@gmail.com <tapir....@gmail.com>
wrote:

> It is not rare a function will use 10M+ stack.
>

FWIW, it being rare is one side of the equation. The other side is how
large the overhead is - and ISTM that overhead is ~2x. That's not nothing,
but it's also not extreme, for something that takes very little time.

The other thing, of course, is that *there is code* to avoid that overhead
- it just isn't triggered by your example, for some reason (as I said, I
could imagine it has something to do with running on the system stack).
It's not unreasonable to assume that *in general*, a function using a 10M+
will use the more efficient growth path. So that even if it's not uncommon
to use a large stack, it *is* uncommon for that to be a problem.

I genuinely don't know. For that, I would have to know *why* your example
isn't more efficient. I don't care enough to find out. But it might be
completely reasonable behavior.


>
> On Thursday, July 1, 2021 at 4:13:40 AM UTC-4 Volker Dobler wrote:
>
>> Note that the compiler should generate efficient code for
>> common, typical, real-world code. Optimising the compiler
>> to generate the most efficient code for pathological code
>> can be a waste of time, both for the compiler writers and
>> for the users waiting longer for their "normal" code to be
>> compiled. Nevertheless the compiler should emit "decent"
>> code for pathological cases. The quadratic stack growth
>> seems decent to me.
>>
>> V.
>>
>> On Thursday, 1 July 2021 at 03:03:37 UTC+2 tapi...@gmail.com wrote:
>>
>>> On Wednesday, June 30, 2021 at 8:46:19 PM UTC-4
>>> axel.wa...@googlemail.com wrote:
>>>
>>>> On Thu, Jul 1, 2021 at 2:34 AM tapi...@gmail.com <tapi...@gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Wednesday, June 30, 2021 at 11:56:45 AM UTC-4 Brian Candler wrote:
>>>>>
>>>>>> So I think what you're asking is, "under what scenario does the code
>>>>>> in L1066-1069
>>>>>> <https://github.com/golang/go/blob/d19a53338fa6272b4fe9c39d66812a79e1464cd2/src/runtime/stack.go#L1065-L1070>
>>>>>> get run?" - is that right?
>>>>>
>>>>>
>>>>> Almost true.
>>>>>
>>>>> Whether or not it should run, growing the stack from 2048 to 512M in
>>>>> 18+ steps looks not right.
>>>>>
>>>>
>>>> Why? 2048 • 2^18 = 2^11 • 2^18 = 2^29 = 536870912.
>>>> Seems like exactly the expected result.
>>>>
>>>
>>> It looks each step calls copystack once.
>>> Isn't one step more efficient?
>>>
>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> On Wednesday, 30 June 2021 at 14:21:21 UTC+1 tapi...@gmail.com wrote:
>>>>>>
>>>>>>> Sorry, I post the wrong anchor. It is line 1068:
>>>>>>> https://github.com/golang/go/blob/d19a53338fa6272b4fe9c39d66812a79e1464cd2/src/runtime/stack.go#L1068
>>>>>>>
>>>>>>> On Wednesday, June 30, 2021 at 5:08:30 AM UTC-4 Brian Candler wrote:
>>>>>>>
>>>>>>>> On Wednesday, 30 June 2021 at 08:25:59 UTC+1 tapi...@gmail.com
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> It looks this line
>>>>>>>>> https://github.com/golang/go/blob/master/src/runtime/stack.go#L1078
>>>>>>>>> never gets executed.
>>>>>>>>>
>>>>>>>>>
>>>>>>>> Can you quote the line you're referring to?  Line numbers can shift
>>>>>>>> up and down as commits are made to the master branch. Right now, L1078 
>>>>>>>> is a
>>>>>>>> blank line.
>>>>>>>>
>>>>>>> --
>>>>>
>>>> You received this message because you are subscribed to the Google
>>>>> Groups "golang-nuts" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to golang-nuts...@googlegroups.com.
>>>>>
>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/golang-nuts/5fab5a6e-5dd5-4df2-8b31-4a51aa825f92n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/golang-nuts/5fab5a6e-5dd5-4df2-8b31-4a51aa825f92n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/9e869b98-f3e0-4bfd-8a24-56c9a8dea8a4n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/9e869b98-f3e0-4bfd-8a24-56c9a8dea8a4n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfG%3DPzP_b7xW7u6jhxP6EFbZ7y43Ckt-wFyW5t3%2BLZpiyQ%40mail.gmail.com.

Reply via email to