Skip to content

perf(fs): Improve file metastore perfomance and correctness - #743

Open
rabbitstack wants to merge 6 commits into
masterfrom
file-metastore-perf-and-correctness
Open

rabbitstack wants to merge 6 commits into
masterfrom
file-metastore-perf-and-correctness

Conversation

@rabbitstack

Copy link
Copy Markdown
Owner

What is the purpose of this PR / why it is needed?

This pull request brings a batch of changes to speed up and improve the correctness of the file metadata store. Best reviewed commit by commit.

What type of change does this PR introduce?


Uncomment one or more /kind <> lines:

/kind feature (non-breaking change which adds functionality)

/kind bug-fix (non-breaking change which fixes an issue)

/kind refactor (non-breaking change that restructures the code, while not changing the original functionality)

/kind breaking (fix or feature that would cause existing functionality to not work as expected

/kind cleanup

/kind improvement

/kind design

/kind documentation

/kind other (change that doesn't pertain to any of the above categories)

Any specific area of the project related to this PR?


Uncomment one or more /area <> lines:

/area instrumentation

/area telemetry

/area rule-engine

/area filters

/area yara

/area event

/area captures

/area alertsenders

/area outputs

/area rules

/area filaments

/area config

/area cli

/area tests

/area ci

/area build

/area docs

/area deps

/area evasion

/area other

Special notes for the reviewer


Does this PR introduce a user-facing change?


Every lookup calls time.Now() and does an atomic store
on a shared cache line. Update only when the timestamp
is more than 1s stale.
Every caller that shares a flight runs AddFile,
fsMetadataCacheMisses.Add(1) and allocates its
own FileInfo. The count is inflated and the
stored pointer is replaced. There is also no
re-check inside the flight, so a flight that
just finished gets re-parsed.
Opens the file once and reads its first probeSize bytes.
If accept predicate is non-nil and returns an error, the
read stops there and that error is returned. Otherwise
the rest of the file is read, up to size bytes in total.

Cloud placeholders get hydrated. OneDrive and similar
files with RECALL_ON_OPEN or RECALL_ON_DATA_ACCESS
trigger a download when opened for read. That is a large
I/O cost for something that will never be loaded as a
module and they are skipped.
Comment thread pkg/fs/file.go
group singleflight.Group
stop chan struct{}
closeOnce sync.Once
group singleflight.Group

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reduce worker count.

This branch has not been deployed

No deployments
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