Title: Improve TypeManager.function/TypeManager.virtual_function fetch speed by using cache. by CookStar · Pull Request #479 · Source-Python-Dev-Team/Source.Python · GitHub
Open Graph Title: Improve TypeManager.function/TypeManager.virtual_function fetch speed by using cache. by CookStar · Pull Request #479 · Source-Python-Dev-Team/Source.Python
X Title: Improve TypeManager.function/TypeManager.virtual_function fetch speed by using cache. by CookStar · Pull Request #479 · Source-Python-Dev-Team/Source.Python
Description: Entity has a mechanism to speed up the retrieval of dynamic_attributes/server_classes, but TypeManager itself does not. With this improvement, instances created by TypeManager can speed up the retrieval of function/virtual_function. In virtual_function, I tried to improve the performance by using type_info and caching, but it did not improve the performance. Test Code (CS:GO/Linux): import time from memory import find_binary from memory import make_object from memory.manager import CustomType from memory.manager import TypeManager """ TypeManager.function Test""" # _ZN9CCSPlayer12RoundRespawnEv signature = b"\x55\x89\xE5\x56\x53\x83\xEC\x1C\x8B\x5D\x08\xFF\x35\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x83\xC4\x10\x84\xC0\x0F\x85\x2A\x2A\x2A\x2A\x8B\x13" # Cache signature find_binary("server", srv_check=False)[signature] manager = TypeManager() class Test(CustomType, metaclass=manager): _binary = "server" _srv_check = False _size = 0 _spawn = manager.function(signature) # Cache function Test._spawn s = time.perf_counter() for i in range(100000): Test._spawn e = time.perf_counter() print(e-s, "Test._spawn") # Cache function test = Test() test._spawn s = time.perf_counter() for i in range(100000): test._spawn e = time.perf_counter() print(e-s, "test._spawn") l = [Test() for i in range(100000)] s = time.perf_counter() for i in range(100000): l[i]._spawn e = time.perf_counter() print(e-s, "Test()._spawn") """ TypeManager.virtual_function Test""" manager = TypeManager() class Test(CustomType, metaclass=manager): blind = manager.virtual_function(551, (DataType.FLOAT, DataType.FLOAT, DataType.FLOAT)) pointer = Entity.find("player").pointer test = make_object(Test, pointer) test.blind s = time.perf_counter() for i in range(100000): test.blind e = time.perf_counter() print(e-s, "test.blind") l = [make_object(Test, pointer) for i in range(100000)] s = time.perf_counter() for i in range(100000): l[i].blind e = time.perf_counter() print(e-s, "make_object(Test, pointer).blind") Since the implementation has changed, the test results have also changed. Output : TypeManager.function Test 4.355441149324179 Test._spawn 4.830625455826521 test._spawn 4.801660872995853 Test()._spawn ↓ OLD: 0.02216128632426262 Test._spawn OLD: 0.008792959153652191 test._spawn OLD: 0.2989997826516628 Test()._spawn NEW: 0.023133378475904465 Test._spawn NEW: 0.29126785323023796 test._spawn NEW: 0.293557733297348 Test()._spaw TypeManager.virtual_function Test 0.5497394129633904 test.blind 0.5683586820960045 make_object(Test, pointer).blind ↓ OLD: 0.008566077798604965 test.blind OLD: 0.5120681896805763 make_object(Test, pointer).blind NEW: 0.46108797565102577 test.blind NEW: 0.4727563001215458 make_object(Test, pointer).blind
Open Graph Description: Entity has a mechanism to speed up the retrieval of dynamic_attributes/server_classes, but TypeManager itself does not. With this improvement, instances created by TypeManager can speed up the retr...
X Description: Entity has a mechanism to speed up the retrieval of dynamic_attributes/server_classes, but TypeManager itself does not. With this improvement, instances created by TypeManager can speed up the retr...
Opengraph URL: https://github.com/Source-Python-Dev-Team/Source.Python/pull/479
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:866b8bbe-347b-6888-193c-1dc0817e4580 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9B5E:E29BE:37DEE8:4BB81E:69727991 |
| html-safe-nonce | 65eafe8414b8c8c932a91a8183bf0c05aeec2a8ec5c0982a72bb125febd50e48 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjVFOkUyOUJFOjM3REVFODo0QkI4MUU6Njk3Mjc5OTEiLCJ2aXNpdG9yX2lkIjoiODE3ODE1NTYwOTI4NzQ1NzE2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b6db4bc99ff47d5d303c580a247627294aa6e1ca36dbc25393ee794d662560c7 |
| hovercard-subject-tag | pull_request:1391800935 |
| 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/Source-Python-Dev-Team/Source.Python/pull/479/files |
| twitter:image | https://avatars.githubusercontent.com/u/30329245?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/30329245?s=400&v=4 |
| og:image:alt | Entity has a mechanism to speed up the retrieval of dynamic_attributes/server_classes, but TypeManager itself does not. With this improvement, instances created by TypeManager can speed up the retr... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3be355d8ea7ca74c4edec03a70ecaa8211862649e90886d88a4db13e6778e4c3 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/Source-Python-Dev-Team/Source.Python git https://github.com/Source-Python-Dev-Team/Source.Python.git |
| octolytics-dimension-user_id | 5440368 |
| octolytics-dimension-user_login | Source-Python-Dev-Team |
| octolytics-dimension-repository_id | 12771934 |
| octolytics-dimension-repository_nwo | Source-Python-Dev-Team/Source.Python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 12771934 |
| octolytics-dimension-repository_network_root_nwo | Source-Python-Dev-Team/Source.Python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4ae5b6c1e16519c3e3ad37a388f7cca2192a79a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width