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

Gzip support, take 2 #2509

Merged
merged 9 commits into from
Jun 15, 2018
Merged

Gzip support, take 2 #2509

merged 9 commits into from
Jun 15, 2018

Conversation

ChrisJefferson
Copy link
Contributor

This is a cleaned up attempt at adding gzip support to GAP.

I recommend reading this commit by commit. The changes are:

First two commits: PR #2508, to disable a warning in the new code

3rd commit: Add zlib to configure (note, this should / will be improved).

4th/5th commit: This abstracts out most uses of read and write to use a SyRead and SyWrite function. At this point this seems fairly useless, but it will make adding gzip support a much smaller change.

6th commit: Actually add gzip

7th commit: Testing

@ChrisJefferson ChrisJefferson added the do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) label Jun 4, 2018
@ChrisJefferson
Copy link
Contributor Author

The 'DO NOT MERGE' is because I'm not happy with how I find zlib (that is, the user must have it installed, or else GAP won't build).

@fingolfin
Copy link
Member

Hmm, tests are failing (and issue labels are missing). Will wait with reviewing until this is resolved.

@codecov
Copy link

codecov bot commented Jun 5, 2018

Codecov Report

Merging #2509 into master will decrease coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2509      +/-   ##
==========================================
- Coverage   74.48%   74.48%   -0.01%     
==========================================
  Files         481      481              
  Lines      242733   242764      +31     
==========================================
+ Hits       180808   180824      +16     
- Misses      61925    61940      +15
Impacted Files Coverage Δ
src/saveload.c 65.78% <ø> (+0.34%) ⬆️
src/sysfiles.c 39.21% <ø> (-0.19%) ⬇️
src/streams.c 77.08% <ø> (-0.2%) ⬇️
src/system.c 74.37% <ø> (+0.28%) ⬆️
lib/streams.gd 87.5% <ø> (ø) ⬆️
src/hpc/threadapi.c 43.59% <0%> (+0.1%) ⬆️
... and 2 more

@fingolfin
Copy link
Member

Travis now fails, but AppVeyor still fails, because of missing zlib headers.

This of course would be fixed if zlib was bundled.

@ChrisJefferson
Copy link
Contributor Author

Some changes:

  1. I have forced the built-in zlib to always use the static build. This is because zlib isn't libtool-aware, so while GAP builds and links, when GAP is loaded the extern/build/zlib directory isn't in the library path and GAP either goes off and uses /lib/zlib1.so (which could be bad), or just fails to load.

  2. At the moment tests are failing because some packages (for example cvec) aren't picking up the zlib header location. However, the most recent round of configure changes seems to have fixed this (it works on cvec 2.6.1, released yesterday), so things should look much better in a couple of days.

@olexandr-konovalov olexandr-konovalov added the gapdays2018-spring Issues and PRs that arose at http://www.gapdays.de/gap-jupyter-days2018 label Jun 8, 2018
configure.ac Outdated
])
BUILD_ZLIB=yes
ZLIB_CPPFLAGS='-I${abs_builddir}/extern/install/zlib/include'
ZLIB_LDFLAGS='-L${abs_builddir}/extern/install/zlib/lib -l:libz.a'
Copy link
Member

Choose a reason for hiding this comment

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

-l:libz.a is not portable (in fact, I could find no documentation on it at all). But it's also not needed here: just change this to:

ZLIB_LDFLAGS='${abs_builddir}/extern/install/zlib/lib/libz.a'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://sourceware.org/binutils/docs/ld/Options.html gives the documentation for -l. I've used it previously as i don't like compiler's habits of "magically" choosing which file they want (dynamic or static), but I don't know what's "standard" linker behaviour, as opposed to GNU behaviour. I'm happy to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

configure.ac Outdated

