Skip to content

CRLF parsing micro-optimization#13

Merged
parroty merged 1 commit intoparroty:masterfrom
mroth:crlf-microperf
Jan 29, 2015
Merged

CRLF parsing micro-optimization#13
parroty merged 1 commit intoparroty:masterfrom
mroth:crlf-microperf

Conversation

@mroth
Copy link
Copy Markdown
Contributor

@mroth mroth commented Jan 29, 2015

This is a tiny optimization on how CRLFs are checked (String.ends_with? is faster than a regex), which speeds up the stream processing process by a few percentage points.

There are of course bigger fish to fry than this… E.g. it shouldn’t make a huge difference but I wanted to do a quick example of the sort of profiling/changes that should be possible since #11 to encourage people to look for optimization opportunities.

Before:

#process stream - single chunk:     100000   17.98 µs/op
#process stream - multi chunk:       50000   39.90 µs/op

After:

#process stream - single chunk:     100000   16.70 µs/op
#process stream - multi chunk:       50000   35.78 µs/op

This is a tiny optimization on how CRLFs are checked
(`String.ends_with?` is faster than a regex), which speeds up the
stream processing process by a few percentage points.

There are of course bigger fish to fry than this.  E.g. it shouldn’t
make a huge difference but I wanted to do a quick example of the sort
of profiling/changes that should be possible now to encourage people to
look for optimization opportunities.

Before:
#process stream - single chunk:     100000   17.98 µs/op
#process stream - multi chunk:       50000   39.90 µs/op

After:
#process stream - single chunk:     100000   16.70 µs/op
#process stream - multi chunk:       50000   35.78 µs/op
parroty added a commit that referenced this pull request Jan 29, 2015
CRLF parsing micro-optimization
@parroty parroty merged commit 8809658 into parroty:master Jan 29, 2015
@mroth mroth deleted the crlf-microperf branch January 29, 2015 03:46
@parroty
Copy link
Copy Markdown
Owner

parroty commented Jan 29, 2015

Thanks! Your comment makes sense a lot.

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