Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [slightly ot]pack200 and gzip  (Read 2624 times)
0 Members and 1 Guest are viewing this topic.
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Posted 2004-10-11 03:21:10 »

I was thinking again (oh oh).

Y'know all those image formats, loading time, awt depedancies and stuff.

With 1.5 they introduced that new compression stuff for webstart... see here and details here.

I just toyed around with it... and yea it seems like you get a slightly better compression. It's actually sometimes even better than PNGs (yea PNGOUTed PNGs can be bigger than gziped TGAs).

"GZIP Compression
[...]
One can get the highest degree of compression using gzip to compress an uncompressed jar file vs. compressing a compressed jar file, the downside is that the file may be stored uncompressed on the target systems."

Downside huh? Well, you use jars with zero compression (store) and put that into a highly compressed gzip archive. If the archive (the zero compressed jar) gets stored on the client side in an uncompressed state (without beeing gzipped) loading times should be pretty short (yea you wast some mb on the hdd, but who cares?).

In theory this should allow the shortest loading times, because the physical distance of the files is as short as possible (because they aren't cluttered around the hdd - y'know fragmentation et all).

Well, we won't get around ogging. Heh. But it looks like a good trade off. It seems to be reasonable for images you need quickly (splash/loading) or for those bad to jpg/high contrast images like fonts or hand drawn cartoon images. They are quite often even a bit smaller than jpg Smiley

So far I can't tell if they get stored uncompressed (de-gzipped) or not. For testing that I would need to write quite a lot php.

Oh and lwjgl.jar, lwjgl.dll and lwjglaudio.dll are 255kb (zip [store]->gzip [max]) instead of 310kb (zip [max]). And you can even strip it down to 202kb *gasp* if you do something like this:

pack200 --modification-time=latest lwjgl-win-new.jar.pack.gz lwjgl-win32-0.92_s.jar

And if you use 7zip for gzipping it gets down to... 195kb Shocked

(Oh and sorry for the lack of structure... I wrote this and tested that stuff at the same time Wink)

弾幕 ☆ @mahonnaiseblog
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #1 - Posted 2004-10-12 10:57:45 »

Just for the fun of it I tried it with super elvis (I wanted some real world game related data Wink)

[btw/ot² the images.jar is ref-ed twice, Cas Tongue]

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
[compressed]

       347.077 alloy.jar
       120.654 gamecommerce.jar
       126.056 hallucinogenesis-code.jar
        74.513 hallucinogenesis-fonts.jar
        35.935 hallucinogenesis-game.jar
       772.686 hallucinogenesis-images.jar
     2.048.148 hallucinogenesis-sounds.jar
     1.605.498 hallucinogenesis-sprites.jar
         8.101 jogg-0.0.5.jar
        63.437 jorbis-0.0.12.jar
       267.898 lwjgl.jar
        85.310 lwjgl-windows.jar
        63.512 openal-windows.jar
       208.687 spgl.jar
---------------------------------------------------
     5.827.512 bytes


[stored jars->p200->gz]

       122.633 alloy.jar.pack.gz
        34.113 gamecommerce.jar.pack.gz
        43.176 hallucinogenesis-code.jar.pack.gz
        65.431 hallucinogenesis-fonts.jar.pack.gz
        33.563 hallucinogenesis-game.jar.pack.gz
       743.804 hallucinogenesis-images.jar.pack.gz
     2.022.725 hallucinogenesis-sounds.jar.pack.gz
     1.579.566 hallucinogenesis-sprites.jar.pack.gz
         4.501 jogg-0.0.5.jar.pack.gz
        28.369 jorbis-0.0.12.jar.pack.gz
        74.758 lwjgl.jar.pack.gz
        80.971 lwjgl-windows.jar.pack.gz
        61.171 openal-windows.jar.pack.gz
        55.256 spgl.jar.pack.gz
---------------------------------------------------
     4.950.037 bytes


[stored jars (client sided size)]

       626.028 alloy.jar
       239.690 gamecommerce.jar
       235.318 hallucinogenesis-code.jar
     1.028.851 hallucinogenesis-fonts.jar
       229.290 hallucinogenesis-game.jar
     2.113.141 hallucinogenesis-images.jar
     2.110.245 hallucinogenesis-sounds.jar
     9.878.503 hallucinogenesis-sprites.jar
        13.713 jogg-0.0.5.jar
       112.330 jorbis-0.0.12.jar
       641.848 lwjgl.jar
       214.795 lwjgl-windows.jar
       145.181 openal-windows.jar
       401.869 spgl.jar
---------------------------------------------------
    17.990.802 bytes


It's about 15% smaller (traveling through the net)... client sided quite the bloat (308%), but it should load faster this way.

Well, I think it's cool. Every 7th (or so) download is for free or to put it in other numbers... 202 downloads for one gb traffic instead of 171 downloads.

Oh and I think the thread should be moved over to OnLine Game Development Tongue

弾幕 ☆ @mahonnaiseblog
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #2 - Posted 2004-10-12 12:52:28 »

