Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rocksdb]: cost of rocksdb::port::PhysicalCoreID too high #2303

Closed
popcnt1 opened this issue Jul 29, 2024 · 2 comments · Fixed by #2332
Closed

[rocksdb]: cost of rocksdb::port::PhysicalCoreID too high #2303

popcnt1 opened this issue Jul 29, 2024 · 2 comments · Fixed by #2332
Assignees
Labels
Milestone

Comments

@popcnt1
Copy link
Collaborator

popcnt1 commented Jul 29, 2024

background:

When importing data using statedb genesis, I found this in perf top -p <rooch_pid>

57.33% rooch [.] rocksdb::port::PhysicalCoreID()

releated issues:

facebook/rocksdb#3889

@popcnt1 popcnt1 added this to the Rooch v0.7 milestone Jul 29, 2024
@popcnt1 popcnt1 self-assigned this Jul 29, 2024
@popcnt1
Copy link
Collaborator Author

popcnt1 commented Jul 31, 2024

we're using CPUID but not shed_getcpu:

       │    Disassembly of section .text:
       │
       │    0000000004162060 <rocksdb::port::PhysicalCoreID()>:
  0.00 │      push  %rbx
  0.00 │      xor   %eax,%eax
  4.34 │      cpuid
  0.92 │      mov   $0xffffffff,%ebx
  0.03 │      test  %eax,%eax
       │    ↓ je    18
       │      mov   $0x1,%eax
 93.41 │      cpuid
  1.11 │      shr   $0x18,%ebx
  0.01 │18:   mov   %ebx,%eax
  0.14 │      pop   %rbx
  0.04 │    ← ret

@popcnt1
Copy link
Collaborator Author

popcnt1 commented Aug 1, 2024

caused by build flage issue in our rocksdb dependency:

No ROCKSDB_SCHED_GETCPU_PRESENT definded

popcnt1 added a commit to rooch-network/rust-rocksdb that referenced this issue Aug 1, 2024
1. CPUID cost high without this flag enabled: rooch-network/rooch#2303
2. sched_getcpu() introduced in kernel2.6.19(`<sched.h>`), set it directly here, but not use the same way as rocksdb's CMakeLists.txt:
```
check_cxx_symbol_exists(sched_getcpu sched.h HAVE_SCHED_GETCPU)
if(HAVE_SCHED_GETCPU)
add_definitions(-DROCKSDB_SCHED_GETCPU_PRESENT)
endif()
```
@github-project-automation github-project-automation bot moved this to Done in Rooch Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant