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

Trim down or minimize memory usage #18

Open
Jacalz opened this issue Nov 17, 2022 · 5 comments
Open

Trim down or minimize memory usage #18

Jacalz opened this issue Nov 17, 2022 · 5 comments

Comments

@Jacalz
Copy link
Contributor

Jacalz commented Nov 17, 2022

We have noticed, partly based on the comment here, that the following map is massive:

var glyphAliases = map[string]string{ // 2462 entries

A map of, according to the comment, 2462 different strings result in a lot of memory usage and quite a huge piece of binary size increases. Can this map be reduced in any way, only created when actually needed or something like that? It might make sense to convert it into one large switch-case (especially now that Go 1.19 uses jump tables for large int and string switch cases) as the Go compiler more easily can optimize that but it would have to be tested to make sure that it isn't noticeably slower.

@benoitkugler
Copy link
Owner

How urgent is this optimization ?
The thing is that this map is only useful for Type1 fonts, and the long term plan for this package is to be integrated in go-text, probably without support for Type1 fonts, which will make this problem disappear (and further reduce memory usage..)

@Jacalz
Copy link
Contributor Author

Jacalz commented Nov 22, 2022

Thanks for the answer. I would personally say that it is relatively important if we want to avoid the large memory increase before publishing the v2.3.0 release. While all of it likely isn't coming from here, I am currently seeing a doubling of memory usage in my application and that isn't very nice

@benoitkugler
Copy link
Owner

I've started working on a new version of the package which will remove this issue (by removing unused dependency).
In the meantime, I'll gladly accept a PR implementing one of the idea you proposed.

@Jacalz
Copy link
Contributor Author

Jacalz commented Nov 27, 2022

Great. I'll try to have a look at that later in the week :)

@Jacalz
Copy link
Contributor Author

Jacalz commented Dec 7, 2022

I ran staticcheck on the repository and it notes that as lot of stuff is unused. I will go though and clean up some unused stuff. It might be that some stuff is unused by mistake but you'll find out during the PR-review, I guess :)

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

No branches or pull requests

2 participants