mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 00:02:28 +00:00
Improve redbean plus code size optimizations
This change turns symbol table compression back on using Puff, which noticeably reduces the size of programs like redbean and Python. The redbean web server receives some minor API additions for controlling things like SSL in addition to filling gaps in the documentation.
This commit is contained in:
parent
425ff5dff0
commit
13ee75150c
58 changed files with 2077 additions and 589 deletions
|
@ -40,6 +40,7 @@
|
|||
#include "libc/x/x.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zipos/zipos.internal.h"
|
||||
#include "third_party/zlib/puff.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
||||
STATIC_YOINK("zip_uri_support");
|
||||
|
@ -133,7 +134,7 @@ void Inflate(void) {
|
|||
stream.avail_out = bufsize_;
|
||||
stream.total_out = bufsize_;
|
||||
CHECK_EQ(Z_OK, inflateInit2(&stream, -MAX_WBITS));
|
||||
CHECK_NE(Z_BUF_ERROR, inflate(&stream, Z_NO_FLUSH));
|
||||
CHECK_EQ(Z_STREAM_END, inflate(&stream, Z_FINISH));
|
||||
CHECK_EQ(Z_OK, inflateEnd(&stream));
|
||||
}
|
||||
|
||||
|
@ -141,6 +142,12 @@ void Undeflate(void) {
|
|||
undeflate(buf_, uncompressedsize_, data_, compressedsize_, &ds_);
|
||||
}
|
||||
|
||||
void Puff(void) {
|
||||
size_t insize = compressedsize_;
|
||||
size_t outsize = uncompressedsize_;
|
||||
CHECK_EQ(0, puff(buf_, &outsize, data_, &insize));
|
||||
}
|
||||
|
||||
BENCH(undeflate, bench) {
|
||||
size_t cf, lf;
|
||||
struct Zipos *zipos;
|
||||
|
@ -155,6 +162,7 @@ BENCH(undeflate, bench) {
|
|||
uncompressedsize_ = ZIP_LFILE_UNCOMPRESSEDSIZE(zipos->map + lf);
|
||||
bufsize_ = ROUNDUP(uncompressedsize_, FRAMESIZE / 2);
|
||||
buf_ = gc(malloc(bufsize_));
|
||||
EZBENCH(donothing, Puff());
|
||||
EZBENCH(donothing, Inflate());
|
||||
EZBENCH(donothing, Undeflate());
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ TEST(gcctls, size) {
|
|||
size = GetFileSize(GetProgramExecutableName());
|
||||
if (IsTiny()) {
|
||||
ASSERT_LT(size, 200 * 1024);
|
||||
} else if (IsModeDbg()) {
|
||||
} else if (IsModeDbg() || IsAsan()) {
|
||||
ASSERT_LT(size, 4 * 1024 * 1024);
|
||||
} else {
|
||||
ASSERT_LT(size, 500 * 1024);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue