Opened 11 years ago

Last modified 6 months ago

#2129 new enhancement

Optimization: Helping gcc with function attributes

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

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 (2)

ugly-fastcall.patch (14.5 KB) - added by tqh 11 years ago.
Ugly fastcall patch
ugly-fastcall.r25229.patch (16.4 KB) - added by tqh 11 years ago.
Ugly fastcall patch against hrev25229

Download all attachments as: .zip

Change History (10)

Changed 11 years ago by tqh

Attachment: ugly-fastcall.patch added

Ugly fastcall patch

comment:1 Changed 11 years ago by tqh

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

comment:2 Changed 11 years ago by anevilyak

Cc: anevilyak added

Changed 11 years ago by tqh

Attachment: ugly-fastcall.r25229.patch added

Ugly fastcall patch against hrev25229

comment:3 Changed 10 years ago by korli

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

comment:4 Changed 10 years ago by korli

Cc: bonefish added

comment:5 Changed 10 years ago by tqh

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

comment:6 Changed 10 years 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...

comment:7 Changed 4 years ago by pulkomandy

Milestone: R1Unscheduled

comment:8 Changed 6 months ago by waddlesplash

At this point, running LTO over the full kernel would probably provide whatever benefit this does, and then some. But I could be mistaken...

Note: See TracTickets for help on using tickets.