Git Product home page Git Product logo

chepa's Issues

failure of walker on folder/file names that contain control sequences

failing for control_sequences:
input

zig build
zig build inttest # warning: generates ca. 480MB test folders

The generated tmp.debug that should have basename contains f_, so the shell prints all knowledge.
output:

debug: file 'f_
'
error: NotDir
/home/misterspoon/dev/git/zig/zig/master/lib/std/os.zig:1341:24: 0x23606a in std.os.openZ (chepa)
            .NOTDIR => return error.NotDir,
                       ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/os.zig:4683:25: 0x23288a in std.os.realpathZ (chepa)
            else => |e| return e,
                        ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/os.zig:4668:5: 0x230952 in std.os.realpath (chepa)
    return realpathZ(&pathname_c, out_buffer);
    ^
/home/misterspoon/dev/git/zig/chepa/src/main.zig:179:36: 0x229f1d in main (chepa)
                const rl_sup_dir = try os.realpath(p_sup_dir, &tmp_buf);
                                   ^
The following command exited with error code 1 (expected 0):
cd /home/misterspoon/dev/git/zig/chepa && /home/misterspoon/dev/git/zig/chepa/zig-out/bin/chepa /home/misters
poon/dev/git/zig/chepa/test_folders
error: UnexpectedExitCode
/home/misterspoon/dev/git/zig/zig/master/lib/std/os.zig:2720:19: 0x2b5cc2 in std.os.readlinkZ (build)
        .INVAL => return error.NotLink,
                  ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/os.zig:2699:9: 0x2b6a12 in std.os.readlink (build)
        return readlinkZ(&file_path_c, out_buffer);
        ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/os.zig:2424:19: 0x29fb4b in std.os.mkdiratZ (build)
        .EXIST => return error.PathAlreadyExists,
                  ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/os.zig:2386:9: 0x29fa33 in std.os.mkdirat (build)
        return mkdiratZ(dir_fd, &sub_dir_path_c, mode);
        ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/fs.zig:1270:9: 0x29f926 in std.fs.Dir.makeDir (build)
        try os.mkdirat(self.fd, sub_path, default_new_dir_mode);
        ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/build/RunStep.zig:250:17: 0x2c6cf6 in std.build.RunStep.make
 (build)
                return error.UnexpectedExitCode;
                ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/build.zig:3261:9: 0x2a02ae in std.build.Step.make (build)
        try self.makeFn(self);
        ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/build.zig:505:9: 0x29f3fc in std.build.Builder.makeOneStep (
build)
        try s.make();
        ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/build.zig:499:17: 0x29f3a8 in std.build.Builder.makeOneStep
(build)
                return err;
                ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/build.zig:460:13: 0x291d71 in std.build.Builder.make (build)
            try self.makeOneStep(s);
            ^
/home/misterspoon/dev/git/zig/zig/master/lib/std/special/build_runner.zig:209:21: 0x288506 in main (build)
            else => return err,
                    ^

notes on upstream improvements to lib/std/x/net and lib/std/x/os

int shutdown(int s, int how); // s is socket descriptor
int how can be:
SHUT_RD or 0 Further receives are disallowed: recv
SHUT_WR or 1 Further sends are disallowed: send
SHUT_RDWR or 2 Further sends and receives are disallowed, both
Further receives are disallowed

std.x.net:
ipv4, ipv6 parser requires accurate length field, but this may not be always known or desirable,
ie for performance
=> we should define an unambiguous end symbol
==> check other implementations

  • missing max lenghts of ip and port for ipv4, ipv6

address:
format does use : as delimiter, but there is no end field for the port.
=> can not be parsed back

misc:
format/print + parse should support

  1. human inspection(debug), 2. output with padding(machine readable), 3. output with len field?
    ptr is u64 (8 byte)+ ptr.len (8 byet) => 16 byte (length of complete ip field as string is 15)

future: kernel abstraction testing strategy? kernel errno semantic strategies, ie machine-readable api stuff?

benchmark results against fd

[user@pc chepa]$ hyperfine './zig-out/bin/chepa perf_folders/ -c' 'fd -j1 "blabla" perf_folders/'
Benchmark 1: ./zig-out/bin/chepa perf_folders/ -c
Time (mean ± σ): 606.5 ms ± 16.5 ms [User: 279.6 ms, System: 312.3 ms]
Range (min … max): 591.7 ms … 649.9 ms 10 runs

Benchmark 2: fd -j1 "blabla" perf_folders/
Time (mean ± σ): 1.355 s ± 0.021 s [User: 0.508 s, System: 0.831 s]
Range (min … max): 1.324 s … 1.396 s 10 runs

Summary
'./zig-out/bin/chepa perf_folders/ -c' ran
2.23 ± 0.07 times faster than 'fd -j1 "blabla" perf_folders/'
[user@pc chepa]$ hyperfine './zig-out/bin/chepa perf_folders/' 'fd -j1 "blabla" perf_folders/'
Benchmark 1: ./zig-out/bin/chepa perf_folders/
Time (mean ± σ): 598.5 ms ± 5.0 ms [User: 278.3 ms, System: 307.1 ms]
Range (min … max): 592.0 ms … 606.0 ms 10 runs

Benchmark 2: fd -j1 "blabla" perf_folders/
Time (mean ± σ): 1.374 s ± 0.021 s [User: 0.543 s, System: 0.816 s]
Range (min … max): 1.346 s … 1.418 s 10 runs

Summary
'./zig-out/bin/chepa perf_folders/' ran
2.30 ± 0.04 times faster than 'fd -j1 "blabla" perf_folders/'

utf8 and general checklist

  1. formulate assumptions for linebreak characters on OSes
  2. create CI
  3. automate benchmarks in build.zig

Incomplete list to check for utf8

  • slow path as another cli flag for validating correct utf8, TODO: check zigstr examples etc
  • use std.unicode to interpret the bits as utf8 (for perf reasons)
  • use jump tag with state machine for parsing all paths
  • control characters, TODO: check utf8 cntrl chars
  • forbid whitespaces except the simple one
  • forbid prefixed dashes
  • forbid prefixed and postfixed whitespace
  • apply the utf8 checks to shell+file output with correct return codes/error handling.

Other perf improvements:

  • use buffered output (rather simple)
  • use buffer-backed allocator instead of allocating space (move stuff into library file)
  • comptime-construct string message offsets for printing (stage2)
  • optimize len fields (tedious)

zig build inttest fails due to inability to set expected_exit_code othern than 0 in RunStep.zig

Input

zig build inttest

output

The following command exited with error code 3 (expected 0):
cd /home/misterspoon/dev/git/zig/chepa && /home/misterspoon/dev/git/zig/chepa/zig-out/bin/chepa -outfile /home/misterspoon/dev/git/zig/chepa/zig-cache/tmp/inttest.txt /home/misterspoon/dev/git/zig/chepa/test_folders
error: UnexpectedExitCode

For comparison:

/home/user/dev/git/zig/chepa/zig-out/bin/chepa -outfile /home/user/dev/git/zig/chepa/zig-cache/tmp/inttest.txt /home/user/dev/git/zig/chepa/test_folders/
echo $?

succeds with

3

problem description of zig libstd for testing printed paths

build.zig: StdIoAction limits make, which executes *RunStep
requires comptime-selection of string compare function, which is currently not possible in libstd.

child_process.zig ExecResult we can not reuse dependency resolving
src/test.zig is not usable and neither has custom string matching

possible solutions:

  1. comptime-selection of user-provided function in build.zig for the stuff in make() of RunStep.zig
  2. work around with 1 level of indirection and more code
  3. own build runner
  4. own test runner (lib)

Long-term goal is to have parallelization and user-configuration of zig test_runner, which does step 2.
However, writing the test cases into test-blocks feels like an aweful hack and having an idea how to make it in build.zig is needed eventually anyway.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.