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 2013/09/04 19:56:53 UTC
[jira] [Assigned] (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:all-tabpanel ]
Leif Hedstrom reassigned TS-2151:
---------------------------------
Assignee: Leif Hedstrom
> 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: 5.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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira