Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Performance improvement and benchmark #200

Closed
wants to merge 8 commits into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Nov 28, 2014

n/t

cc @bnoordhuis

@chrisdickinson
Copy link
Contributor

base benchmarks (as of 3f1a05a)

$ rm -rf bench; make clean; make -j8; make bench; ./bench
rm -f *.o *.a tags test test_fast test_g \
        http_parser.tar libhttp_parser.so.* \
        url_parser url_parser_g parsertrace parsertrace_g
cc -I. -DHTTP_PARSER_STRICT=1  -Wall -Wextra -Werror -O0 -g  -c http_parser.c -o http_parser_g.o
cc -I. -DHTTP_PARSER_STRICT=1  -Wall -Wextra -Werror -O0 -g  -c test.c -o test_g.o
cc -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -c http_parser.c
cc -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -c test.c -o test.o
cc -Wall -Wextra -Werror -O0 -g   http_parser_g.o test_g.o -o test_g
cc -Wall -Wextra -Werror -O3   http_parser.o test.o -o test_fast
./test_g
http_parser v2.3.0 (0x020300)
sizeof(http_parser) = 32
response scan 1/2  100%
response scan 2/2  100%
responses okay
request scan 1/4  100%
request scan 2/4  100%
request scan 3/4  100%
request scan 4/4  100%
requests okay
./test_fast
http_parser v2.3.0 (0x020300)
sizeof(http_parser) = 32
response scan 1/2  100%
response scan 2/2  100%
responses okay
request scan 1/4  100%
request scan 2/4  100%
request scan 3/4  100%
request scan 4/4  100%
requests okay
cc -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -Wno-unused-parameter -c bench.c -o bench.o
cc -Wall -Wextra -Werror -O3  -Wno-unused-parameter  http_parser.o bench.o -o bench
Benchmark result:
Took 17.883043 seconds to run
279594.468750 req/sec

bench as of 9bf763e

$ rm -rf bench; make clean; make -j8; make bench; ./bench
rm -f *.o *.a tags test test_fast test_g \
        http_parser.tar libhttp_parser.so.* \
        url_parser url_parser_g parsertrace parsertrace_g
cc -I. -DHTTP_PARSER_STRICT=1  -Wall -Wextra -Werror -O0 -g  -c http_parser.c -o http_parser_g.o
cc -I. -DHTTP_PARSER_STRICT=1  -Wall -Wextra -Werror -O0 -g  -c test.c -o test_g.o
cc -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -c http_parser.c
cc -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -c test.c -o test.o
cc -Wall -Wextra -Werror -O0 -g   http_parser_g.o test_g.o -o test_g
cc -Wall -Wextra -Werror -O3   http_parser.o test.o -o test_fast
./test_g
http_parser v2.3.0 (0x020300)
sizeof(http_parser) = 32
response scan 1/2  100%
response scan 2/2  100%
responses okay
request scan 1/4  100%
request scan 2/4  100%
request scan 3/4  100%
request scan 4/4  100%
requests okay
./test_fast
http_parser v2.3.0 (0x020300)
sizeof(http_parser) = 32
response scan 1/2  100%
response scan 2/2  100%
responses okay
request scan 1/4  100%
request scan 2/4  100%
request scan 3/4  100%
request scan 4/4  100%
requests okay
cc -I. -DHTTP_PARSER_STRICT=0  -Wall -Wextra -Werror -O3  -Wno-unused-parameter -c bench.c -o bench.o
cc -Wall -Wextra -Werror -O3  -Wno-unused-parameter  http_parser.o bench.o -o bench
Benchmark result:
Took 5.048899 seconds to run
990314.875000 req/sec


pos = memchr(p, CR, data + len - p);
if (pos == NULL)
pos = memchr(p, LF, data + len - p);

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@bnoordhuis
Copy link
Member

Needs some clarification about end-of-line scanning but apart from that LGTM and nice work. As discussed on IRC, scanning for known headers could probably be optimized some more using e.g. Boyer-Moore skip tables.

@indutny
Copy link
Member Author

indutny commented Nov 29, 2014

@bnoordhuis please take a look at latest commit, it should fix the issue with end-of-line scan.

@indutny
Copy link
Member Author

indutny commented Nov 29, 2014

All landed in 3f1a05a, 6132d1f, 0cb0ee6, 2630060, c6097e1, 0097de5, 959f4cb. Thank you!

@indutny indutny closed this Nov 29, 2014
@indutny indutny deleted the feature/perf-improvement branch November 29, 2014 00:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants