-
Notifications
You must be signed in to change notification settings - Fork 643
Trying to run pystone -> StopIteration #305
Comments
This came to light because of this issue report: #305 Basically, map() and zip() were detecting StopIteration but were calling ExcRestore(nil, nil) in the wrong place, so under normal circumstances, exc info would be set to StopIteration after they returned. Normally this would not cause a problem, but the code in the bug report was calling a native function (time.Now()) subsequent to a map() and nativeInvoke checks ExcInfo() to determine whether the Go function manually triggered an exception. See: https://github.com/google/grumpy/blob/master/runtime/native.go#L572 In this case, nativeInvoke was being fooled because exc info had been set previously. nativeInvoke should probably be smarter about this by resetting the exception before the native call.
Thanks for the bug report! I was able to reproduce the problem and fixed it in e97a8ec Let me know if anything else comes up. |
@trotterdylan thanks for fixing map and zip wrt StopIteration. Now running pystone under grumpy gives:
If I change
Thanks again, |
@navytux Do you have pypy numbers too? |
@cclauss yes:
|
Cool, if you want to file a new issue for the %g that'd be great. Re: performance, fwiw my bet is that the bottleneck is the native calls to time(). Native calls currently use Go runtime reflection which is terribly slow. Long term I plan on exposing native objects statically at build time which should reduce the overhead substantially. If you're interested in investigating performance you can produce Go profiles from Grumpy binaries using the GRUMPY_PROFILE environment variable. With that profile you can use the Go pprof tool as described here: https://blog.golang.org/profiling-go-programs |
@trotterdylan thanks for feedback and GRUMPY_PROFILE hint. I've spawned %g to #306. About time to run: the
to me offhand it looks like it is not reflections. Good to know though there are plans to cut overhead for native calls. Thanks again, |
This came to light because of this issue report: google/grumpy#305 Basically, map() and zip() were detecting StopIteration but were calling ExcRestore(nil, nil) in the wrong place, so under normal circumstances, exc info would be set to StopIteration after they returned. Normally this would not cause a problem, but the code in the bug report was calling a native function (time.Now()) subsequent to a map() and nativeInvoke checks ExcInfo() to determine whether the Go function manually triggered an exception. See: https://github.com/google/grumpy/blob/master/runtime/native.go#L572 In this case, nativeInvoke was being fooled because exc info had been set previously. nativeInvoke should probably be smarter about this by resetting the exception before the native call.
Hello up there. I've tried to run CPython's pystone with Grumpy but instead of regular output it just prints "StopIteration" without any traceback. To try to see what is going on I've edded explicit
try
/traceback.print_exc()
around main() and then it prints:This looks strange as
Array2Glob = map(lambda x: x[:], [Array1Glob]*51)
is there in global context not inside some function but traceback shows it to be called from insidetime.clock()
(?).Full source code for (a bit) adjusted pystone.py is here:
https://lab.nexedi.com/kirr/grumpy/blob/52625c82/pystone.py
Thanks beforehand,
Kirill
The text was updated successfully, but these errors were encountered: