ocaml 4.01.0 → 4.02.1, binary size became larger - size

On Ubuntu 14.04, 32 bit:
➥ cat test.ml
let () = print_endline "hello";
➥ opam switch list | grep " C "
4.01.0 C 4.01.0 Official 4.01.0 release
➥ ocamlopt test.ml
➥ ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 13:29 a.out
➥ opam switch 4.02.0
➥ eval `opam config env`
➥ ocamlopt test.ml
➥ ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171122 Oct. 30 13:30 a.out
➥ opam switch 4.02.1
➥ eval `opam config env`
➥ ocamlopt test.ml
➥ ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 14:08 a.out
Executable size became bigger and bigger: 158569 → 171122 → 171196.
In a more complex applications I get an even greater increase in the size of the file.
Any ideas how to fix?
Update #1:
Tried strip:
➥ strip -V | head -n 1
GNU strip (GNU Binutils for Ubuntu) 2.24
➥ ls -l
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 15:22 a.4.01.0.out
-rwxrwxr-x 1 shorrty shorrty 117368 Oct. 30 15:26 a.4.01.0.out.stripped
-rwxrwxr-x 1 shorrty shorrty 171122 Oct. 30 15:03 a.4.02.0.out
-rwxrwxr-x 1 shorrty shorrty 127580 Oct. 30 15:26 a.4.02.0.out.stripped
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 15:21 a.4.02.1.out
-rwxrwxr-x 1 shorrty shorrty 127612 Oct. 30 15:26 a.4.02.1.out.stripped
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 15:21 a.out
It continues to grow: 117368 → 127580 → 127612
Update #2:
Tried option -compact, didn't work:
➥ opam switch 4.01.0 && eval `opam config env`
➥ ocamlopt test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:02 a.out
➥ ocamlopt -compact test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:03 a.out
➥ opam switch 4.02.1 && eval `opam config env`
➥ ocamlopt test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:05 a.out
➥ ocamlopt -compact test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:05 a.out
Tried option -inline, didn't work too:
➥ opam switch 4.01.0 && eval `opam config env`
➥ ocamlopt -inline 0 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:07 a.out
➥ ocamlopt -inline 1 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 158569 Oct. 30 22:07 a.out
➥ opam switch 4.02.1 && eval `opam config env`
➥ ocamlopt -inline 0 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:08 a.out
➥ ocamlopt -inline 1 test.ml && ls -l a.out
-rwxrwxr-x 1 shorrty shorrty 171196 Oct. 30 22:09 a.out

Your code didn't change, but it calls the pervasives module which changed between 4.01 and 4.02.
Notably, the part about formats was changed to use GADT-based formats instead of strings.
This notably made to_string, of_string and concatenation (quite) heavier.
See this discussion for more details.

Related

why am I get negative compression ratio for a gz file

