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

RFE: Toggle membership events on/off (per channel, ideally) #282

Closed
sergiodj opened this issue Jul 1, 2024 · 8 comments
Closed

RFE: Toggle membership events on/off (per channel, ideally) #282

sergiodj opened this issue Jul 1, 2024 · 8 comments
Assignees
Labels
discussion enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@sergiodj
Copy link

sergiodj commented Jul 1, 2024

Hi,

The other day I viewed a room which wasn't very large, but I noticed that it took ement several seconds to display it. This was unusual behaviour, so I decided to profile Emacs and understand what was going on. I noticed that almost half of the CPU time was spent processing membership events.

I like having membership events displayed in some of the rooms I'm in, but I would gladly turn them off on most of them. I've been reading ement's code, more specifically ement-room--format-membership-events and ement-room--pp-thing, to see if I can hack it and make it ignore the events. I'll submit a PR when I have something.

Thanks.

@phil-s
Copy link

phil-s commented Jul 1, 2024

See also #247

@alphapapa
Copy link
Owner

Yes, #247 should solve the performance problem.

@sergiodj I've been using Ement for years, including in rooms like #matrix-hq:matrix.org, which has over 30,000 members. Until Arto reported the problem mentioned in #247, I had never heard of a situation in which there were so many membership events that it was a performance problem. So the problem you're reporting seems also unusual, and so I'd ask you to provide more information about the room and its events so we can understand what's going on. Just turning off membership events would probably not be a good solution, and I'd prefer not to add another option like that unless it were really necessary.

@sergiodj
Copy link
Author

sergiodj commented Jul 2, 2024

Thanks, @alphapapa.

I find it strange, too. For me, this only happened so far in rooms bridged with Heisenbridge. I wonder if it's because membership events are much more common on IRC (i.e., people who don't use bouncers tend to disconnect at night, plus the many "connection reset by peer" problems).

To give you an example, when I opened my #emacs @ libera.chat room for the first time today it took about 10 minutes for ement to process everything (meanwhile, my Emacs was blocked waiting). Upon looking at the backlog that was loaded, I see roughly 1000 membership events (most of them being joined, left or a combination of the two).

I don't know what else I can provide, but please let me know if you think of something.

Thanks.

@alphapapa
Copy link
Owner

I find it strange, too. For me, this only happened so far in rooms bridged with Heisenbridge. I wonder if it's because membership events are much more common on IRC (i.e., people who don't use bouncers tend to disconnect at night, plus the many "connection reset by peer" problems).

To give you an example, when I opened my #emacs @ libera.chat room for the first time today it took about 10 minutes for ement to process everything (meanwhile, my Emacs was blocked waiting). Upon looking at the backlog that was loaded, I see roughly 1000 membership events (most of them being joined, left or a combination of the two).

That would seem to suggest that there were about 1,000 membership events in the same span of time that there were about 30 message events (AFAIR the Matrix server tries to send about the last 30 message events in a room upon initial sync). That seems unusual, but maybe it's not...? I mean, I used to join #emacs:libera.chat when it was bridged via Libera's Matrix bridge, and I never had any problems remotely like this. So I wonder if it's something to do with the bridge involved.

Anyway, please try the branch in question and let me know how well it performs with opening that room. If it's still too slow, I guess we'll have to figure out a way to disable membership events in certain rooms.

@sergiodj
Copy link
Author

sergiodj commented Jul 4, 2024

Thanks for the reply.

I will probably be able to give the branch a try tomorrow, and will report back my findings.

Either way, I still believe it would be beneficial to have the ability to silence membership events from certain channels. I understand that this may be considered a low priority request, though.

@alphapapa alphapapa self-assigned this Jul 4, 2024
@alphapapa alphapapa added the enhancement New feature or request label Jul 4, 2024
@alphapapa alphapapa added this to the Future milestone Jul 4, 2024
@alphapapa
Copy link
Owner

It sounds simple enough: just disable membership events for a room. But there's a lot more to it than that:

  1. UI. It probably means making new commands to toggle them on and off (and they should probably be generic enough to toggle other event types in the future). Those probably need to appear in the room transient menu as well, with bindings, and dynamic labels to show the status.
  2. On the back end, we have to decide how to persist the data. We could use a custom event type in the room's account data, but if possible, we should try to integrate with existing specifications or apps (e.g. does Element support this? If so, can we use the same data on the backend to represent the setting?). If we have to make our own event type, we have to decide whether to make it just for membership events, or whether to store a list of event types to disable. And maybe instead of just disabling them, we want to have an option to...handle them differently, I don't know (other event types might end up with an option to handle them more quietly or something).

Given all that, it would probably only take a few minutes to write some advice functions that you could use to ignore membership events in certain rooms. They could sit in your config and solve this problem for you immediately. Then, eventually, something like this could be implemented in a flexible, extensible way suitable for the long-term.

@alphapapa alphapapa added help wanted Extra attention is needed discussion labels Jul 4, 2024
@sergiodj
Copy link
Author

sergiodj commented Jul 4, 2024

Thanks for replying and considering the feature.

Sure, in theory I could solve every problem by advising functions and so on, but it would be great to have features implemented on Ement as well.

Cheers.

@alphapapa
Copy link
Owner

Sure, in theory I could solve every problem by advising functions and so on, but it would be great to have features implemented on Ement as well.

What I'm trying to convey is that it would probably take about 5 lines of code to solve this problem in your config temporarily with advice; and that I wouldn't expect this kind of feature to be implemented in Ement itself anytime soon, because my to-do list is quite long. So if it makes the difference between being able to use it in that kind of chat room or not...it's up to you. :)

@alphapapa alphapapa modified the milestones: Future, 0.16 Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants