Skip to content

Commit

Permalink
[npm install] starting to look good!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Dec 17, 2021
1 parent c056093 commit 809c1e4
Show file tree
Hide file tree
Showing 17 changed files with 1,072 additions and 372 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@ misctools/fetch
src/deps/libiconv
src/deps/openssl
src/tests.zig
*.blob
*.blob
src/deps/s2n-tls
23 changes: 21 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
"request": "launch",
"name": "fetch debug #2",
"program": "${workspaceFolder}/misctools/fetch",
"args": ["https://youtube.com/", "--verbose"],
"args": ["https://registry.npmjs.org/react", "--verbose"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "fetch debug #3",
"program": "${workspaceFolder}/misctools/fetch",
"args": ["http://example.com/", "--verbose"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
Expand Down Expand Up @@ -340,7 +349,17 @@
"args": ["install"],
"cwd": "/tmp/wow-such-npm",
"env": {
"GOMAXPROCS": "1"
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "Install #2",
"program": "bun-debug",
"args": ["install"],
"cwd": "/tmp/wow-such-npm2",
"env": {
},
"console": "internalConsole"
},
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ fetch:
src/deps/libarchive.a \
src/deps/libcrypto.a \
src/deps/libssl.a \
src/deps/picohttpparser.o \
$(LIBCRYPTO_STATIC_LIB)
src/deps/picohttpparser.o

fetch-debug:
cd misctools; $(ZIG) build-obj ./fetch.zig -fcompiler-rt -lc --main-pkg-path ../ $(BORINGSSL_PACKAGE) --pkg-begin io ../$(IO_FILE) --pkg-end
Expand All @@ -329,8 +328,8 @@ fetch-debug:
src/deps/libarchive.a \
src/deps/libcrypto.a \
src/deps/libssl.a \
src/deps/picohttpparser.o \
$(LIBCRYPTO_STATIC_LIB)
src/deps/picohttpparser.o



httpbench-debug:
Expand Down
35 changes: 19 additions & 16 deletions misctools/fetch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,25 @@ pub fn main() anyerror!void {

try NetworkThread.init();

var async_http = try default_allocator.create(HTTP.AsyncHTTP);
async_http.* = try HTTP.AsyncHTTP.init(
default_allocator,
args.method,
args.url,
args.headers,
args.headers_buf,
response_body_string,
request_body_string,

0,
);
async_http.client.verbose = args.verbose;
async_http.verbose = args.verbose;
async_http.channel = channel;
async_http.schedule(default_allocator);
var ctx = try default_allocator.create(HTTP.HTTPChannelContext);
ctx.* = .{
.channel = channel,
.http = try HTTP.AsyncHTTP.init(
default_allocator,
args.method,
args.url,
args.headers,
args.headers_buf,
response_body_string,
request_body_string,

0,
),
};
ctx.http.callback = HTTP.HTTPChannelContext.callback;
ctx.http.schedule(default_allocator);
ctx.http.client.verbose = args.verbose;
ctx.http.verbose = args.verbose;

while (true) {
while (channel.tryReadItem() catch null) |http| {
Expand Down
60 changes: 40 additions & 20 deletions misctools/http_bench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -190,26 +190,36 @@ pub fn main() anyerror!void {

try NetworkThread.init();

const Group = struct {
response_body: MutableString = undefined,
request_body: MutableString = undefined,
context: HTTP.HTTPChannelContext = undefined,
};
var groups = try default_allocator.alloc(Group, args.count);
var i: usize = 0;
while (i < args.count) : (i += 1) {
var response_body = try default_allocator.create(MutableString);
groups[i] = Group{};
var response_body = &groups[i].response_body;
response_body.* = try MutableString.init(default_allocator, 1024);
var request_body = try default_allocator.create(MutableString);
var request_body = &groups[i].request_body;
request_body.* = try MutableString.init(default_allocator, 0);

var async_http = try default_allocator.create(HTTP.AsyncHTTP);
async_http.* = try HTTP.AsyncHTTP.init(
default_allocator,
args.method,
args.url,
args.headers,
args.headers_buf,
request_body,
response_body,
args.timeout,
);
async_http.channel = channel;
async_http.schedule(default_allocator);
var ctx = &groups[i].context;
ctx.* = .{
.channel = channel,
.http = try HTTP.AsyncHTTP.init(
default_allocator,
args.method,
args.url,
args.headers,
args.headers_buf,
request_body,
response_body,
args.timeout,
),
};
ctx.http.callback = HTTP.HTTPChannelContext.callback;
ctx.http.schedule(default_allocator);
}

var read_count: usize = 0;
Expand Down Expand Up @@ -242,11 +252,21 @@ pub fn main() anyerror!void {
},
}

Output.prettyError(" <d>{s}<r><d> - {s}<r> <d>({d} bytes)<r>\n", .{
@tagName(http.client.method),
http.client.url.href,
http.response_buffer.list.items.len,
});
if (http.gzip_elapsed > 0) {
Output.prettyError(" <d>{s}<r><d> - {s}<r> <d>({d} bytes, ", .{
@tagName(http.client.method),
http.client.url.href,
http.response_buffer.list.items.len,
});
Output.printElapsed(@floatCast(f64, @intToFloat(f128, http.gzip_elapsed) / std.time.ns_per_ms));
Output.prettyError("<d> gzip)<r>\n", .{});
} else {
Output.prettyError(" <d>{s}<r><d> - {s}<r> <d>({d} bytes)<r>\n", .{
@tagName(http.client.method),
http.client.url.href,
http.response_buffer.list.items.len,
});
}
} else if (http.err) |err| {
fail_count += 1;
Output.printError(" err: {s}\n", .{@errorName(err)});
Expand Down
4 changes: 2 additions & 2 deletions src/deps/boringssl.translated.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18825,8 +18825,8 @@ pub const SSL_CTX = opaque {

pub inline fn setCustomVerify(this: *SSL_CTX, cb: ?VerifyCallback) void {
SSL_CTX_set_custom_verify(this, 0, cb);
SSL_CTX_set_custom_verify(this, 1, cb);
SSL_CTX_set_custom_verify(this, 2, cb);
// SSL_CTX_set_custom_verify(this, 1, cb);
// SSL_CTX_set_custom_verify(this, 2, cb);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/fallback.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2bbe5942da63d2ba
796022f759787f0a
Loading

0 comments on commit 809c1e4

Please sign in to comment.