Revert "remove trace & optimize"

This reverts commit ce9efbda606a07e8686309bfe102a2caa21fa004.