Thanks for moving Wink

So far I got a minimalistic example up and running (apache mod_rewrite plus some lines of php). Well, what's left is checking of the accepted encoding (it's a blind guess right now) and some logic.

I hope this stuff will work on my host, too Smiley

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #3 - Posted 2004-10-15 19:48:17 »

Dear diary... Tongue

It's done proper now, it works and my host supports it, too. Hooray! Grin

Will do some testing tomorrow... I really want to check it on all major platforms+vm combinations. I've also written a small test application (for testing the server) and a really simple thingy which just tells you which archive has been picked (just a frame with a label... "I was a .jar", "I was a .jar.gz" and "I was a .jar.pack.gz")... So basically everything is there for doing some quick tests to check if your host supports it and if you've setup everything correctly Smiley

弾幕 ☆ @mahonnaiseblog
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #4 - Posted 2004-10-18 13:11:10 »

http://www.kaioa.com/src/tmp/BounceDemo.jnlp

That's a small demo, which tells you which archive has been send to you. I forgot to use target/source 1.4 switches while compiling, which kinda voided the purpose of the demo. Well, that's fixed now Wink

So far it has been tested on a handfull of linux and win machines running either 1.4.x or 1.5.0. And it really works as intended. I also found out that webstart saves the "E-Tag", which I generated... so yea it won't download the archives again if it hasn't been updated (the etag itself is actually just the timestamp of the last modification plus the filesize in bytes).

弾幕 ☆ @mahonnaiseblog
Offline c_lilian

Senior Duke


Projects: 1


Java games will probably rock someday...


« Reply #5 - Posted 2006-01-10 17:19:52 »

Hi oNyx,

I'm facing the same problem now...  no Servlet support but I'd like to provide pack200 files... would you mind sharing your php code here ?

many thanks

Lilian

Offline c_lilian

Senior Duke


Projects: 1


Java games will probably rock someday...


« Reply #6 - Posted 2006-01-11 08:49:36 »

problem resolved with http://joust.kano.net/weblog/archive/2004/10/16/pack200-on-apache-web-server

But I'm still interested by your solution !

Lilian

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #7 - Posted 2006-01-11 09:09:17 »

I actually have 3 solutions.

The one I like most (the one I currently use) uses a redirection header.

.htaccess
1  
2  
3  
4  
5  
6  
7  
8  
9  
AddType application/x-java-jnlp-file .jnlp
AddType application/x-java-archive .jar
AddType application/x-java-archive .jar_gz
AddType application/x-java-archive .jar_pack_gz
AddEncoding pack200-gzip .jar_pack_gz
AddEncoding gzip .jar_gz
RewriteEngine On
RewriteBase   /jws
RewriteRule jar/(.*) jarbounce2.php?file=$1 [NE]


jarbounce2.php
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
<?php
if(!isset($_GET['file']))
{
   not_found();
}

$gzip_accepted=FALSE;
$pack_accepted=FALSE;

if(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'pack200-gzip')!==FALSE)
   $pack_accepted=TRUE;
if(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')!==FALSE)
   $gzip_accepted=TRUE;

if(file_exists('jars/'.$_GET['file'].'_pack_gz') AND $pack_accepted)
{
   bounce_off($_GET['file'].'_pack_gz');
}
elseif(file_exists('jars/'.$_GET['file'].'_gz') AND $gzip_accepted)
{
   bounce_off($_GET['file'].'_gz');
}
elseif(file_exists('jars/'.$_GET['file']))
{
   bounce_off($_GET['file']);
}
else
{
   not_found();
}

function bounce_off($filename)
{
   header('HTTP/1.1 301 Moved Permanently');
   header('Location: http://kaioa.com/jws/jars/'.$filename);
   die();
}

function not_found()
{
   //you could do something else here, like logging and/or redirecting
   //it to your usual 404 page
   header('HTTP/1.0 404 Not Found');
   die();
}
?>


Structure is like this:
/jws/.htaccess
/jws/jarbounce2.php
/jws/jars/foobar.jar
/jws/jars/foobar.jar_gz
/jws/jars/foobar.jar_pack_gz

In the jnlp I just refer to "jar/foobar.jar" (Note that its "jar" and not "jars").

Oh and dont forget to adjust that header location line.

弾幕 ☆ @mahonnaiseblog
Offline c_lilian

Senior Duke


Projects: 1


Java games will probably rock someday...


« Reply #8 - Posted 2006-01-11 09:20:48 »

thanks for sharing !

Lilian

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (20 views)
2014-10-25 15:46:29

Longarmx (53 views)
2014-10-17 03:59:02

Norakomi (47 views)
2014-10-16 15:22:06

Norakomi (35 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (70 views)
2014-10-14 00:39:48

TehJavaDev (69 views)
2014-10-14 00:35:47

TehJavaDev (61 views)
2014-10-14 00:32:37

BurntPizza (74 views)
2014-10-11 23:24:42

BurntPizza (47 views)
2014-10-11 23:10:45
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!