Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 675
    • Issues 675
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPyPyPy
  • pypypypy
  • Merge requests
  • !851

Make it possible to @specialize.memo on gc.trace callbacks

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Antonio Cuni requested to merge branch/gc-custom-trace-memo-on-default into branch/default Jun 28, 2022
  • Overview 0
  • Commits 14
  • Pipelines 1
  • Changes 21

As the title says, the goal of this PR is to be able to use @specialize.memo() on the callbacks which are passed to gc.trace, and in particular on the callback argument which is passed when using rgc.register_custom_trace_hook.

This branch is needed for hpy; in particular for the branch hpy-0.0.4-hpyfields: in that branch, we need to call the user-supplied tp_traverse inside our custom GC tracer: to do so, we generate a tp-traverse-compatible callback for each gc.trace callback that we receive, using @specialize.memo().

The problem is that before this branch, some of the callbacks were functions and some were instance methods, and it's not possible to @specialize.memo() on instance methods.

To achieve the final goal, this branch does:

  1. add an assert_callback_is_function() inside gc.trace in order to catch early all the places in which you pass a method
  2. add a second argument to the callback
  3. fix all places which were passing methods

I have run extensive benchmarks to ensure that this branch does not introduce performance regressions. In particular I benchmarked:

  1. default (rev 8eb1cf456a46) vs gc-custom-trace-memo-on-default, with and without JIT
  2. py3.9 (rev a528f674f2d1) vs gc-custom-trace-memo, with and without JIT
  3. targetgcbench.py (on default vs this branch)

The results of (1) and (2) are visible at https://speed.pypy.org/comparison/ if you select the relevant binaries (permalink is not working unfortunately). In that comparison we see that some benchmarks are slightly faster and some are slightly slower; to be extra sure, I re-ran the slower benchmarks manually on bencher7 and could not see any noticeable difference, so probably the difference that we see in the charts are just random variations.

(3) is an RPython benchmark which exercises the GC which I ran manually on bencher7, and it doesn't show any performance regression.

--HG-- branch : gc-custom-trace-memo-on-default

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: branch/gc-custom-trace-memo-on-default