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

Update clock speed #13293

Merged
merged 17 commits into from
Sep 12, 2024
Merged

Update clock speed #13293

merged 17 commits into from
Sep 12, 2024

Conversation

GUIDINGLI
Copy link
Contributor

@GUIDINGLI GUIDINGLI commented Sep 4, 2024

Summary

Update clock system, do this caused we want speed up the time calculation, so change:
clock_time2ticks, clock_ticks2time, clock_timespec_add, clock_timespec_compare, clock_timespec_subtract
to MACRO

mainly include:

clock: take clock_timespec_compare/add/subtract() as MACRO

clock: Replace all ts and tick conversion functions

Using the ts/tick conversion functions provided in clock.h

Impact

clock

Testing

Vela bes board, sim

@acassis
Copy link
Contributor

acassis commented Sep 4, 2024

@GUIDINGLI please fix typo: MARCO -> MACRO

Please add commit log explaining why to convert it to MACRO

@GUIDINGLI
Copy link
Contributor Author

@GUIDINGLI please fix typo: MARCO -> MACRO

Please add commit log explaining why to convert it to MACRO

done

@acassis
Copy link
Contributor

acassis commented Sep 5, 2024

@GUIDINGLI please fix typo: MARCO -> MACRO
Please add commit log explaining why to convert it to MACRO

done

Thank you @GUIDINGLI you just missed the commit message, please just explain there why to convert the function to MACRO

@xiaoxiang781216
Copy link
Contributor

@GUIDINGLI please fix the conflict.

sched/clock/clock_gettime.c Outdated Show resolved Hide resolved
sched/clock/clock_systime_ticks.c Show resolved Hide resolved
GUIDINGLI and others added 4 commits September 12, 2024 11:59
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Using the ts/tick conversion functions provided in clock.h

Do this caused we want speed up the time calculation, so change:
clock_time2ticks, clock_ticks2time, clock_timespec_add,
clock_timespec_compare, clock_timespec_subtract... to MACRO

Signed-off-by: ligd <liguiding1@xiaomi.com>
include/nuttx/clock.h Outdated Show resolved Hide resolved
GUIDINGLI and others added 7 commits September 12, 2024 13:49
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
https: //coverity.pt.xiaomi.com/#/project-view/10098/10010?selectedIssue=1275849

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Gary-Hobson and others added 6 commits September 12, 2024 13:49
CID 1266677: (#2 of 2): Use 32-bit time_t (Y2K38_SAFETY)
1. declaration_with_small_time_t: Declare use of time_t, which is defined as 32 bits wide on this platform, while the minimum safe width is 64.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
64-by-32-bit divisions are prominent in the NuttX, even on 32-bit
machines.  Luckily, many of them use a constant divisor that allows
for a much faster multiplication by the divisor's reciprocal.

The compiler already performs this optimization when compiling a 32-by-32
division with a constant divisor. Unfortunately, on 32-bit machines, gcc
does not optimize 64-by-32 divisions in that case, except for constant
divisors that happen to be a power of 2.

Let's avoid the slow path whenever the divisor is constant by manually
computing the reciprocal ourselves and performing the multiplication
inline.  In most cases, this improves performance of 64-by-32 divisions
by about two orders of magnitude compared to the __div64_32() fallback,
especially on architectures lacking a native div instruction.

Signed-off-by: ligd <liguiding1@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit 8b4b66e into apache:master Sep 12, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants