-
Notifications
You must be signed in to change notification settings - Fork 25k
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
zstd is much slower than deflate #119662
Comments
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
I've just found out that in 8.17 there's an undocumented, but working I've done the benchmarks again with the |
Thanks @hchargois for reporting the effects that you see in your environment because of the zstandard compression change. I have not yet replicated the experiment that you shared in the issue description, but a while back when we experimented with zstandard and in general we observed that switching from deflate to zstandard for when index.codec=best_compression, at worst resulted in similar performance / compression ratio as delate and at best gave better compression ratio and better performance. (mainly better indexing throughput) Based on the query you shared (the For your use case how does index.codec=default perform? This is used by default and uses lz4 under the hood and in general should perform better for when stored field read performance is more important compared to how well stored fields compress on disk.
Yes, the |
lz4 of course performs much much better in query speed, around 150 ms on that test index, more than 10x faster than deflate. But the storage size is much larger, the index is 930 MB (25 % more than deflate). We can't really afford that much extra space. Deflate has always provided a trade-off that suited us fine. Of course we wouldn't mind better query times for the same index size, or a smaller index size for the same query times... but with zstd it's significantly worse query times for no gain in index size... Not very enticing. BTW I used a large size to better show the influence of the codec decompressing the stored fields, as you mentioned, and to have larger numbers to compare and avoid noise. Still, the incidence of the codec speed manifests itself at any size, even as low as the default size of 10 (even though
(all times in ms, from the |
Elasticsearch Version
8.17.0
Installed Plugins
No response
Java Version
bundled
OS Version
Archlinux, kernel 6.12.1-arch1-1
Problem Description
The zstd codec introduced in ES 8.16 performs significantly worse than the old deflate codec, in terms of read (query) speed. Queries that need to read stored fields perform around 30 to 45 % worse with zstd than with deflate.
Moreover, I've found that there are no counterbalancing benefits, as the indexing speed doesn't improve, and the index size is only around 1% smaller at best, which is not significant.
So basically we're trading a <1 % improvement in index size with a ~ 40 % deterioration of query speed. For my use-case, that's not worth it.
I'm opening this as a "bug" because to me it's a huge regression, especially since there's no option to keep using deflate.
I don't know if the zstd codec can be "fixed" by optimizing it or changing its parameters, but regardless we should be able to continue using the deflate codec. Ideally we should have more precise control over the actual codec used, and we should be allowed to configure its parameters such as compression level, etc. The "default"/"best_compression" options should only be aliases to some predefined codecs and parameters that may change from release to release, but if we know we want a stable configuration, we should be able to choose "deflate" (or "zstd") and be sure that the codec doesn't change.
Steps to Reproduce
Download a sample dataset, for example the first 1M reviews of the Yelp dataset: https://www.kaggle.com/datasets/yelp-dataset/yelp-dataset
Index them in 2 indices,
yelp_deflate
on ES 8.15.3 andyelp_zstd
on ES 8.17.0, with the same mapping:Make a simple search query that returns a good amount of documents:
Run the query on each index multiple times (so that the indices are in the system's page cache) but with the request_cache turned off, and record the "took":
The results are as follows:
As for the storage, after force-merging the indices in a single segment, we get:
Logs (if relevant)
No response
The text was updated successfully, but these errors were encountered: