Fast implementation of logtail in C/C++