# Use bundled zlib if requested
AS_IF([test x$BUILD_ZLIB = xyes],[
AS_IF([test x$CYGWIN = xyes],[
Copy link
Member

Choose a reason for hiding this comment

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

It seems a bit overkill to move the a huge section of configure.ac just to check for cygwin here, esp. as that only requires matching $host_os against *cygwin*...

Copy link
Contributor Author

@ChrisJefferson ChrisJefferson Jun 13, 2018

Choose a reason for hiding this comment

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

How do I do substring matching in configure scripts? Google isn't turning up anything useful. In shell I'd normally do [[ ... ]], but configure doesn't seem to like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I eventually managed to track down you are supposed to use AC_CASE of course....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@fingolfin
Copy link
Member

This still has a "DO NOT MERGE" label, and I am not sure what it's status is, so I'll refrain from a full review.

Just one more comment: GitHub's UI shows that commits ordered by date, which here does not fit their actual order. Perhaps consider doing a git rebase --ignore-date master next time you update it?

@ChrisJefferson ChrisJefferson added topic: kernel and removed do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) labels Jun 13, 2018
@ChrisJefferson
Copy link
Contributor Author

Now updated (hopefully)

@@ -84,15 +84,27 @@ typedef void sig_handler_t ( int );
#include <mach-o/dyld.h>
#endif

#include <zlib.h>


/* utility to check return value of 'write' */
ssize_t echoandcheck(int fid, const char *buf, size_t count) {
Copy link
Member

Choose a reason for hiding this comment

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

(I am not asking you to actually change this, but: wouldn't this have been one of the few cases were one really could have fixed the formatting of the whole function, given that you touch all of it except the first two and last two lines?)

src/sysfiles.c Outdated
syBuf[fid].isTTY = 0;
syBuf[fid].type = pipe_socket;
syBuf[fid].fp = fileno(syBuf[fid].pipehandle);
syBuf[fid].bufno = -1;
Copy link
Member

Choose a reason for hiding this comment

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

Weirdly, the indentation in this case is wrong by one space (but again, I am not really asking you to change this)

src/sysfiles.c Outdated
ret = gzwrite(syBuf[fid].gzfp, buf, count);
if (ret < 0)
ErrorQuit(
"Cannot write to compressed file, see 'LastSystemError();'\n",
Copy link
Member

Choose a reason for hiding this comment

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

Language nitpick: If I saw that message, I would think "ah, writing to compressed files is not supported"; but I think what really is meant here is that writing to a compressed file failed. Perhaps "Could not write" or "Failed to write" would be clearer (or maybe that's me as a non-native speaker just not getting it)?

(Again, not necessarily asking you to change this, just wondering)

src/sysfiles.c Outdated
else {
ret = write(syBuf[fid].echo, buf, count);
if (ret < 0)
ErrorQuit("Cannot write to file descriptor %d, see "
Copy link
Member

Choose a reason for hiding this comment

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

Same as above (but of course this message is old and predates this PR)

src/sysfiles.h Outdated
UInt ateof; /* set to 1 by any read operation that hits eof
/* gzfp is used if type == gzip_socket
** Stored as a void* to avoid including zlib.h */
void* gzfp;
Copy link
Member

Choose a reason for hiding this comment

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

Formatting: space before * (but we can also fix this afterwards -- indeed, with your PR merged, I think we are close to making syBuf private to sysfiles.h, then we could move this out of the header and into the .c file, and take care of formatting in this struct overall)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we could try moving this into sysfiles.h later. I did at some point run clang-format on this part, but it totally changed the whole struct and I wanted it to be clear what I'd added/changed.

@ChrisJefferson
Copy link
Contributor Author

@fingolfin , while many of reformatting comments are reasonable, I'd prefer to merge this and then make cleanups later, partly because it will be a pain to figure out which changes have to go in which of the existing commits.

@fingolfin fingolfin added the kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements label Jun 15, 2018
@fingolfin
Copy link
Member

I'd merge this now but there was a build failure, seemingly due to a network problem. I just restarted that job, if it passes, we can merge.

@fingolfin fingolfin merged commit 809347d into gap-system:master Jun 15, 2018
@ChrisJefferson ChrisJefferson deleted the gzip branch July 9, 2018 14:22
@fingolfin fingolfin added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gapdays2018-spring Issues and PRs that arose at http://www.gapdays.de/gap-jupyter-days2018 kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: added PRs introducing changes that have since been mentioned in the release notes topic: kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants