Ticket #2129 (new enhancement)

Opened 2 years ago

Last modified 17 months ago

Optimization: Helping gcc with function attributes

Reported by: tqh Owned by: bonefish
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/pre-alpha1
Keywords: Cc: anevilyak
Blocked By: Platform: x86
Blocking:

Description

I wanted to experiment with gcc's attribute((fastcall)) which makes the functions two first arguments being passed in registers. I added it to kernel functions I thought would be called a lot. The resulting OS seems to be very responsive, although no measurements have been done.

My patch is just for inspiration, it is ugly and I did not really care about compability or if I break any API. Providing it here for those interested. It is used A LOT in Mozilla sources btw although hidden behind macros. It might be useful along with other function attributes in critical parts.

Function attributes are described here:  http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Attachments

ugly-fastcall.patch Download (14.5 KB) - added by tqh 2 years ago.
Ugly fastcall patch
ugly-fastcall.r25229.patch Download (16.4 KB) - added by tqh 23 months ago.
Ugly fastcall patch against r25229

Change History

Changed 2 years ago by tqh

Ugly fastcall patch

Changed 2 years ago by tqh

attribute has two underscores in front and after that went missing in the submission.

Changed 2 years ago by anevilyak

  • cc anevilyak added

Changed 23 months ago by tqh

Ugly fastcall patch against r25229

Changed 17 months ago by korli

Ingo, would you mind giving an eye to this enhancement ? It might be a bad idea on public functions though.

Changed 17 months ago by korli

  • cc bonefish added

Changed 17 months ago by tqh

Not sure they provide much speedup. Although I still keep them around in my tree.

Changed 17 months ago by bonefish

  • cc bonefish removed
  • owner changed from axeld to bonefish

This kind of optimization can make sense; I would wait with trying it a bit longer, though. "fastcall" saves only a few cycles by passing arguments via registers instead of via the stack, but we're still looking for optimization potential of several hundred percent for certain use cases.

At any rate I would use a macro instead of hardcoding the gcc attribute.

Assigning the ticket to myself, so it won't be forgotten...

Note: See TracTickets for help on using tickets.