[jit] Compare object identity first in ClassType::operator== (#65347)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65347
This check is much cheaper than anything involving actually inspecting object fields (i.e., the cost is low), and if it succeeds we can skip the expensive (e.g., it involves locking a weak_ptr and then destroying the resulting shared_ptr) function body. It almost entirely eliminates time spent in this function during model loading according to perf.
ghstack-source-id: 140148561
Test Plan: Specifically I profiled static runtime startup for the ctr_mobile_feed model and saw self time in this function go from 2-3% to 0.36%.
Reviewed By: ejguan
Differential Revision: D31057279
fbshipit-source-id: efb6bdc0957b680112ac282e85dc1b06b1b6c0bd