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

Refactoring and Performance Optimizations #598

Merged
merged 6 commits into from
Nov 14, 2024

Conversation

ckadluba
Copy link
Member

  • Refactoring and performance optimizations in batched and audit sink
  • Create perftest result on release
  • Updated issue template
  • Updated editorconfig
  • Added specific documentation about when SQL SELECT permission is not required

SELECT permissions are not required in all cases.
Upload performance test results as an artifact in release.yml
Refactoring
* Removed DataTableCreator from class MsSqlServerSink. Pushed it down to SqlBulkBatchWriter. This also made it possible to remove reference to System.Data in MsSqlServerSink.
* Removed DataTableCreator from SinkDependencies.
* Removed IBulkBatchWriter interface from SqlInsertStatementWriter. MSSqlServerSink class now has separate instances of ISqlBulkBatchWriter and ISqlLogEventWriter and chooses which one to use based on sink option `UseSqlBulkCopy`.
* Added new class SqlCommandFactory with interface ISqlCommandFactory

Performance optimizations in batched sink
* Generate schema and table string only once and do not use string.Format().
* Do not cast on each column of each log event.

Performance optimizations in audit sink
* Render INSERT string only once and not for each log event since it will not change between log events.
* Do not create a separate SqlCommand for each log event. Reuse the same and set only new SqlConnection, CommandText and parameters for each log event.

Added new tests and adapted existing ones.
@ckadluba ckadluba added this pull request to the merge queue Nov 14, 2024
Merged via the queue into serilog-mssql:dev with commit 71ca19a Nov 14, 2024
7 checks passed
@ckadluba ckadluba deleted the perf-refactor branch November 14, 2024 14:57
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.

1 participant