• R/O
  • SSH
  • HTTPS

chibios: Commit


Commit MetaInfo

Revisão14528 (tree)
Hora2021-06-11 19:04:12
Autorgdisirio

Mensagem de Log

Performance improvements thanks to code paths tuning using likely/unlikely macros.

Mudança Sumário

Diff

--- trunk/doc/rt/reports/benchmarks/rt-stm32g4-170mhz-gcc.txt (revision 14527)
+++ trunk/doc/rt/reports/benchmarks/rt-stm32g4-170mhz-gcc.txt (revision 14528)
@@ -1,11 +1,11 @@
11
22 *** ChibiOS/RT Test Suite
33 ***
4-*** Compiled: Jun 7 2021 - 08:51:33
4+*** Compiled: Jun 11 2021 - 11:12:01
55 *** Platform: STM32G4 Hi-resolution Line
66 *** Test Board: STMicroelectronics STM32 Nucleo64-G474RE
77 ***
8-*** Text size: 51148 bytes
8+*** Text size: 50964 bytes
99 *** RO data size: 9904 bytes
1010 *** Data size: 220 bytes
1111 *** BSS size: 5400 bytes
@@ -189,7 +189,7 @@
189189 === Test Sequence 12 (Benchmarks)
190190 ----------------------------------------------------------------------------
191191 --- Test Case 12.1 (Messages performance #1)
192---- Score : 904248 msgs/S, 1808496 ctxswc/S
192+--- Score : 923906 msgs/S, 1847812 ctxswc/S
193193 --- Result: SUCCESS
194194 ----------------------------------------------------------------------------
195195 --- Test Case 12.2 (Messages performance #2)
@@ -201,7 +201,7 @@
201201 --- Result: SUCCESS
202202 ----------------------------------------------------------------------------
203203 --- Test Case 12.4 (Context Switch performance)
204---- Score : 2821568 ctxswc/S
204+--- Score : 2893608 ctxswc/S
205205 --- Result: SUCCESS
206206 ----------------------------------------------------------------------------
207207 --- Test Case 12.5 (Threads performance, full cycle)
@@ -209,15 +209,15 @@
209209 --- Result: SUCCESS
210210 ----------------------------------------------------------------------------
211211 --- Test Case 12.6 (Threads performance, create/exit only)
212---- Score : 634325 threads/S
212+--- Score : 639095 threads/S
213213 --- Result: SUCCESS
214214 ----------------------------------------------------------------------------
215215 --- Test Case 12.7 (Mass reschedule performance)
216---- Score : 288135 reschedules/S, 1728810 ctxswc/S
216+--- Score : 289115 reschedules/S, 1734690 ctxswc/S
217217 --- Result: SUCCESS
218218 ----------------------------------------------------------------------------
219219 --- Test Case 12.8 (Round-Robin voluntary reschedule)
220---- Score : 1748060 ctxswc/S
220+--- Score : 1752560 ctxswc/S
221221 --- Result: SUCCESS
222222 ----------------------------------------------------------------------------
223223 --- Test Case 12.9 (Virtual Timers set/reset performance)
@@ -249,11 +249,11 @@
249249
250250 *** ChibiOS OS Library Test Suite
251251 ***
252-*** Compiled: Jun 7 2021 - 08:51:33
252+*** Compiled: Jun 11 2021 - 11:12:01
253253 *** Platform: STM32G4 Hi-resolution Line
254254 *** Test Board: STMicroelectronics STM32 Nucleo64-G474RE
255255 ***
256-*** Text size: 51148 bytes
256+*** Text size: 50964 bytes
257257 *** RO data size: 9904 bytes
258258 *** Data size: 220 bytes
259259 *** BSS size: 5400 bytes
--- trunk/os/rt/src/chschd.c (revision 14527)
+++ trunk/os/rt/src/chschd.c (revision 14528)
@@ -414,11 +414,13 @@
414414 }
415415 #endif
416416
417- /* If the waken thread has a not-greater priority than the current
417+ /* If the woken thread has a not-greater priority than the current
418418 one then it is just inserted in the ready list else it made
419419 running immediately and the invoking thread goes in the ready
420- list instead.*/
421- if (ntp->hdr.pqueue.prio <= otp->hdr.pqueue.prio) {
420+ list instead.
421+ Note, we are favoring the path where the woken thread has higher
422+ priority.*/
423+ if (unlikely(ntp->hdr.pqueue.prio <= otp->hdr.pqueue.prio)) {
422424 (void) __sch_ready_behind(ntp);
423425 }
424426 else {
@@ -455,7 +457,9 @@
455457
456458 chDbgCheckClassS();
457459
458- if (firstprio(&oip->rlist.pqueue) > tp->hdr.pqueue.prio) {
460+ /* Note, we are favoring the path where the reschedule is necessary
461+ because higher priority threads are ready.*/
462+ if (likely(firstprio(&oip->rlist.pqueue) > tp->hdr.pqueue.prio)) {
459463 __sch_reschedule_ahead();
460464 }
461465 }
@@ -563,19 +567,21 @@
563567 tprio_t p1 = firstprio(&oip->rlist.pqueue);
564568 tprio_t p2 = tp->hdr.pqueue.prio;
565569
570+ /* Note, we are favoring the path where preemption is necessary
571+ because higher priority threads are ready.*/
566572 #if CH_CFG_TIME_QUANTUM > 0
567573 if (tp->ticks > (tslices_t)0) {
568- if (p1 > p2) {
574+ if (likely(p1 > p2)) {
569575 __sch_reschedule_ahead();
570576 }
571577 }
572578 else {
573- if (p1 >= p2) {
579+ if (likely(p1 >= p2)) {
574580 __sch_reschedule_behind();
575581 }
576582 }
577583 #else /* CH_CFG_TIME_QUANTUM == 0 */
578- if (p1 > p2) {
584+ if (likely(p1 > p2)) {
579585 __sch_reschedule_ahead();
580586 }
581587 #endif /* CH_CFG_TIME_QUANTUM == 0 */
@@ -595,7 +601,9 @@
595601
596602 chDbgCheckClassS();
597603
598- if (firstprio(&oip->rlist.pqueue) >= tp->hdr.pqueue.prio) {
604+ /* If this function has been called then it is likely there are threads
605+ at same priority level.*/
606+ if (likely(firstprio(&oip->rlist.pqueue) >= tp->hdr.pqueue.prio)) {
599607 __sch_reschedule_behind();
600608 }
601609 }
--- trunk/release_note_next.txt (revision 14527)
+++ trunk/release_note_next.txt (revision 14528)
@@ -47,6 +47,9 @@
4747
4848 - Support for full-SMP multi-core threading.
4949 - Support for decoupled multi-core threading.
50+- Performance improvements thanks to code paths tuning using likely/unlikely
51+ macros. This feature requires compiler support and is currently enabled
52+ for GCC.
5053 - 64 bits monotonic time stamps with the same resolution of system time.
5154 - Much more efficient and accurate Virtual Timers in tick-less mode.
5255 - Automatic reload of Virtual Timers, now both one-shot and continuous timers
Show on old repository browser