Todd Lipcon has posted comments on this change.

Change subject: [rpc] faster generation of KRPC call ID
......................................................................


Patch Set 2: Code-Review-1

(1 comment)

don't think this is a worthwhile optimization since this isn't a hot code path

http://gerrit.cloudera.org:8080/#/c/7813/2//COMMIT_MSG
Commit Message:

PS2, Line 48:   const int u_bound = 800000000 + (random() % 100);
            :   int n = 0;
            :   for (int i = 0; i < u_bound; ++i) {
            :     n = next_id();
            :   }
I think your microbenchmark is invalid. With -O3 it compiles to this assembly:

int main() {
  4007a0:       48 83 ec 08             sub    $0x8,%rsp
  srandom(time(nullptr));
  4007a4:       31 ff                   xor    %edi,%edi
  4007a6:       e8 d5 ff ff ff          callq  400780 <time@plt>
  4007ab:       89 c7                   mov    %eax,%edi
  4007ad:       e8 8e ff ff ff          callq  400740 <srandom@plt>
  const int u_bound = 800000000 + (random() % 100);
  4007b2:       e8 a9 ff ff ff          callq  400760 <random@plt>
  4007b7:       48 ba 0b d7 a3 70 3d    movabs $0xa3d70a3d70a3d70b,%rdx
  4007be:       0a d7 a3 
  4007c1:       48 89 c1                mov    %rax,%rcx
  4007c4:       48 f7 ea                imul   %rdx
  4007c7:       48 89 c8                mov    %rcx,%rax
  4007ca:       48 c1 f8 3f             sar    $0x3f,%rax
  4007ce:       48 01 ca                add    %rcx,%rdx
  4007d1:       48 c1 fa 06             sar    $0x6,%rdx
  4007d5:       48 29 c2                sub    %rax,%rdx
  4007d8:       48 8d 04 92             lea    (%rdx,%rdx,4),%rax


ie it's turning the loop into a single constant time multiplication.


-- 
To view, visit http://gerrit.cloudera.org:8080/7813
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I03726343d222bcd241c2c2a5a1670a672f8e5cb6
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Alexey Serbin <aser...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <a...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Todd Lipcon <t...@apache.org>
Gerrit-HasComments: Yes

Reply via email to