Skip to content

perf: monomorphic logevent #575

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

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

lukecotter
Copy link
Contributor

@lukecotter lukecotter commented Feb 21, 2025

Description

The goal of this PR is to improve Log Parser performance, primarily through ensuring objects are monomorphic which helps engines optimise especially in tight loops.

It will also address some other performance improvements and restructure the files e.g separate file for the types

Specifics

  • Do not define properties outside constructor e.g

dont

class Foo {
  bar = 1;
}

do

class Foo {
  constructor() {
    this.bar = 1;
  }
}
  • Consistent field assignment order
  • Use simple objects instead of classes where possible
  • Composition over inheritence
  • Use stream reader instead of fecth.data.text() when reading log
  • Optimise functions that navigate the tree

Type of change (check all applicable)

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • ⚡ Performance Improvement
  • 📝 Documentation
  • 🔧 Chore
  • 💥 Breaking change

[optional] Any images / gifs / video

Related Tickets & Documents

resolves #552
Related Issue #
fixes #
closes #

Added tests?

  • 👍 yes
  • 🙅 no, not needed
  • 🙋 no, I need help

Added to documentation?

  • 🔖 README.md
  • 🔖 CHANGELOG.md
  • 📖 help site
  • 🙅 not needed

[optional] Are there any post-deployment tasks we need to perform?

- Use a single while loop instead of 2 + removes len decrement
- Remove the need for Map to represent levels
Pipes the fetch repsonsse through TextDecoderStream.
We still read the full log content into memory but we do not block the main thread.

It also open up a migration to reading the log line by line
later instead of all into memory which will help with memory.
- ApexLogParser.ts - Main parser logic
- LogEvents.ts - All log event classes
- LogLineMapping.ts - Mapping of log event types to classes
- types.ts - Types and interfaces
@lcottercertinia
Copy link
Collaborator

Some changes have moved to #612.
Some of these and future changes in this PR are too risky this close to release.

@lcottercertinia lcottercertinia marked this pull request as draft May 2, 2025 10:42
@lukecotter lukecotter force-pushed the perf-monomorphic-logevent branch 2 times, most recently from 90a165b to 5fde7a1 Compare May 23, 2025 09:29
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.

perf: move to monomorphic object for the log parser
2 participants