Skip to content

Comments

bus: use va_marshaller to avoid GValue boxing#2683

Merged
fujiwarat merged 1 commit intoibus:mainfrom
chergert:main
Oct 15, 2024
Merged

bus: use va_marshaller to avoid GValue boxing#2683
fujiwarat merged 1 commit intoibus:mainfrom
chergert:main

Conversation

@chergert
Copy link

Building your own marshaller list is most of the way there to get better signal performance, but you can go a bit further by having it generate va_marshallers and set those too.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows you to also get better profiling data at runtime.

@fujiwarat fujiwarat self-requested a review October 5, 2024 16:22
Copy link
Member

@fujiwarat fujiwarat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your patch.

I noticed the comment in glib/gobject/gsignal.c:g_signal_new() explains g_signal_set_va_marshaller(). and confirmed the patch can switch to use the va_marshaller.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows you to also get better profiling data at runtime.

I guess the GValue boxing means instance_and_params in glib//gobject/gsignal.c:signal_emit_valist_unlocked() and it might effects the memory usage of ibus-daemon?

I'm not sure about where effects the better profiling data.
It would be great if you rebase the patch and add the BUG=https://github.com/ibus/ibus/pull/2683 line at the last of your patch description.

I will test your patch as Fedora internal patch.

@chergert
Copy link
Author

chergert commented Oct 6, 2024

I guess the GValue boxing means instance_and_params in glib//gobject/gsignal.c:signal_emit_valist_unlocked() and it might effects the memory usage of ibus-daemon?

I wouldn't expect any difference to memory usage.

I'm not sure about where effects the better profiling data.

By using the va_marshaller you can collect the values from the call site and directly call the signal handler using the default calling convention without any sort of FFI trampoline. Where that helps with profiling is that you'll get a proper callstack that the Linux kernel's perf subsystem can unwind.

It would be great if you rebase the patch and add the BUG=#2683 line at the last of your patch description.

Sure thing

Building your own marshaller list is most of the way there to get better
signal performance, but you can go a bit further by having it generate
va_marshallers and set those too.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows
you to also get better profiling data at runtime.

BUG=ibus#2683
@fujiwarat
Copy link
Member

LGTM. Merged.

I wouldn't expect any difference to memory usage.

Sorry, I meant to reduce the times of the memory allocation and enhance the performance.

Where that helps with profiling is that you'll get a proper callstack that the Linux kernel's perf subsystem can unwind.

Thank you. I will learn it later.

fujiwarat added a commit to fujiwarat/ibus that referenced this pull request Dec 19, 2024
Building your own marshaller list is most of the way there to get better
signal performance, but you can go a bit further by having it generate
va_marshallers and set those too.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows
you to also get better profiling data at runtime.

Fixes: ibus@c13c54e
BUG=ibus#2683
@fujiwarat
Copy link
Member

Applying another patch for 1.5.32 above.

fujiwarat added a commit to fujiwarat/ibus that referenced this pull request Dec 19, 2024
Building your own marshaller list is most of the way there to get better
signal performance, but you can go a bit further by having it generate
va_marshallers and set those too.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows
you to also get better profiling data at runtime.

Fixes: ibus@c13c54e
BUG=ibus#2683
fujiwarat added a commit to fujiwarat/ibus that referenced this pull request Dec 24, 2024
Building your own marshaller list is most of the way there to get better
signal performance, but you can go a bit further by having it generate
va_marshallers and set those too.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows
you to also get better profiling data at runtime.

Fixes: ibus@c13c54e
BUG=ibus#2683
fujiwarat added a commit to fujiwarat/ibus that referenced this pull request Dec 29, 2024
Building your own marshaller list is most of the way there to get better
signal performance, but you can go a bit further by having it generate
va_marshallers and set those too.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows
you to also get better profiling data at runtime.

Fixes: ibus@c13c54e
BUG=ibus#2683
fujiwarat added a commit that referenced this pull request Jan 12, 2025
Building your own marshaller list is most of the way there to get better
signal performance, but you can go a bit further by having it generate
va_marshallers and set those too.

Not only do va_marshallers allow you to avoid the GValue boxing, it allows
you to also get better profiling data at runtime.

Fixes: c13c54e
BUG=#2683
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants