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

Martin v0.11.6 much faster than v0.12.0 and 0.13.0?? #1172

Open
nyurik opened this issue Feb 2, 2024 Discussed in #1161 · 3 comments
Open

Martin v0.11.6 much faster than v0.12.0 and 0.13.0?? #1172

nyurik opened this issue Feb 2, 2024 Discussed in #1161 · 3 comments
Labels
help wanted performance serving Related to web serving component

Comments

@nyurik
Copy link
Member

nyurik commented Feb 2, 2024

Discussed in #1161

Originally posted by radimkrchnacek January 30, 2024
I am testing 3 different versions of Martin on localhost with the same settings (default settings, just caching disabled) and the same postgis 3.3 database table. Versions v0.12.0 and v0.13.0 seem to be much slower than v0.11.6
I also tried running Martin with RUST_LOG=debug and the DB queries are identical for all 3 versions.
What might be the cause of these huge performance differences?

v0.12.0:
martin-v0 12 0

v0.11.6:
martin-v0 11 6

v.0.13.0
martin-v0 13 0

@ShadowSonata
Copy link

I had this similar issue the other day (as I was using the tag latest for my testing and it automatically bumped to the latest version). I found out that the content-encoding has changed.

This is the response header in v0.11.6
image

And the response header in v0.13.0
image

If I force content-encoding to gzip by adding "Accept-Encoding" to my request, the response time and the data size come back to normal.
image

@nyurik
Copy link
Member Author

nyurik commented Feb 5, 2024

@ShadowSonata I think that's the culprit. I switched the default serving compression from gzip to brotli encoding (when the browser supports both and has not set a preference of one over the other). As you can see from your own example, you gained 20% on the content size. But that 20% doesn't come from nowhere - Brotli takes longer to compress.

So there are two ways to fix this, and both in theory could be used:

  • add compression preference, e.g. a CLI param --preferred-encoding (gzip|brotli) and a similar global config file value. If the browser does not give different q values for br and gzip in the Accept-Encoding header, Martin will pick one over the other. By default, Chrome sets Accept-Encoding:gzip, deflate, br (default q=1.0 for all)
  • Martin tile cache contains pre-compressed values - i.e. the cache has the value as returned by the tile source. MBTiles usually stores gzipped tiles. Postgres usually returns uncompressed ones. This means that Martin compresses tiles on each response when tiles are coming from Postgres. The solution is to modify cache logic to store the tile after compressing it. This will make responses much faster except for the very first one (per tile coordinates).

@nyurik nyurik added the serving Related to web serving component label Feb 5, 2024
@nyurik
Copy link
Member Author

nyurik commented Feb 5, 2024

The individual issues #1178 and #1112 track both of the use cases. It should be fairly easy to do - and as always, I am more than willing to guide any newcomers if someone can step forward before I get to it in my limited volunteer time. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted performance serving Related to web serving component
Projects
None yet
Development

No branches or pull requests

2 participants