Skip to content

Commit

Permalink
fix: no retries on sync lock
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Nov 15, 2023
1 parent c907c7d commit b7f5588
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/util/fileLocking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { dirname } from 'node:path';
import { lock, lockSync } from 'proper-lockfile';
import { SfError } from '../sfError';
import { Logger } from '../logger/logger';
import { lockRetryOptions } from './lockRetryOptions';
import { lockOptions, lockRetryOptions } from './lockRetryOptions';

type LockInitResponse = { writeAndUnlock: (data: string) => Promise<void>; unlock: () => Promise<void> };
type LockInitSyncResponse = { writeAndUnlock: (data: string) => void; unlock: () => void };
Expand Down Expand Up @@ -74,10 +74,10 @@ export const lockInitSync = (filePath: string): LockInitSyncResponse => {

const [unlock] = fs.existsSync(filePath)
? // if the file exists, wait for it to be unlocked
[lockSync(filePath, lockRetryOptions)]
[lockSync(filePath, lockOptions)]
: // lock the entire directory to keep others from trying to create the file while we are
[
lockSync(dirname(filePath), lockRetryOptions),
lockSync(dirname(filePath), lockOptions),
Logger.childFromRoot('fileLocking.lockInit').debug(
`No file found at ${filePath}. Write will create it. Locking the entire directory until file is written.`
),
Expand Down

3 comments on commit b7f5588

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: b7f5588 Previous: 25b3cf1 Ratio
Child logger creation 473291 ops/sec (±0.93%) 479149 ops/sec (±1.14%) 1.01
Logging a string on root logger 840314 ops/sec (±7.51%) 789128 ops/sec (±6.99%) 0.94
Logging an object on root logger 625241 ops/sec (±7.49%) 575668 ops/sec (±9.28%) 0.92
Logging an object with a message on root logger 4672 ops/sec (±227.87%) 10577 ops/sec (±201.13%) 2.26
Logging an object with a redacted prop on root logger 422583 ops/sec (±10.19%) 470328 ops/sec (±8.54%) 1.11
Logging a nested 3-level object on root logger 372532 ops/sec (±8.54%) 404392 ops/sec (±7.29%) 1.09

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Logger Benchmarks - ubuntu-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: b7f5588 Previous: 25b3cf1 Ratio
Logging an object with a message on root logger 4672 ops/sec (±227.87%) 10577 ops/sec (±201.13%) 2.26

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

Logger Benchmarks - windows-latest

Benchmark suite Current: b7f5588 Previous: 25b3cf1 Ratio
Child logger creation 325123 ops/sec (±0.64%) 345195 ops/sec (±0.47%) 1.06
Logging a string on root logger 728434 ops/sec (±4.58%) 820301 ops/sec (±5.81%) 1.13
Logging an object on root logger 569957 ops/sec (±5.90%) 642427 ops/sec (±5.39%) 1.13
Logging an object with a message on root logger 12705 ops/sec (±188.94%) 3646 ops/sec (±220.41%) 0.29
Logging an object with a redacted prop on root logger 500213 ops/sec (±4.85%) 462167 ops/sec (±7.87%) 0.92
Logging a nested 3-level object on root logger 346779 ops/sec (±6.65%) 331376 ops/sec (±5.16%) 0.96

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.