You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by "Leif Hedstrom (JIRA)" <ji...@apache.org> on 2015/05/12 21:09:01 UTC

[jira] [Commented] (TS-2151) Do we really need HttpSM::_instantiate_func() now?

    [ https://issues.apache.org/jira/browse/TS-2151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14540506#comment-14540506 ] 

Leif Hedstrom commented on TS-2151:
-----------------------------------

I did some quick benchmark, exercising a lot of HttpSM allocations.

Current code:

{code}
7338035 fetches on 72800 conns, 300 max parallel, 7.338040E+08 bytes, in 60 seconds
100 mean bytes/fetch
122300.5 fetches/sec, 1.223005E+07 bytes/sec
msecs/connect: 0.828 mean, 2.769 max, 0.057 min
msecs/first-response: 2.369 mean, 355.065 max, 0.093 min
{code}

Without the Sparse allocation:

{code}
7481466 fetches on 74248 conns, 300 max parallel, 7.481470E+08 bytes, in 60 seconds
100 mean bytes/fetch
124691.1 fetches/sec, 1.246911E+07 bytes/sec
msecs/connect: 0.923 mean, 2.600 max, 0.056 min
msecs/first-response: 2.310 mean, 411.276 max, 0.094 min
{code}


it certainly doesn't seem like it's making any significant difference, in fact, without Sparse allocation is marginally faster.

I think the simplification is well worth it, since we avoid possible existing and future problems where an HttpSM is not properly initialized.

> Do we really need HttpSM::_instantiate_func() now?
> --------------------------------------------------
>
>                 Key: TS-2151
>                 URL: https://issues.apache.org/jira/browse/TS-2151
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Leif Hedstrom
>            Assignee: Leif Hedstrom
>             Fix For: 6.0.0
>
>
> The HttpSM implements the instantiate_func() which means the Sparse Class allocator ends up trying to "optimize" the memcpy(). We should benchmark this, and see if is actually a performance improvement still. Simplifying this code with just a mempcy() (i.e. use normal class allocator behavior) would make it safer and less confusing.
> {code}
> void
> HttpSM::_instantiate_func(HttpSM * prototype, HttpSM * new_instance)
> {
>   int history_len = sizeof(prototype->history);
>   int total_len = sizeof(HttpSM);
>   int pre_history_len = (char *) (&(prototype->history)) - (char *) prototype;
>   int post_history_len = total_len - history_len - pre_history_len;
>   int post_offset = pre_history_len + history_len;
> #ifndef SIMPLE_MEMCPY_INIT
>   int j;
>   memset(((char *) new_instance), 0, pre_history_len);
>   memset(((char *) new_instance) + post_offset, 0, post_history_len);
>   uint32_t *pd = (uint32_t *) new_instance;
>   for (j = 0; j < scat_count; j++) {
>     pd[to[j]] = val[j];
>   }
>   ink_assert((memcmp((char *) new_instance, (char *) prototype, pre_history_len) == 0) &&
>                    (memcmp(((char *) new_instance) + post_offset, ((char *) prototype) + post_offset, post_history_len) == 0));
> #else
>   // memcpy(new_instance, prototype, total_len);
>   memcpy(new_instance, prototype, pre_history_len);
>   memcpy(((char *) new_instance) + post_offset, ((char *) prototype) + post_offset, post_history_len);
> #endif
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)