Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Records #49

Merged
merged 31 commits into from
Jun 7, 2023
Merged

Records #49

merged 31 commits into from
Jun 7, 2023

Conversation

pelletier
Copy link
Contributor

@pelletier pelletier commented Jun 2, 2023

  • get records <log>.
  • describe record <log>/<offset>.
  • describe record -hex to display hex version of strings
  • Why record times are 53 year old (sounds like they are offsets from epoch)?
  • Support -q.
  • Write tests once the format looks good.
  • Implement lookup.

Only on one segment. Segments iterator in the separate PR.


get records output example

(see the description edit history for previous attempts)

ubuntu ~/s/g/s/timecraft records$ go run . get records a64d2cce-4427-4114-995c-65075896a7a4
ID (LOG/OFFSET)                          SEGMENT  TIME     SIZE      SYSCALL
a64d2cce-4427-4114-995c-65075896a7a4/0   0        53y ago  40 B      RandomGet([uint8]) errno
a64d2cce-4427-4114-995c-65075896a7a4/1   0        53y ago  16 B      RandomGet([uint8]) errno
a64d2cce-4427-4114-995c-65075896a7a4/2   0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/3   0        53y ago  12 B      ArgsSizesGet() (int,int,errno)
a64d2cce-4427-4114-995c-65075896a7a4/4   0        53y ago  22 B      ArgsGet() ([string],errno)
a64d2cce-4427-4114-995c-65075896a7a4/5   0        53y ago  12 B      EnvironSizesGet() (int,int,errno)
a64d2cce-4427-4114-995c-65075896a7a4/6   0        53y ago  1.97 KiB  EnvironGet() ([string],errno)
a64d2cce-4427-4114-995c-65075896a7a4/7   0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/8   0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/9   0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/10  0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/11  0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/12  0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/13  0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/14  0        53y ago  16 B      FDPreStatGet(3) (prestat,errno)
a64d2cce-4427-4114-995c-65075896a7a4/15  0        53y ago  13 B      FDPreStatDirName(3) (string,errno)
a64d2cce-4427-4114-995c-65075896a7a4/16  0        53y ago  16 B      FDPreStatGet(4) (prestat,errno)
a64d2cce-4427-4114-995c-65075896a7a4/17  0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/18  0        53y ago  24 B      ClockTimeGet(clock,time) (time,errno)
a64d2cce-4427-4114-995c-65075896a7a4/19  0        53y ago  26 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/20  0        53y ago  322 B     FDRead(0,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/21  0        53y ago  42 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/22  0        53y ago  29 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/23  0        53y ago  37 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/24  0        53y ago  37 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/25  0        53y ago  35 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/26  0        53y ago  34 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/27  0        53y ago  30 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/28  0        53y ago  29 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/29  0        53y ago  43 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/30  0        53y ago  51 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/31  0        53y ago  68 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/32  0        53y ago  51 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/33  0        53y ago  51 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/34  0        53y ago  66 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/35  0        53y ago  31 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/36  0        53y ago  29 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/37  0        53y ago  51 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/38  0        53y ago  46 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/39  0        53y ago  58 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/40  0        53y ago  31 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/41  0        53y ago  50 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/42  0        53y ago  30 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/43  0        53y ago  16 B      FDRead(0,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/44  0        53y ago  25 B      FDWrite(1,[io]) (size,errno)
a64d2cce-4427-4114-995c-65075896a7a4/45  0        53y ago  8 B       ProcExit(ExitCode) errno

describe record output examples

ubuntu ~/s/g/s/timecraft records!$ go run . describe record a64d2cce-4427-4114-995c-65075896a7a4/20
Offset:  20
Segment: 0
Process: a64d2cce-4427-4114-995c-65075896a7a4
Time:    53y ago
Size:    322 B
---
Host function: FDRead
Parameters:
0	type: fd	value: 0
1	type: [io]	value:
    | 00000000  70 61 63 6b 61 67 65 20  6d 61 69 6e 0a 0a 69 6d  |package main..im|
    | 00000010  70 6f 72 74 20 28 0a 09  22 62 75 66 69 6f 22 0a  |port (.."bufio".|
    | 00000020  09 22 66 6d 74 22 0a 09  22 6f 73 22 0a 29 0a 0a  |."fmt".."os".)..|
    | 00000030  66 75 6e 63 20 6d 61 69  6e 28 29 20 7b 0a 09 66  |func main() {..f|
    | 00000040  6d 74 2e 50 72 69 6e 74  6c 6e 28 22 72 65 61 64  |mt.Println("read|
    | 00000050  79 22 29 0a 09 73 63 61  6e 6e 65 72 20 3a 3d 20  |y")..scanner := |
    | 00000060  62 75 66 69 6f 2e 4e 65  77 53 63 61 6e 6e 65 72  |bufio.NewScanner|
    | 00000070  28 6f 73 2e 53 74 64 69  6e 29 0a 09 66 6f 72 20  |(os.Stdin)..for |
    | 00000080  73 63 61 6e 6e 65 72 2e  53 63 61 6e 28 29 20 7b  |scanner.Scan() {|
    | 00000090  0a 09 09 78 20 3a 3d 20  73 63 61 6e 6e 65 72 2e  |...x := scanner.|
    | 000000a0  54 65 78 74 28 29 0a 09  09 66 6d 74 2e 50 72 69  |Text()...fmt.Pri|
    | 000000b0  6e 74 6c 6e 28 22 3d 3e  22 2c 20 78 2c 20 22 2d  |ntln("=>", x, "-|
    | 000000c0  3e 22 2c 20 6c 65 6e 28  78 29 29 0a 09 7d 0a 0a  |>", len(x))..}..|
    | 000000d0  09 65 72 72 20 3a 3d 20  73 63 61 6e 6e 65 72 2e  |.err := scanner.|
    | 000000e0  45 72 72 28 29 0a 09 69  66 20 65 72 72 20 21 3d  |Err()..if err !=|
    | 000000f0  20 6e 69 6c 20 7b 0a 09  09 66 6d 74 2e 50 72 69  | nil {...fmt.Pri|
    | 00000100  6e 74 6c 6e 28 22 65 72  72 6f 72 3a 22 2c 20 65  |ntln("error:", e|
    | 00000110  72 72 29 0a 09 7d 0a 09  66 6d 74 2e 50 72 69 6e  |rr)..}..fmt.Prin|
    | 00000120  74 6c 6e 28 22 64 6f 6e  65 22 29 0a 7d 0a        |tln("done").}.|
Results:
0	type: size	value: 302 (302 B)
1	type: errno	value: 0 (OK)

get.go Outdated Show resolved Hide resolved
get.go Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
internal/print/human/bytes.go Outdated Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
format/timecraft.go Outdated Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
internal/stream/stream.go Outdated Show resolved Hide resolved
@pelletier pelletier marked this pull request as ready for review June 6, 2023 21:57
@pelletier
Copy link
Contributor Author

@achille-roussel I think it's ready for review. I haven't made the change to NewLogReader to receive a manifest as we discussed. I'd rather make it in a separate PR.

Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

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

Loving it! ❤️

describe.go Outdated Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
internal/print/textprint/lines.go Outdated Show resolved Hide resolved
internal/timemachine/registry.go Outdated Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
get.go Show resolved Hide resolved
get.go Outdated Show resolved Hide resolved
@pelletier
Copy link
Contributor Author

@achille-roussel addressed the feedback. I brought back the stream.ErrCloser to simplify the registry.ListRecords implementation. Do you see any better way?

Copy link
Contributor

@achille-roussel achille-roussel left a comment

Choose a reason for hiding this comment

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

Ship it!

@pelletier pelletier merged commit 93701e9 into main Jun 7, 2023
3 checks passed
@pelletier pelletier deleted the records branch June 7, 2023 12:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants