Perf fix
Add pattern rank calculation
Set queue maxlen