News for hackers. Stuff that matters.
Re:A fast HTTP request/response parser for Common Lisp by halayli on Thursday October 30, 2014 @03:19PM (#8535191)
parsed = http_parser_execute(parser, &settings_null, buf, strlen(buf));

assert(parsed == strlen(buf));

He's calling strlen(buf) twice here. There's no guarantee that this is optimized at compile time. Usually len of buf is determined from read/recv system calls and for a fair comparison strlen should be removed here.

Re:A fast HTTP request/response parser for Common Lisp by fukamachi on Thursday October 30, 2014 @03:29PM (#8535254)
No difference even though I ran the benchmark again after removing the line.
Re:A fast HTTP request/response parser for Common Lisp by halayli on Thursday October 30, 2014 @04:40PM (#8535677)
Interesting. I was expecting at least cpu branch improvements given the lack of assert.
Re:A fast HTTP request/response parser for Common Lisp by halayli on Thursday October 30, 2014 @05:18PM (#8535884)
Also use gettimeofday() instead of clock(), because you don't know how far into the second you are at the time it's called.
Re:A fast HTTP request/response parser for Common Lisp by jeffreyrogers on Friday October 31, 2014 @12:04AM (#8537249)
Any good compiler will optimize that out. (Actually, even a bad compiler will optimize that out... it's a really easy optimization).
Re:A fast HTTP request/response parser for Common Lisp by Ono-Sendai on Thursday October 30, 2014 @03:29PM (#8535251)
assert only runs in debug mode anyway.
Re:A fast HTTP request/response parser for Common Lisp by haberman on Thursday October 30, 2014 @03:32PM (#8535278)
It runs unless NDEBUG is defined, which the author did not do according to his methodology. Anyway I looked at the assembly output and strlen() is optimized away.
Re:A fast HTTP request/response parser for Common Lisp by webreac on Thursday October 30, 2014 @05:30PM (#8535937)
I really do not like when bad habits are encouraged by the optimizer.
Re:A fast HTTP request/response parser for Common Lisp by halayli on Thursday October 30, 2014 @04:39PM (#8535668)
Re:A fast HTTP request/response parser for Common Lisp by aidenn0 on Friday October 31, 2014 @02:50AM (#8537605)
"Forcing a definition of the name NDEBUG, either from the compiler command line or with the preprocessor control statement #define NDEBUG ahead of the #include <assert.h> statement, shall stop assertions from being compiled into the program"