Skip to content

Embedded Python seems not possible to resolve "native" functions #236

Open

Description

@kayhayen

Hello,

this is Linux with Python2 and Python3 both.

git clone --branch factory https://github.com/Nuitka/Nuitka.git
python2 ./bin/nuitka-run --profile tests/benchmarks/pystone.py 500000 && python -m vmprof.show nuitka-performance.dat
#or if you prefer:
python3 ./bin/nuitka-run --profile tests/benchmarks/pystone3.py 500000 && python3 -m vmprof.show nuitka-performance.dat

I am getting purely native symbols with plausible time distribution. Nuitka is embedding Python here. I am doing this on Debian Linux with both installed Python2 and Python3 with same results. This used to work years ago. When you look at pystone.bin you will find it's not stripped, has debug symbols, and objdump disassambles it just fine with symbols. It writes "nuitka-performance.dat" hard coded.

The way I am implementing it is here: https://github.com/Nuitka/Nuitka/blob/factory/nuitka/build/static_src/HelpersProfiling.c

Basically I am just calling enable with a file number and default arguments. My checking of vmprof code says that on Linux "native" resolution is automatically enabled by default.

Can you tell me what I am doing wrong, or give me a pointer, to where it's attempted to resolve, so I might debug this? My current best guess is that it might be using sys.exectable, which would not be the binary, something like this. Is embedding of Python supported at all anymore? Was it ever, maybe I always used extension modules, not sure now.

Yours,
Kay

Activity

  1. kayhayen commented on Jul 2, 2021

    @kayhayen
    Author
  2. kayhayen commented on Jul 2, 2021

    @kayhayen
    Author
  3. kayhayen commented on Jul 2, 2021

    @kayhayen
    Author
  4. kayhayen commented on Jul 2, 2021

    @kayhayen
    Author
  5. kayhayen commented on Jul 3, 2021

    @kayhayen
    Author

    Ok, when I did that, I found it never recorded what I was having on the stack. It seems to have some severe regressions for mixing C code and Python stacks. At the end, after recording the all C stack, it would unconditionally record the Python stack only, unless in the middle, it encounter a frame evaluation, when it does that sooner.

    Still no idea why these came out as native functions. Probably because I barely have any Python stacks, and there are functions on the stack before entering main. When I find the time, I am goingto make a PR out of this.

  6. mattip commented on Sep 21, 2026

    @mattip
    Contributor

    Could you try again with 0.5.0? We have improved function resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions