Title: (READY FOR REVIEW)Garbage collect: A stop-the-world cycle collector by discord9 · Pull Request #4180 · RustPython/RustPython · GitHub
Open Graph Title: (READY FOR REVIEW)Garbage collect: A stop-the-world cycle collector by discord9 · Pull Request #4180 · RustPython/RustPython
X Title: (READY FOR REVIEW)Garbage collect: A stop-the-world cycle collector by discord9 · Pull Request #4180 · RustPython/RustPython
Description: That might be extend to be a on-the-fly version. Based on #4158
Summary of GC Algorithm
the algorithm store a buffer of object thats' "possible roots" of garbage cycles(i.e. if a object is decrement but not to zero, its a possible root) then, during gc, algorithm have three main phase:
iterate over this buffer, free objects of rc==0.
then in next phase tracing other object(whose rc>0) and do a "trial decrement" to all of its childrens, so to remove all the "internal reference" in the graph, so whats left is external reference, so by now,object with rc==0 is safe to be collected
restore everyone elses rc, only drop garbage found from previous phase, note in here we first do a drop in place for every garbage then dealloc everything to prevent UB from deref to deallocated objects
Progress
basic cycle collector algorithm(stop the world version)
necessary trait and cond comp flag and feature
impl GcTrace for all builtin types(Some type's trace() still need tweak, see below, still have some not impl)
rebase off the newest main(for rustc 1.64.0 update)
export gc() as a python function(in the stdlib), now invoke gc() in python will force a cycle collect to happen, return number of cyclic garbage collected(and freed)
test(especially for threading)
bug: I use wrong drop in collect_white, should drop PyInner
Open Graph Description: That might be extend to be a on-the-fly version. Based on #4158 Summary of GC Algorithm the algorithm store a buffer of object thats' "possible roots" of garbage cycles(i.e. if a obje...
X Description: That might be extend to be a on-the-fly version. Based on #4158 Summary of GC Algorithm the algorithm store a buffer of object thats' "possible roots" of garbage cycles(i....
Opengraph URL: https://github.com/RustPython/RustPython/pull/4180
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:41354f9b-22b8-9a8d-ea5c-f0b02cb62eaa |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DF08:2E83F4:5C99FBC:7C4818C:6A5DE635 |
| html-safe-nonce | 39fc2c5f529fac1cc61d5fa59b908c3622513c5115fd4785e84687c77712e7e0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjA4OjJFODNGNDo1Qzk5RkJDOjdDNDgxOEM6NkE1REU2MzUiLCJ2aXNpdG9yX2lkIjoiMTU0MjYwNTI0NjM2NzEzMTE4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5bda52c1c994c7d961f72f425d5ed1c4008cb44fb093644b8a88c7a73bbef5bc |
| hovercard-subject-tag | pull_request:1064293211 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/4180/files |
| twitter:image | https://avatars.githubusercontent.com/u/55937128?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/55937128?s=400&v=4 |
| og:image:alt | That might be extend to be a on-the-fly version. Based on #4158 Summary of GC Algorithm the algorithm store a buffer of object thats' "possible roots" of garbage cycles(i.e. if a obje... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | f068985268f2a1e272fe40dd37a3352a16d337d57ec570e56da6c2346e179f59 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e36408244bcd0ded36f1cfba5db8e97f99c2117e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width