Skip to content

Conversation

@kakkoyun
Copy link
Member

feat(injector/typed): add interface-based type system with parser

  • Introduce Type interface for polymorphic type handling
  • Add support for pointer, slice, array, and map types
  • Implement recursive descent parser for type expressions
  • Rename TypeName to NamedType for clarity
  • Add helper functions NewNamedType and MustNamedType
  • Update all usage sites to use new type system

perf(injector/typed): remove regex-based parsing and document improvements

Replaced regex-based type parsing with recursive descent parser:

  • 71.53% faster overall (geometric mean)
  • 53.15% less memory usage
  • 29.26% fewer allocations

Benchmark results (old regex vs new parser):

  • Simple types: 5.21x faster, 87% less memory
  • Qualified types: 8.14x faster, 91% less memory
  • Pointer types: 5.89x faster, 89% less memory
  • Complex nested types: 7.89x faster, 92% less memory

All improvements statistically significant (p=0.008)

Signed-off-by: Kemal Akkoyun [email protected]

@kakkoyun
Copy link
Member Author

kakkoyun commented May 27, 2025

Copy link
Contributor

@RomainMuller RomainMuller left a comment

Choose a reason for hiding this comment

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

It really bothers me that it's unclear whether the types are conveyed by pointer or value... They need to be either, not both... The pointer derefs look odd and should be removed one way or the other IMHO.

@kakkoyun kakkoyun changed the base branch from 04-15-refactor_injector_refactor_typename_handling_and_migrate_to_typed_package to graphite-base/633 June 5, 2025 10:56
@kakkoyun kakkoyun force-pushed the graphite-base/633 branch from d2cdd1b to bbe2ed1 Compare June 5, 2025 11:00
@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch from a081e66 to 65b54f7 Compare June 5, 2025 11:00
@kakkoyun kakkoyun changed the base branch from graphite-base/633 to 04-15-refactor_injector_refactor_typename_handling_and_migrate_to_typed_package June 5, 2025 11:00
@kakkoyun kakkoyun requested a review from RomainMuller June 5, 2025 12:33
@kakkoyun kakkoyun force-pushed the 04-15-refactor_injector_refactor_typename_handling_and_migrate_to_typed_package branch from bbe2ed1 to d575c0b Compare June 5, 2025 14:25
@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch from 23bf3bc to b30a1ec Compare June 5, 2025 14:25
@kakkoyun kakkoyun force-pushed the 04-15-refactor_injector_refactor_typename_handling_and_migrate_to_typed_package branch from d575c0b to a59cbdb Compare June 5, 2025 16:27
@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch from b30a1ec to e7f3303 Compare June 5, 2025 16:27
Base automatically changed from 04-15-refactor_injector_refactor_typename_handling_and_migrate_to_typed_package to main June 5, 2025 17:21
@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch from e7f3303 to 0f39ff3 Compare June 5, 2025 17:27
@kakkoyun
Copy link
Member Author

kakkoyun commented Jun 5, 2025

/merge

@dd-devflow
Copy link

dd-devflow bot commented Jun 5, 2025

View all feedbacks in Devflow UI.

2025-06-05 18:20:30 UTC ℹ️ Start processing command /merge


2025-06-05 18:20:41 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-06-05 18:21:17 UTC ⚠️ MergeQueue: This merge request was unqueued

[email protected] unqueued this merge request

@kakkoyun
Copy link
Member Author

kakkoyun commented Jun 5, 2025

/remove

@dd-devflow
Copy link

dd-devflow bot commented Jun 5, 2025

View all feedbacks in Devflow UI.

2025-06-05 18:21:12 UTC ℹ️ Start processing command /remove


2025-06-05 18:21:14 UTC ℹ️ Devflow: /remove

@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch 5 times, most recently from 0f0aca9 to 7121fd0 Compare June 6, 2025 13:10
@kakkoyun kakkoyun marked this pull request as draft June 6, 2025 14:28
auto-merge was automatically disabled June 6, 2025 14:28

Pull request was converted to draft

@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch from 7121fd0 to b9416ed Compare September 11, 2025 15:48
@kakkoyun kakkoyun requested a review from Copilot September 11, 2025 15:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a comprehensive interface-based type system for the injector/typed package, replacing the previous TypeName struct with a polymorphic Type interface. The changes also include a new recursive descent parser that replaces regex-based parsing for improved performance and Unicode support.

Key changes:

  • Replace TypeName struct with Type interface supporting pointer, slice, array, and map types
  • Implement recursive descent parser with comprehensive Unicode support
  • Rename TypeName to NamedType for clarity and add helper functions

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/injector/typed/typename_test.go Removed - replaced by new type-specific test files
internal/injector/typed/typename.go Removed - functionality migrated to new type system files
internal/injector/typed/typed.go New utility functions for type extraction
internal/injector/typed/type_test.go Basic tests for new Type interface
internal/injector/typed/type.go Core Type interface definition with comprehensive documentation
internal/injector/typed/slice_test.go Comprehensive tests for slice type parsing and matching
internal/injector/typed/slice.go SliceType implementation
internal/injector/typed/pointer_test.go Tests for pointer type functionality
internal/injector/typed/pointer.go PointerType implementation
internal/injector/typed/parser.go New recursive descent parser with Unicode support
internal/injector/typed/parse_test.go Extensive parser tests including Unicode handling
internal/injector/typed/namedtype_test.go Tests for NamedType functionality
internal/injector/typed/namedtype.go NamedType implementation with backward compatibility
internal/injector/typed/map_test.go Tests for map type parsing and matching
internal/injector/typed/map.go MapType implementation
internal/injector/typed/array_test.go Tests for array type functionality
internal/injector/typed/array.go ArrayType implementation
internal/injector/aspect/join/struct.go Updated to use new type system
internal/injector/aspect/join/function_test.go Updated type references
internal/injector/aspect/join/function.go Updated to use NamedType pointers
internal/injector/aspect/join/declaration.go Updated type usage
internal/injector/aspect/advice/struct.go Updated to use new type system
internal/injector/aspect/advice/code/dot_function.go Updated type matching calls
internal/injector/aspect/advice/call_test.go Updated type references
internal/injector/aspect/advice/call.go Updated to use new type system

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch 2 times, most recently from d58b189 to b341ca5 Compare September 19, 2025 15:32
- Introduce Type interface for polymorphic type handling
- Add support for pointer, slice, array, and map types
- Implement recursive descent parser for type expressions
- Rename TypeName to NamedType for clarity
- Add helper functions NewNamedType and MustNamedType
- Update all usage sites to use new type system
Signed-off-by: Kemal Akkoyun <[email protected]>
@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch 2 times, most recently from a150f32 to 5375609 Compare September 23, 2025 15:37
@kakkoyun kakkoyun force-pushed the add-interface-based-type-system branch from 5375609 to 7b77e61 Compare September 23, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants