Skip to content

Avoid using PeekBuffer for newline searching #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2023
Merged

Conversation

fzhinkin
Copy link
Collaborator

PeekBuffer creates a lot of troubles when using ByteBuffer, but even with a byte array, switching to an indexOf-based algorithm significantly improves performance.

PeekBuffer creates a lot of troubles when it comes to using ByteBuffer, but even with byte array, switching to indexOf-based algorithm significantly improves performance.
@fzhinkin
Copy link
Collaborator Author

Here are benchmarking results (I executed benchmarks in throughput mode, so higher the score, better the performance):

baseline (devel):

Utf8LineBenchmark.benchmark              17       128           LF  thrpt    5  14393924.677 ± 633264.931  ops/s
Utf8LineBenchmark.benchmark              17       128         CRLF  thrpt    5  12899750.296 ± 327695.500  ops/s
Utf8LineStrictBenchmark.benchmark        17       128           LF  thrpt    5  13517716.542 ± 149910.502  ops/s
Utf8LineStrictBenchmark.benchmark        17       128         CRLF  thrpt    5  10519251.118 ±  74099.464  ops/s

new version (this branch):

Benchmark                          (length)  (minGap)  (separator)   Mode  Cnt         Score        Error  Units
Utf8LineBenchmark.benchmark              17       128           LF  thrpt    5  25948563.426 ± 525739.384  ops/s
Utf8LineBenchmark.benchmark              17       128         CRLF  thrpt    5  25194297.473 ± 615986.235  ops/s
Utf8LineStrictBenchmark.benchmark        17       128           LF  thrpt    5  25797103.301 ± 413829.337  ops/s
Utf8LineStrictBenchmark.benchmark        17       128         CRLF  thrpt    5  24884202.183 ± 542315.770  ops/s

@fzhinkin fzhinkin requested a review from shanshin November 24, 2023 19:04
@fzhinkin fzhinkin self-assigned this Nov 24, 2023
@fzhinkin fzhinkin marked this pull request as ready for review November 24, 2023 19:05
@fzhinkin fzhinkin merged commit daffa8d into develop Nov 30, 2023
@fzhinkin fzhinkin deleted the speedup-readline branch November 30, 2023 10:15
fzhinkin added a commit that referenced this pull request Jan 4, 2024
PeekBuffer creates a lot of troubles when it comes to using ByteBuffer, but even with byte array, switching to indexOf-based algorithm significantly improves performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants