tqchen opened a new pull request, #634: URL: https://github.com/apache/tvm-ffi/pull/634
This PR caches dynamically allocated object type indices in a static inline const `_type_index` and makes `RuntimeTypeIndex` return the cached value directly. `_GetOrAllocRuntimeTypeIndex` is marked cold and moves to cold/startup code, reducing the hot accessor to a plain load.\n\nSide codegen probe for a dynamic object accessor:\n\n- `ReadDynTypeIndex`: 176 B -> 14 B\n- total probe object: 769 B -> 634 B\n- hot path no longer contains function-local static guard/allocation checks\n- added static inline storage cost is explicit: 4 B `_type_index`, 8 B guard, 8 B `.init_array`, plus small startup init\n\nValidation:\n\n- `cmake -G Ninja -S . -B build/cpp_tests -DTVM_FFI_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=RelWithDebugInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=ON`\n- `cmake --build build/cpp_tests --config RelWithDebugInfo --target tvm_ffi_tests`\n- `ASAN_OPTIONS=detect_leaks=0 GTEST_COLOR=1 build/cpp_tests/lib/tvm_ffi_tests --gtest_filter='Object*:Reflection*:StructuralKey.MapAnyKeyUsesStr ucturalAttrs'`\n- `ASAN_OPTIONS=detect_leaks=0 GTEST_COLOR=1 ctest -C RelWithDebugInfo --test-dir build/cpp_tests --output-on-failure` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
