Skip to content

Refactor: memory-efficient geo file decoder#934

Merged
Loyalsoldier merged 4 commits intov2fly:masterfrom
Loyalsoldier:refactor-geodata
Apr 30, 2021
Merged

Refactor: memory-efficient geo file decoder#934
Loyalsoldier merged 4 commits intov2fly:masterfrom
Loyalsoldier:refactor-geodata

Conversation

@Loyalsoldier
Copy link
Contributor

@Loyalsoldier Loyalsoldier commented Apr 25, 2021

This PR implements a simple decoder based on LEB128 used in protobuf. It reads geo files byte by byte to reduce peak memory usage when V2Ray parses configuration.

If the decoder fails to decode the geo file, it will fallback to the original ReadFile method to keep backward compatibility.

About protobuf encoding and decoding, read https://developers.google.com/protocol-buffers/docs/encoding

Copy link
Contributor

@kslr kslr left a comment

Choose a reason for hiding this comment

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

如果能用 mixmind 原始数据就更好了

@xiaokangwang
Copy link
Contributor

It is better if it can be made a option, instead of something fixed.

Copy link
Contributor

@xiaokangwang xiaokangwang left a comment

Choose a reason for hiding this comment

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

I would like to advise making this a option. Please only merge after a stable release.

@Loyalsoldier Loyalsoldier merged commit 7e87670 into v2fly:master Apr 30, 2021
@dyhkwong
Copy link
Contributor

dyhkwong commented May 1, 2021

As a side effect, this impl causes v2ray-core to have full cpu usage, hang and even become unresponsive for a few seconds at startup (test with default geo files). Think twice?

@xiaokangwang
Copy link
Contributor

This change my subject to revert, please keep your branch.

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.

4 participants