Hi, When investigating `re-search-forward' performance in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58558 (bug#58558), I noticed that buf_bytepos_to_charpos is taking most of the CPU time, according to perf stats. This was partially caused by `parse-sexp-lookup-properties', but even after working around the text property issue, buf_bytepos_to_charpos still shows up on top of the perf profile. Since one of the apparent bottlenecks in buf_bytepos_to_charpos is for (tail = BUF_MARKERS (b); tail; tail = tail->next) which obviously scales with the number of markers in buffer, I decided to add a cut-off parameter, as in the attached patch (number 50 has no particular motivation underneath). Surprisingly, this simple change reduced my Org agenda generation times from 20 seconds down to 3-4 seconds! I am sure that my dumb approach is not the best way to improve the performance, but this place in buf_bytepos_to_charpos is clearly something that can be optimized.