Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for all CLP FFI functionality and refactor existing code: #3

Merged
merged 27 commits into from
May 10, 2024

Conversation

davidlion
Copy link
Member

@davidlion davidlion commented Apr 10, 2024

  • Add CLP encoding/decoding functionalities
  • Add CLP IR wildcard query support
  • Add basic GitHub templates and workflows
  • Rewrite CLP IR serialization/deserialization functionalities to match the latest CLP glossary, and simplify resource management
  • Add reader/writer interfaces for CLP IR
  • Update formatting and lining tooling
  • Switch to use static library

Description

  • all CLP encoding/decoding/searching FFI functionality
  • simplify resource management and control flow
    • Go code will need to call Close() functions to avoid memory leaks, but code is much easier to understand and less error prone
  • switch to static library
  • rewrite/add documentation for all user-facing code
  • rewrite terminology to match new CLP glossary
  • update formatting + linting tooling
  • github templates + workflows

Validation performed

  • Old/existing unit tests remade and passing.
  • Added new unit tests.

Note, this is the same as #2 but from the beta branch to de-duplicate branches.

- Add all clp-ffi functions
- Add reader and writer
- Add unit tests
- Add formatting and linting
- Overhaul doc strings and terminology
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Add the first batch of comments on cpp decoder/deserializer implementations

cpp/src/ffi_go/ir/LogTypes.hpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/LogTypes.hpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/LogTypes.hpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/LogTypes.hpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/LogTypes.hpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/deserializer.h Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/deserializer.h Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/deserializer.h Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/deserializer.cpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/deserializer.cpp Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Headers

cpp/src/ffi_go/ir/decoder.h Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Comments about the workflow

.github/workflows/build.yml Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Comments on the README

README.rst Outdated Show resolved Hide resolved
README.rst Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Add comments on cpp implementations of encoders and serializers

cpp/.clang-format Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/decoder.cpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/decoder.cpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/encoder.h Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/encoder.h Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/serializer.h Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/serializer.cpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/serializer.cpp Show resolved Hide resolved
cpp/src/ffi_go/ir/serializer.cpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/serializer.h Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Comments on the wildcard query C++ implementations.

cpp/src/ffi_go/search/wildcard_query.h Outdated Show resolved Hide resolved
cpp/src/ffi_go/search/wildcard_query.cpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/search/wildcard_query.cpp Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Comments on ffi/ffi.go. All about the doc strings.

ffi/ffi.go Outdated Show resolved Hide resolved
ffi/ffi.go Outdated Show resolved Hide resolved
ffi/ffi.go Outdated Show resolved Hide resolved
davidlion and others added 7 commits April 25, 2024 12:53
- fix typos
- update NamespaceIndentation to None
- add [[nodiscard]]
- typedef -> using
- add const
- use fancy auto syntax

Co-authored-by: Lin Zhihao <[email protected]>
- drop static cast

Co-authored-by: Lin Zhihao <[email protected]>
.github/workflows/build.yml Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/encoder.cpp Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

According to the cpp standard, for dependent names we need typename disambiguator to explicitly tell the compiler this is a type name: https://en.cppreference.com/w/cpp/language/dependent_name
Even though the code still gets compiled in some compilers without typename, it is a good practice to add it anyways.

cpp/src/ffi_go/ir/decoder.cpp Outdated Show resolved Hide resolved
cpp/src/ffi_go/ir/encoder.cpp Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Comments on ir/writer.go and ir/serializer.go

ir/serializer.go Show resolved Hide resolved
ir/serializer.go Outdated Show resolved Hide resolved
ir/serializer.go Outdated Show resolved Hide resolved
ir/writer.go Show resolved Hide resolved
ir/writer.go Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Comments on:

  • ir/ir.go
  • ir/decoder.go
  • ir/deserializer.go
  • search/wildcard_query.go

// streams through CLP's FFI (foreign function interface). More details on CLP
// IR streams are described in this [Uber blog].
// Log events in IR format can be viewed in the [log viewer] or programmatically
// analyzed using APIs provided in this package.
//
// [CLP]: https://github.com/y-scope/clp
// [Uber blog]: https://www.uber.com/blog/reducing-logging-cost-by-two-orders-of-magnitude-using-clp/
Copy link
Member

Choose a reason for hiding this comment

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

Technically this line exceeds 100 chars. If wrapping it into a new line doesn't break the doc site we should do it

ir/ir.go Outdated Show resolved Hide resolved
ir/ir.go Outdated Show resolved Hide resolved
ir/deserializer.go Outdated Show resolved Hide resolved
ir/deserializer.go Outdated Show resolved Hide resolved
ir/deserializer.go Outdated Show resolved Hide resolved
ir/deserializer.go Outdated Show resolved Hide resolved
ir/deserializer.go Show resolved Hide resolved
}

// A timestamp interval of [m_lower, m_upper).
type TimestampInterval struct {
Copy link
Member

Choose a reason for hiding this comment

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

Do we provide a way to create a default timestamp interval that covers the entire supported timestamp range?

Copy link
Member Author

Choose a reason for hiding this comment

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

This seems unnecessary as constructing the equivalent struct would also only be one line of code.

Copy link
Member

Choose a reason for hiding this comment

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

But do we have TS_MIN and TS_MAX defined?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why would these be different from int min/max?

Copy link
Member

Choose a reason for hiding this comment

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

we defined the timestamp type to EpochTimeMs instead of explicitly using int. It might not be obvious for users what underlying type it is. It also introduces problems if we change the underlying type in the future.

search/wildcard_query.go Outdated Show resolved Hide resolved
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Comments on ir/reader.go

ir/reader.go Outdated Show resolved Hide resolved
ir/reader.go Outdated Show resolved Hide resolved
ir/reader.go Outdated Show resolved Hide resolved
ir/reader.go Show resolved Hide resolved
LinZhihao-723 and others added 3 commits April 28, 2024 21:41
Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

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

Need a multi-line commit message like this PR: y-scope/clp#301

@davidlion
Copy link
Member Author

how about:

Add all CLP FFI functionality and refactor existing code: (#3)

  • Add CLP IR encoding/decoding
  • Add CLP IR wildcard query
  • Add basic GitHub templates and workflows
  • Rewrite CLP IR serialization/deserialization functionalities to match the latest CLP glossary, and simplify resource management
  • Add reader/writer interfaces for CLP IR
  • Provide pre-built static libraries

@LinZhihao-723 LinZhihao-723 changed the title Support all CLP encoding/decoding/searching FFI functionality and large scale refactor/rewrite Add support for all CLP FFI functionality and refactor existing code: May 10, 2024
@LinZhihao-723 LinZhihao-723 merged commit 238b9a9 into main May 10, 2024
8 checks passed
@davidlion davidlion deleted the beta branch May 10, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants