improve ringbuffers in recursor, add query ringbuffer + infra to get top queries