I found an interesting thing about a gz file. The compression ration is negative.
[root#pridns named]# ll dns-query.log-2022083103*
-rw-r--r-- 1 named named 1.2G Aug 31 03:10 dns-query.log-2022083103.gz
[root#pridns named]#
[root#pridns named]# gzip -l dns-query.log-2022083103.gz
compressed uncompressed ratio uncompressed_name
1187103824 679547787 -74.7% dns-query.log-2022083103
[root#pridns named]#
[root#pridns named]# python -c "print((679547787-1187103824)/679547787.0)"
-0.7469026413
[root#pridns named]#
[root#pridns named]# gunzip -c dns-query.log-2022083103.gz > dns-query.log-2022083103
[root#pridns named]#
[root#pridns named]# ll dns-query.log-2022083103*
-rw-r--r-- 1 root root 8.7G Sep 16 11:06 dns-query.log-2022083103
-rw-r--r-- 1 named named 1.2G Aug 31 03:10 dns-query.log-2022083103.gz
[root#pridns named]#
[root#pridns named]# ls -l dns-query.log-2022083103*
-rw-r--r-- 1 root root 9269482379 Sep 16 11:06 dns-query.log-2022083103
-rw-r--r-- 1 named named 1187103824 Aug 31 03:10 dns-query.log-2022083103.gz
[root#pridns named]#
[root#pridns named]# python -c "print((9269482379-1187103824)/9269482379.0)"
0.871934184082
[root#pridns named]# gzip --version
gzip 1.5
Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
Written by Jean-loup Gailly.
[root#pridns named]#
The correct compression ratio should be 87.2%.
I also tried to test another file, the compression ratio is correct.
[root#pridns named]# gzip -l dns-security.log-2022083103.gz
compressed uncompressed ratio uncompressed_name
131503235 1275215408 89.7% dns-security.log-2022083103
[root#pridns named]# zcat dns-security.log-2022083103.gz > dns-security.log-2022083103
[root#pridns named]# ls -l dns-security.log-2022083103*
-rw-r--r-- 1 root root 1275215408 Sep 16 11:31 dns-security.log-2022083103
-rw-r--r-- 1 named named 131503235 Aug 31 03:10 dns-security.log-2022083103.gz
[root#pridns named]# python -c "print((1275215408-131503235)/1275215408.0)"
0.896877630105
[root#pridns named]#
The comments of #pmqs are correct, from the spec on https://www.rfc-editor.org/rfc/rfc1952, the original file size is just stored as 4 bytes. 9269482379 = 0x22881138B, the high bits are cropped, so the stored size is 0x2881138B = 679,547,787.
2.3.1. Member header and trailer
...
ISIZE (Input SIZE)
This contains the size of the original (uncompressed) input
data modulo 2^32.
...

ln not always working over SSH

I am making a deployment script using GitLab's CD. I've got a script:
- ssh USER#HOST "cd domains/$DOMAIN/ && mkdir build-$CI_JOB_ID"
- rsync -ar --port=22 * USER#HOST :domains/$DOMAIN/build-$CI_JOB_ID
- ssh USER#HOST "cd domains/$DOMAIN/ && ln -sfv build-$CI_JOB_ID/public public_html && ls -la"
- ssh USER#HOST "cd domains/$DOMAIN/ && ls | grep '^build\-.*$' | grep -Ev '^build-$CI_JOB_ID$' | xargs rm -rf"
everything works fine but not ln command. It works only 50% of the time. Here are logs from ` jobs runnning one after another.
Job 1 with $CI_JOB_ID = 76337215 worked properly. Link is correct.
$ ssh USER#HOST "cd domains/$DOMAIN/ && ln -sfv build-$CI_JOB_ID/public public_html && ls -la"
public_html -> build-76337215/public
total 20
drwx--x--x 5 USER 1000 7 Jun 20 22:15 .
drwx--x--x 23 USER 1000 23 Jun 19 16:34 ..
-rw-r--r-- 1 USER 1000 39 Jun 17 22:12 .htaccess
drwxr-xr-x 12 USER 1000 20 Jun 20 22:07 build-76335972
drwxr-xr-x 12 USER 1000 20 Jun 20 22:14 build-76337215
drwxr-xr-x 2 USER 1000 4 Jun 20 11:48 logs
lrwxr-xr-x 1 USER 1000 21 Jun 20 22:15 public_html -> build-76337215/public
Job 2 with $CI_JOB_ID = 76339729 did not work. Link is still to old 76337215 from Job 1.
$ ssh USER#HOST "cd domains/$DOMAIN/ && ln -sfv build-$CI_JOB_ID/public public_html && ls -la"
public_html/public -> build-76339729/public
total 20
drwx--x--x 5 USER 1000 7 Jun 20 22:28 .
drwx--x--x 23 USER 1000 23 Jun 19 16:34 ..
-rw-r--r-- 1 USER 1000 39 Jun 17 22:12 .htaccess
drwxr-xr-x 12 USER 1000 20 Jun 20 22:14 build-76337215
drwxr-xr-x 12 USER 1000 20 Jun 20 22:28 build-76339729
drwxr-xr-x 2 USER 1000 4 Jun 20 11:48 logs
lrwxr-xr-x 1 USER 1000 21 Jun 20 22:15 public_html -> build-76337215/public
What I am doing wrong? Why it is not working 100% of the time?
The problem is that if public_html already exists and is a directory (or a symlink to a directory), then your ln command creates a new link in that directory, rather than replacing public_html.
Use the -T option to avoid this:
ln -sfTv build-$CI_JOB_ID/public public_html
alternately, you can use the -n option to not dereference a link
ln -sfnv build-$CI_JOB_ID/public public_html
this will replace public_html if it is a symlink and create the symlink in the subdirectory if it is a real directory (-T would give an error in the latter case).

maxminddb module for apache 2.4 on ubuntu error: The MaxMind DB file contains invalid metadata

here is my system information:
$ apachectl -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2016-07-14T12:32:26
$ cat /etc/*release* | grep -i dist
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.1 LTS"
$ uname -r
4.4.0-57-generic
i wish to install mod_maxminddb. i installed geoipupdate as a prerequisites and configured it to include not only geolite database, but either commercial one (using this)
$ ls -l /etc/GeoIP.conf
-rw-r--r-- 1 root root 818 Dec 24 18:29 /etc/GeoIP.conf
$ ls -l /usr/share/GeoIP/
total 0
$ geoipupdate
$ ls -l /usr/share/GeoIP/
total 187444
-rw-r--r-- 1 root root 112192399 Dec 24 18:46 GeoIP2-City.mmdb
-rw-r--r-- 1 root root 3012279 Dec 24 18:46 GeoIP2-Country.mmdb
-rw-r--r-- 1 root root 47721533 Dec 24 18:46 GeoIPCity.dat
-rw-r--r-- 1 root root 1699494 Dec 24 18:45 GeoIP.dat
-rw-r--r-- 1 root root 4189407 Dec 24 18:45 GeoIPISP.dat
-rw-r--r-- 1 root root 4299547 Dec 24 18:45 GeoLiteASNum.dat
-rw-r--r-- 1 root root 17760694 Dec 24 18:45 GeoLiteCity.dat
-rw-r--r-- 1 root root 1054583 Dec 24 18:45 GeoLiteCountry.dat
then complied and installed the mod_maxminddb, and when apache is configured to use the commercial databases, the following error is thrown
$ apachectl -M
AH00526: Syntax error on line 12 of /etc/apache2/mods-enabled/maxminddb.conf:
MaxMindDBFile: Failed to open /usr/share/GeoIP/GeoIPCity.dat: The MaxMind DB file contains invalid metadata
but that is not the case when apache is configured to use the geolite databases.
any ideas?
You didn't include your Apache config, but you appear to be trying to use mod_maxminddb with GeoIPCity.dat (GeoIP Legacy). It only works with GeoIP2. Adjust line 12 of maxminddb.conf to use GeoIP2-City.mmdb instead.

Mercurial pull/checkout results in broken symbolic links [duplicate]

Is there some equivalent in Mercurial to NIX soft- or hard- links to directories or files.
Basically that a file (or directory) is linked to a file "somewhere else" and follows the version of that location (Unlike a regular branch I think, where one would have to merge)
Mercurial versions soft links that are internal to the repository just great. It'll detect them, record them, and create them for you. Is there a specific use case you're looking for? The closest thing to an link that reaches outside the repository is a subrepo, which is a pointer to a specific version of another repo.
Symlinks work
(df)Ry4ans-MacBook-Air:~ ry4an$ hg init olav
(df)Ry4ans-MacBook-Air:~ ry4an$ cd olav/
(df)Ry4ans-MacBook-Air:olav ry4an$ echo this > target
(df)Ry4ans-MacBook-Air:olav ry4an$ ln -s target link
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
total 16
lrwxr-xr-x 1 ry4an staff 6B Feb 16 19:25 link# -> target
-rw-r--r-- 1 ry4an staff 5B Feb 16 19:25 target
(df)Ry4ans-MacBook-Air:olav ry4an$ hg commit -A -m "link and its target"
adding link
adding target
(df)Ry4ans-MacBook-Air:olav ry4an$ hg log -p
changeset: 0:42a41a431661
tag: tip
user: Ry4an Brase <ry4an-hg#ry4an.org>
date: Sat Feb 16 19:26:17 2013 -0500
summary: link and its target
diff -r 000000000000 -r 42a41a431661 link
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/link Sat Feb 16 19:26:17 2013 -0500
## -0,0 +1,1 ##
+target
\ No newline at end of file
diff -r 000000000000 -r 42a41a431661 target
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/target Sat Feb 16 19:26:17 2013 -0500
## -0,0 +1,1 ##
+this
(df)Ry4ans-MacBook-Air:olav ry4an$ hg update null
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
(df)Ry4ans-MacBook-Air:olav ry4an$ hg update tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
(df)Ry4ans-MacBook-Air:olav ry4an$ ls -l
total 16
lrwxr-xr-x 1 ry4an staff 6B Feb 16 19:26 link# -> target
-rw-r--r-- 1 ry4an staff 5B Feb 16 19:26 target
But hardlinks don't
$hg commit -Am "hardlinks target"
adding link
adding target
$hg log -p
changeset: 0:ec9407634133
tag: tip
user: Chris Wesseling <chris.wesseling#cwi.nl>
date: Wed Mar 13 23:14:44 2013 +0100
summary: hardlinks target
diff -r 000000000000 -r ec9407634133 link
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/link Wed Mar 13 23:14:44 2013 +0100
## -0,0 +1,1 ##
+foo
diff -r 000000000000 -r ec9407634133 target
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/target Wed Mar 13 23:14:44 2013 +0100
## -0,0 +1,1 ##
+foo
$ls -lin
total 8
276702 -rw-r--r-- 2 1204653 5900 4 13 mrt 23:14 link
276702 -rw-r--r-- 2 1204653 5900 4 13 mrt 23:14 target
$hg update null
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$hg update tip
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ls -lin
total 8
276719 -rw-r--r-- 1 1204653 5900 4 13 mrt 23:15 link
276721 -rw-r--r-- 1 1204653 5900 4 13 mrt 23:15 target
Path auditing on *nix
On *nix systems, hg Mercurial audits symbolic links ("symlinks") for referred path security.
For example, absolute and empty paths are considered unsafe and will therefore not be added to the repository.
Mercurial developers have not documented this feature. However, the source code contains a comment with a somewhat vague explanation:
class pathauditor(object):
'''ensure that a filesystem path contains no banned components.
the following properties of a path are checked:
- ends with a directory separator
- under top-level .hg
- starts at the root of a windows drive
- contains ".."
- traverses a symlink (e.g. a/symlink_here/b)
- inside a nested repository (a callback can be used to approve
some nested repositories, e.g., subrepositories)
'''
On Windows, symbolic links are not supported for various reasons, see:
https://www.mercurial-scm.org/bts/issue1825
https://www.mercurial-scm.org/bts/issue2579

ipython works wrongs wrong with awk?

Dear all! I find a question with ipython.
When I input
!ls -l | awk '{print $$1}'
It gives me:
drwxr-xr-x 2 ckivip ckivip 4096 Oct 11 20:38 Desktop
drwxr-xr-x 6 ckivip ckivip 4096 Oct 11 22:57 Documents
drwxrwxr-x 3 ckivip ckivip 4096 Oct 11 12:53 Downloads
drwxr-xr-x 6 ckivip ckivip 4096 Sep 29 18:22 Epigenetics
drwxr-xr-x 2 ckivip ckivip 4096 Sep 20 14:59 Music
drwxr-xr-x 23 ckivip ckivip 4096 Oct 10 11:02 Pictures
drwxr-xr-x 8 ckivip ckivip 4096 Sep 20 15:21 Project
drwx------ 5 ckivip ckivip 4096 Sep 25 21:31 R
drwxr-xr-x 5 ckivip ckivip 4096 Oct 9 19:23 Share
However, when I input
!ls -l | awk '{print $1}'
It gives me:
drwxr-xr-x
drwxr-xr-x
drwxrwxr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwx------
It's so annoying about the "$" symbol. And the most ugly thing is that I also can't transport the variables in python to shell using '$' when I use 'awk' function. How can I deal with it?
I'm not familiar with ipython but to address the part about passing the values of shell variables to awk: you do that with 'awk -v variable=value', so if you have a shell variable "$1" that contains the value "3" and you want awk to print the 3rd field of your input based on that, then the syntax is:
awk -v f="$1" '{ print $f }'
so in the above you could try:
!ls -l | awk -v f="$1" '{print $f}'
or if doubling the shell "$"s is required:
!ls -l | awk -v f="$$1" '{print $f}'
Hope that helps.