Use custom AppendOnlyList for op_events to reduce the number of atomic operations (#78643)
Summary:
- Use atomic counter in Block storage constructor and offset within the block to calculate correlation_id.
- Implicitly deduce correlation id, no need to store it when profiling.
Test Plan:
Added test_profiler_correlation_id() in test_profiler.py to check the uniqueness of correlation id.
To run the test:
python test_profiler.py
Differential Revision: D36793803
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78643
Approved by: https://github.com/robieta