Skip to content

benchmark: http parser optimization

This change refers to http/bench-parser.js, and we also call is Http Parser benchmark. We propose the following change in Node.JS, in file deps/v8/src/utils.h: Old:

template <typename sourcechar, typename sinkchar>
void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, size_t chars) {
 sinkchar* limit = dest + chars;
 if ((sizeof(*dest) == sizeof(*src)) &&
     (chars >= static_cast<int>(kMinComplexMemCopy / sizeof(*dest)))) {
   MemCopy(dest, src, chars * sizeof(*dest));
 } else {
   while (dest < limit) *dest++ = static_cast<sinkchar>(*src++);
 }
}

New:

template <typename sourcechar, typename sinkchar>
void CopyCharsUnsigned(sinkchar* dest, const sourcechar* src, size_t chars) {
 sinkchar* limit = dest + chars;
 if (sizeof(*dest) == sizeof(*src))
{
   MemCopy(dest, src, chars * sizeof(*dest));
 } else {
   while (dest < limit) *dest++ = static_cast<sinkchar>(*src++);
 }
}

Please see the details in the attached file. MessageForTheCommunity.docx

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

The copy of several buffers could be optimized by using memcpy directly, instead of direct copying char after char.

Merge request reports

Loading