Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@driusan
Copy link
Collaborator

@driusan driusan commented Apr 15, 2024

This adds support to LORIS for optionally compressing the response to the client if the Accept-Encoding header includes support for gzip using a new PSR-15 middleware. In this pull request the middleware is added for any data framework menu which uses the format=binary parameter and it used for the new data query tool results.

This can significantly improve the loading time of large datasets. For instance, when combined with PR#9195 on the UK biobank the size of the result downloaded from the candidate_list is reduced from 47.48MB to 7.45MB according to the Firefox dev tools and there are similar reductions in the transferred size for data query results with arbitrary queries.

@driusan
Copy link
Collaborator Author

driusan commented Apr 15, 2024

Sending as a draft because this is not intended to be merged until after the current release, but should be ready if anyone wants to look at or test it.

@driusan driusan force-pushed the CompressionMiddleware branch from 2b4dddb to a29ab69 Compare April 15, 2024 17:14
@driusan driusan marked this pull request as ready for review June 20, 2024 18:14
Copy link
Contributor

@maximemulder maximemulder left a comment

Choose a reason for hiding this comment

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

Works on my machine, reduced candidate_list request from 60kb to 10kb depending on the Accept-Encoding HTTP header.

I would prefer if non-doc type annotations are added to src/Http/GzipStream (unless they are automatically inherited, in which case my bad !), before merging but not blocking on that.

I did a quick search to see if there are existing libraries that do that for us but I did not find any, I am kind of baffled we have to handle this kind of details ourselves.

EDIT: Uh, I thought I was only reviewing, why was I assigned ? Assigning back to @driusan unless there's something I overlooked.

@maximemulder maximemulder added the Passed manual tests PR has been successfully tested by at least one peer label Oct 1, 2024
@maximemulder maximemulder assigned driusan and unassigned maximemulder Oct 1, 2024
@driusan
Copy link
Collaborator Author

driusan commented Oct 1, 2024

@maximemulder you were just assigned to review so that it doesn't show up as unassigned.

What do you mean by "I would prefer if non-doc type annotations are added to src/Http/GzipStream"? I can update the docs, but I'm not sure what you mean.

@maximemulder
Copy link
Contributor

maximemulder commented Oct 1, 2024

Oh, I mean writing :

function tell(): int
{ ... }

instead of

/**
 * @return int
 */
function tell()
{ ... }

but if you prefer the latter that's fine as well.

@driusan
Copy link
Collaborator Author

driusan commented Oct 1, 2024

I would also prefer that but the signature needs to match the PSR7 StreamInterface that it implements

@maximemulder
Copy link
Contributor

Oh okay, I did not take into account that the library could be untyped. If you're confident about your implementation of StreamInterface (since many methods are missing) then consider myself convinced.

@driusan driusan merged commit b938a05 into aces:main Oct 2, 2024
ZhichGaming pushed a commit to ZhichGaming/Loris that referenced this pull request Nov 25, 2024
This adds support to LORIS for optionally compressing the response to
the client if the `Accept-Encoding` header includes support for gzip
using a new PSR-15 middleware. In this pull request the middleware is
added for any data framework menu which uses the `format=binary`
parameter and it used for the new data query tool results.

This can significantly improve the loading time of large datasets. For
instance, when combined with PR#9195 on the UK biobank the size of the
result downloaded from the candidate_list is reduced from 47.48MB to
7.45MB according to the Firefox dev tools and there are similar
reductions in the transferred size for data query results with arbitrary
queries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Passed manual tests PR has been successfully tested by at least one peer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants