-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
nsqd: cpu usage on ARM #658
Comments
It does seem like a surprising amount of time is taken to get time and divide just to generate GUIDs. By the way,
|
os is ubuntu 14.04 cpu is tk1 the nsqd is in version 0.3.2 i 've build another version 0.3.5 today and would test if the question is resolved |
So the Tegra K1, ARMv7 (32bit) Cortext A15 (or "project denver" 64-bit ARMv8 cores, but I'm guessing that's less likely). I don't think much nsqd benchmarking/tuning has been done on ARM. It makes sense that int64 division overhead could be rather different. And as for time related functions, I'm really not sure; for c programs on x86/64 it's accelerated with the VDSO (virtual dynamic shared object), for go on arm ... ? |
@Huangyan9188 Also if you can share which version of Go you had 0.3.2 compiled with and what version you recompile 0.3.5 with (ideally Go 1.5.1), that would be helpful. |
@Huangyan9188 might you be able to try my branch in #663 |
While looking at this, I noticed something interesting: idPump() is doing a lot of time.Now() and time.Sub(), which it would only do if there were a lot of errors from NewGUID() (or if runtime.Gosched() happened to result in inline calls to those same functions) |
@Huangyan9188 can you paste the |
Hello, guys, we have find the point Testing Case
Then Nsq's CPU Usage up to the top The core of this problem is the NewGUID function, It's related time serious If i could fix it by changing the guid generation method? |
@Huangyan9188 would you like to open a PR for discussion? |
We recognize that nsqd does not handle it very well when time goes backwards. It's more serious than high cpu usage; nsqd can't generate any usable GUIDs for messages. In the short term, if you're trying to use nsqd, use something like ntpd, and make sure the time is OK before nsqd starts. Maybe use ntpdate to jump the time, then start ntpd, which will "slew" the time, and never cause it to jump backwards. |
So, uh, I'll just mention that an obvious alternative algorithm for generating IDs, which does not depend on millisecond-precise time, is a well seeded, good pseudorandom generator (openbsd's arc4random() is just one on the top of my head). There is a 1% chance of a duplicate of random 64-bit ID if you generate 610,000,000 of them (see this useful birthday paradox table). But it's probably not worth changing the algorithm and seeing what the performance is like, because there are other places in nsqd that I expect might be confused if time went backwards, like message expiry and defers (though those might be fixed by being based on system monotonic time?). Anyway, this isn't really about ARM performance anymore, it might be worth closing. |
why id are all 0784e362e6570000, because we use nsqd in cloud devices, so should always ntpupdate ,so we should fix this issue to continue use that |
Going to close this, thanks for the discussion. Although there might be room for improvement in the way |
The text was updated successfully, but these errors were encountered: