Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiny profiling info (Psyco #2) #37246

Closed
arigo mannequin opened this issue Oct 1, 2002 · 8 comments
Closed

Tiny profiling info (Psyco #2) #37246

arigo mannequin opened this issue Oct 1, 2002 · 8 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@arigo
Copy link
Mannequin

arigo mannequin commented Oct 1, 2002

BPO 617311
Nosy @mwhudson, @gvanrossum, @arigo
Files
  • diff-2.2: context diff against the 2.2 branch
  • diff-2.3: context diff for the cvs trunk
  • diff: updated context diff for 2.3
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/mwhudson'
    closed_at = <Date 2002-11-08.12:56:53.000>
    created_at = <Date 2002-10-01.23:20:54.000>
    labels = ['interpreter-core']
    title = 'Tiny profiling info (Psyco #2)'
    updated_at = <Date 2002-11-08.12:56:53.000>
    user = 'https://github.com/arigo'

    bugs.python.org fields:

    activity = <Date 2002-11-08.12:56:53.000>
    actor = 'mwh'
    assignee = 'mwh'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2002-10-01.23:20:54.000>
    creator = 'arigo'
    dependencies = []
    files = ['4606', '4607', '4608']
    hgrepos = []
    issue_num = 617311
    keywords = ['patch']
    message_count = 8.0
    messages = ['41287', '41288', '41289', '41290', '41291', '41292', '41293', '41294']
    nosy_count = 3.0
    nosy_names = ['mwh', 'gvanrossum', 'arigo']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue617311'
    versions = ['Python 2.3']

    @arigo
    Copy link
    Mannequin Author

    arigo mannequin commented Oct 1, 2002

    Psyco-friendly patch #2.

    A very very small statistic-collecting patch.

    pystate.h: added a field at the end of the
    PyThreadStruct:

        int tick_counter;

    ceval.c: eval_frame():

    tstate->tick_counter is incremented whenever the
    check_interval ticker reaches zero.
    

    The purpose is to give a useful measure of the number
    of interpreted
    bytecode instructions in a given thread. This
    extremely lightweight
    statistic collector can be of interest to profilers
    (like psyco.jit()).

    We can safely guess that a single integer increment
    every 100
    interpreted bytecode instructions will go entierely
    unnoticed
    in any performance measure. [This is true for
    pystone.py.]

    @arigo arigo mannequin closed this as completed Oct 1, 2002
    @arigo arigo mannequin assigned mwhudson Oct 1, 2002
    @arigo arigo mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Oct 1, 2002
    @arigo arigo mannequin closed this as completed Oct 1, 2002
    @arigo arigo mannequin assigned mwhudson Oct 1, 2002
    @arigo arigo mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Oct 1, 2002
    @mwhudson
    Copy link

    mwhudson commented Oct 4, 2002

    Logged In: YES
    user_id=6656

    I see no harm in this.

    Are you sure it's actually going to be useful, though?

    @arigo
    Copy link
    Mannequin Author

    arigo mannequin commented Oct 4, 2002

    Logged In: YES
    user_id=4771

    It is the only way I could work out so far that can
    "predict" how much a function will be accelerated when run
    under Psyco. This is a very precious indication for an
    automatic Psyco-binder. The following table shows the
    results with the various test functions of the
    distribution's "test.py" file:

    (fn name) (speed-up) (bytecode insns per second)
    f1 106.00
    2310545
    f4 11.33
    2819100
    f5 12.08
    2992445
    f6 1.35
    412022
    f7 2.24
    1331353
    f7bis 10.29
    1632296

    The third column is '(tick_counter * check_interval) /
    execution_time'. The correlation between the two columns is
    admittedly not perfect, but still we can see that it was not
    worthy to try and accelerate f6 because it didn't spend a
    lot of time actually interpreting bytecodes.

    Note that similar information could be obtained by setting a
    line-tracing hook, counting not instructions but lines
    (which is less precise but still a good approximation).
    However, line tracing is *much* too slow for anything but
    debugging usage.

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    I'd like to get this into 2.2.2. MWH, can you check it in?

    @mwhudson
    Copy link

    mwhudson commented Oct 7, 2002

    Logged In: YES
    user_id=6656

    Done in

    Include/pystate.h revision 2.18.16.1
    Python/ceval.c revision 2.301.4.7

    Armin, I don't know how you generated this patch, but it
    would have been easier to apply if it had been rooted in the
    "src" directory, like e.g.:

    $ cvs diff Include/pystate.h Python/ceval.c > ~/diff

    @arigo
    Copy link
    Mannequin Author

    arigo mannequin commented Oct 7, 2002

    Logged In: YES
    user_id=4771

    Uploaded the 2.3 patch (this one cleanly generated -- for the
    other one I just cat'ed two patches in one).

    @arigo
    Copy link
    Mannequin Author

    arigo mannequin commented Oct 9, 2002

    Logged In: YES
    user_id=4771

    Attached an updated diff for 2.3. This one doesn't have
    Windows line endings and includes the initialization of
    tick_counter to 0 that was added by Guido in the latest
    2.2.2. (I thought it was unnecessary to initialize it to
    anything because profilers would only be interested in
    differences.)

    @mwhudson
    Copy link

    mwhudson commented Nov 8, 2002

    Logged In: YES
    user_id=6656

    I got lazy and checked in all the psyco patches at once:

    Include/pystate.h revision 2.21
    Modules/pyexpat.c revision 2.76
    Python/ceval.c revision 2.340
    Python/pystate.c revision 2.22

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants