Skip to content

Use different library for mime on windows #600

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

Merged
merged 3 commits into from
Feb 14, 2020

Conversation

Zexbe
Copy link
Contributor

@Zexbe Zexbe commented Feb 9, 2020

Windows can't build with magic, so this gives it an alternative crate to use.
While adding unit tests, and checking what magic returned, I found a few mimes it was returning incorrectly, and have also corrected those.

@Zexbe Zexbe requested a review from jyn514 February 9, 2020 03:07
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

Last couple nits and then looks good to merge.

@jyn514 jyn514 merged commit 5618f17 into rust-lang:master Feb 14, 2020
jyn514 added a commit to jyn514/docs.rs that referenced this pull request Mar 28, 2020
This uses the Rust tree_magic package instead.

Most work was already done in
rust-lang#600.
This just sets tree_magic to build unconditionally instead of always on
Windows.

This improves the memory usage of docs.rs by over a factor of 5 when
uploading files in some cases. This can be tested locally like so:

Run minio in the background:
```
docker run -p 9000:9000 -e MINIO_ACCESS_KEY=password -e MINIO_SECRET_KEY=password minio/minio server /data
```

Navigate to localhost:9000/ and set both the access key and secret key
to 'password'. Add a new bucket called `rust-docs-rs`.

Now in another terminal, run docs.rs. This assumes you already have the
CRATESFYI_DATABASE_URL set up locally as described in
[developing without docker-compose](https://forge.rust-lang.org/docs-rs/no-docker-compose.html):

```
 # set up a fairly large file
mkdir -p ignored/tmp
yes | head -n $((1024 * 1024 * 50)) > ignored/tmp/100MB

git checkout master
cargo build --release
RUST_LOG=cratesfyi,info S3_ENDPOINT=http://localhost:9000 AWS_ACCESS_KEY_ID=password AWS_SECRET_ACCESS_KEY=password valgrind --tool=massif --massif-out-file=libmagic.massif.out target/release/cratesfyi database add-directory ignored/tmp/
 # this will show ~1.5 GB used, depending on your system
ms_print libmagic.massif.out | less

 # now try without libmagic
git checkout druid
cargo build --release
RUST_LOG=cratesfyi,info S3_ENDPOINT=http://localhost:9000 AWS_ACCESS_KEY_ID=password AWS_SECRET_ACCESS_KEY=password valgrind --tool=massif --massif-out-file=no_libmagic.massif.out target/release/cratesfyi database add-directory ignored/tmp/
 # this will show ~250 MB used, depending on your system
ms_print no_libmagic.massif.out | less
```
jyn514 added a commit that referenced this pull request Mar 28, 2020
This uses the Rust tree_magic package instead.

Most work was already done in
#600.
This just sets tree_magic to build unconditionally instead of always on
Windows.

This improves the memory usage of docs.rs by over a factor of 5 when
uploading files in some cases. This can be tested locally like so:

Run minio in the background:
```
docker run -p 9000:9000 -e MINIO_ACCESS_KEY=password -e MINIO_SECRET_KEY=password minio/minio server /data
```

Navigate to localhost:9000/ and set both the access key and secret key
to 'password'. Add a new bucket called `rust-docs-rs`.

Now in another terminal, run docs.rs. This assumes you already have the
CRATESFYI_DATABASE_URL set up locally as described in
[developing without docker-compose](https://forge.rust-lang.org/docs-rs/no-docker-compose.html):

```
 # set up a fairly large file
mkdir -p ignored/tmp
yes | head -n $((1024 * 1024 * 50)) > ignored/tmp/100MB

git checkout master
cargo build --release
RUST_LOG=cratesfyi,info S3_ENDPOINT=http://localhost:9000 AWS_ACCESS_KEY_ID=password AWS_SECRET_ACCESS_KEY=password valgrind --tool=massif --massif-out-file=libmagic.massif.out target/release/cratesfyi database add-directory ignored/tmp/
 # this will show ~1.5 GB used, depending on your system
ms_print libmagic.massif.out | less

 # now try without libmagic
git checkout druid
cargo build --release
RUST_LOG=cratesfyi,info S3_ENDPOINT=http://localhost:9000 AWS_ACCESS_KEY_ID=password AWS_SECRET_ACCESS_KEY=password valgrind --tool=massif --massif-out-file=no_libmagic.massif.out target/release/cratesfyi database add-directory ignored/tmp/
 # this will show ~250 MB used, depending on your system
ms_print no_libmagic.massif.out | less
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants