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

Improve memory and performance of url.Query #410

Closed
wants to merge 3 commits into from

Conversation

karlseguin
Copy link
Contributor

@karlseguin karlseguin commented Feb 8, 2025

1 - Use getOrPut to avoid making 2 map lookups where possible.

2 - Use an arena allocator for Values, which makes memory management simpler.

3 - Because of the arena, we no longer need to allocate key or values which don't need
to be unescaped. The downside is that the input string has to outlive the
query.Values (but I think this is currently always the case)

4 - Optimize unescape logic & allocations

5 - Improve test coverage

1 - Use getOrPut to avoid making 2 map lookups where possible.

2 - Use an arena allocator for Values, which makes memory management simpler.

3 - Because of lightpanda-io#2, we no longer need to allocate key or values which don't need
    to be unescaped. The downside is that the input string has to outlive the
    query.Values (but I think this is currently always the case)

4 - Optimize unescape logic & allocations

5 - Improve test coverage
@krichprollsch krichprollsch self-requested a review February 8, 2025 10:34
test "parse empty query" {
var values = try parseQuery(std.testing.allocator, "");
defer values.deinit();
// The return'd string may or may not be allocated. Callers should use arenas
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we change the allocator we pass to unescape in parseQuery to use the values's arena then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

YES! The test runner doesn't detect memory leaks when using std.testing.allocator right now (https://github.com/lightpanda-io/browser/pull/409)...would have caught that.

@karlseguin karlseguin closed this Feb 10, 2025
@karlseguin karlseguin deleted the url_query branch February 10, 2025 08:12
@github-actions github-actions bot locked and limited conversation to collaborators Feb 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants