Skip to content

perf: skip GameDataParser if there are no subscribers#2

Closed
alrun3 wants to merge 1 commit into
TheLazzoro:mainfrom
alrun3:optional-gamedata
Closed

perf: skip GameDataParser if there are no subscribers#2
alrun3 wants to merge 1 commit into
TheLazzoro:mainfrom
alrun3:optional-gamedata

Conversation

@alrun3
Copy link
Copy Markdown
Contributor

@alrun3 alrun3 commented Aug 1, 2025

No description provided.

@TheLazzoro
Copy link
Copy Markdown
Owner

TheLazzoro commented Aug 1, 2025

OnGameDataBlock is always subscribed to through W3GReplay.cs contructor, so even though it's nullable it's actually never the case. Is there a particular goal in mind?

@alrun3
Copy link
Copy Markdown
Contributor Author

alrun3 commented Aug 1, 2025

OnGameDataBlock is always subscribed to through W3GReplay.cs contructor, so even though it's nullable it's actually never the case

My bad I use LINQPad and just #load in the classes, which makes internal members accessible, so I completely overlooked the visibility:

#load ".\W3G-NET\W3GNET\Parsers\*.cs"
#load ".\W3G-NET\W3GNET\Extensions\*.cs"
#load ".\W3G-NET\W3GNET\Types\*.cs"
#load ".\W3G-NET\W3GNET\Util\*.cs"
#load ".\W3G-NET\W3GNET\W3GReplay.cs"

using W3GNET.Parsers;
using System.Linq;

async Task Main()
{
    var parser = new ReplayParser();

Is there a particular goal in mind?

If you're just searching through your replay directory for specific metadata, skipping the gamedata parsing significantly improves performance. Eg.:

new ReplayBrowser(UserProfile, Id)
    .EnumerateReplays()
    .Where(r => r.MapName.Contains("<some map name>"))
    .Select(r => r.FileInfo)

@alrun3 alrun3 closed this Aug 1, 2025
@alrun3 alrun3 deleted the optional-gamedata branch August 1, 2025 22:43
@TheLazzoro
Copy link
Copy Markdown
Owner

If you're just searching through your replay directory for specific metadata, skipping the gamedata parsing significantly improves performance.

Ah yeah right now it just parses everything. If the goal here is to improve performance for this type of scenario I would recommend adding parameters so you can explicitly tell the parser to skip certain parts.

@alrun3
Copy link
Copy Markdown
Contributor Author

alrun3 commented Aug 19, 2025

If you're just searching through your replay directory for specific metadata, skipping the gamedata parsing significantly improves performance.

Ah yeah right now it just parses everything.

I just took another look, and since the class is part of the public API, the change still seems valid.

If the goal here is to improve performance for this type of scenario I would recommend adding parameters so you can explicitly tell the parser to skip certain parts.

I understand the suggestion. However, relying on both configuration and subscriber presence seems redundant. Emitting data only when there are subscribers helps keep the API surface smaller and avoids potential mismatches between configuration and actual usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants