Cleanup repo sources, tests, Apply pylint. Update README.md#2
Cleanup repo sources, tests, Apply pylint. Update README.md#2gregthelaw merged 1 commit intomainfrom
Conversation
| ./test | ||
| python l3_dump.py /tmp/l3_test test | ||
| python l3_dump.py /tmp/l3_small_test test | ||
| @echo |
There was a problem hiding this comment.
Add blank lines between every new command run, so the chunks of output are more visible in stdout.
Also on L9 below, we run the Py script w/o args, just to be sure that the help/usage message is still coming out correctly.
| @@ -0,0 +1,51 @@ | |||
| # L3: The Lightweight Logging Library | |||
There was a problem hiding this comment.
Rewrote in md format, with minor inline edits and rewrites for better readability.
| * \version 0.1 | ||
| * \date 2023-12-24 | ||
| * | ||
| * \copyright Copyright (c) 2023 |
There was a problem hiding this comment.
Should the Copyright messages in diff files change to: 2023-2024?
That kind of annual update is a nightmare ... How does one manage that in other oss repos?
|
|
||
| /** | ||
| * L3 Log Structure definitions: | ||
| */ |
There was a problem hiding this comment.
Add small prologs to each struct describing what it stands for.
Please correct or add more descriptive text if you wish to see some.
| if (fd == -1) return -1; | ||
| if (fd == -1) { | ||
| return -1; | ||
| } |
There was a problem hiding this comment.
I strongly encourage and request that we should adhere to the practice of enclosing even single-line if(), while() bodies inside { }and conform to proper indentation on the next line.
I have applied this change to few files.
Long-term: We should consider standardizing on a clang-format format-file, run that in CI, so all new code comes out looking consistent.
| L3: Lightweight Logging Library, Version 0.1 | ||
| Date 2023-12-24 | ||
| Copyright (c) 2023-2024 | ||
| """ |
There was a problem hiding this comment.
Applied pylint to this file, and that's included in the Makefile, too.
Future changes have to conform otherwise builds will fail.
| rodata_offs = int(stdout.split('\n')[2].split()[0], 0) | ||
|
|
||
| # pylint: disable-next=line-too-long | ||
| with subprocess.Popen(["readelf", "-p", ".rodata", sys.argv[2]], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as p: |
There was a problem hiding this comment.
Rewrite here and on L17 above to enclose statement using with was suggested by pylint for reasons of correct resource mgmt.
Another benefit of running pylint.
| static uint64_t inline | ||
| timespec_to_ns(struct timespec *ts) | ||
| { | ||
| return ((ts->tv_sec * L3_NS_IN_SEC) + ts->tv_nsec); |
There was a problem hiding this comment.
Modularized into tiny helper fn.
|
|
||
| // Useful constants | ||
| #define L3_MILLION (1000 * 1000) | ||
| #define L3_NS_IN_SEC (1000 * 1000 * 1000) |
There was a problem hiding this comment.
Add mnemonics to recognize eye-blurring mind-numbing constants with series of 0s.
|
|
||
| int nMil = 300; | ||
| printf("\nExercise in-memory logging performance benchmarking: " | ||
| "%d Mil simple/fast log msgs\n", |
There was a problem hiding this comment.
Msg now reports workloads' #-of-inserts parameter.
|
|
||
| printf("simple: %" PRIu64 "ns\n", (nsec1 - nsec0) / n); | ||
| printf("%d Mil simple log msgs: %" PRIu64 "ns/msg\n", | ||
| nMil, (nsec1 - nsec0) / n); |
There was a problem hiding this comment.
Clarify the units of the metric reported. Mention that it's avg.
One day, we may want to track and report min / avg / max / std-dev metrics, for proper benchmarking results. Future.
This commit does code-cleanup for diff files in the core l3 package.
- Rewrite README as README.md. Update / correct description
- Makefile: Add blank lines for readability. Run `pylint` on
l3_dump.py . Invoke script to exercise help output.
- l3.h - Add code comments. Mark params as const where applicable.
- l3.c - Code tightening:
- Consistently enclose all single-line bodies in { } with indentation
- Replace constants with mnemonics; e.g. L3_DLADDR_NOT_FOUND_ERRNO
- Rename mytid() -> l3_mytid(), to namespace the lookup fn.
- l3_dump.py - Address all pylint errors (now runs in Make)
Add copyright notice to Py script.
- test.c - Various test cleanups. Add timespec_to_ns()
- Report units of throughput metric. Tag as 'avg'.
Tested on Ubuntu Linux-VM.
629f4dc to
aa3797c
Compare
gregthelaw
left a comment
There was a problem hiding this comment.
Excellent - thank you for these changes. All good!
This commit does code-cleanup for diff files in the core l3 package.
Rewrite README as README.md. Update / correct description
Makefile: Add blank lines for readability. Run
pylinton l3_dump.py . Invoke script to exercise help output.l3.h - Add code comments. Mark params as const where applicable.
l3.c - Code tightening: - Consistently enclose all single-line bodies in { } with indentation - Replace constants with mnemonics; e.g. L3_DLADDR_NOT_FOUND_ERRNO - Rename mytid() -> l3_mytid(), to namespace the lookup fn.
l3_dump.py - Address all pylint errors (now runs in Make) Add copyright notice to Py script.
test.c - Various test cleanups. Add timespec_to_ns()
Tested on Ubuntu Linux-VM.
Sample output from dev-test on my Ubuntu-VM: