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

perf: Dependency files caching #129

Merged
merged 38 commits into from
Jun 8, 2021
Merged

perf: Dependency files caching #129

merged 38 commits into from
Jun 8, 2021

Conversation

michalbali256
Copy link
Contributor

Cache dependencies (macro and COPY files), so they are not parsed multiple times, if the user has not made any changes to them.

@michalbali256 michalbali256 marked this pull request as draft May 10, 2021 16:22
@michalbali256 michalbali256 marked this pull request as ready for review May 13, 2021 12:52
benchmark/benchmark.cpp Outdated Show resolved Hide resolved
benchmark/benchmark.cpp Outdated Show resolved Hide resolved
// structure represents invocation of COPY member in HLASM macro library
struct copy_member_invocation
{
const id_index name;
Copy link
Contributor

Choose a reason for hiding this comment

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

what was the reason to make these const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the only reason was that it is a structure and it does not make sense to change these members. Getter functions would be certainly better.

parser_library/src/workspaces/processor_file_impl.cpp Outdated Show resolved Hide resolved
for (const auto& [fname, cached_version] : cached_data.stamps)
{
auto file = file_mngr_->find(fname);
if (!file)
Copy link
Contributor

Choose a reason for hiding this comment

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

could we keep like weak_ptr to the file instead of file_manager ref and the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not, since file_manager creates new shared pointers to processor_files in the rare cases when the files are accessed concurrently. We need to access the newest version here.

Comment on lines +163 to +165
auto file = file_mngr_->find(copy_ptr->definition_location.file);
if (!file)
throw std::runtime_error("Dependencies of a macro must be open right after parsing the macro.");
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see that it could happen.. Should I remove the condition?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am again thinking about a race condition or something like that...


void macro_cache::erase_cache_of_opencode(const std::string opencode_file_name)
{
auto it = cache_.begin();
Copy link
Contributor

Choose a reason for hiding this comment

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

any concurrency concerns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the function is currently called from the workspace, which does not have any concurrent usage, as far as I know

parser_library/src/workspaces/macro_cache.h Outdated Show resolved Hide resolved
Comment on lines 75 to 77
, ACTR(&*ptr.emplace("ACTR").first)
, AREAD(&*ptr.emplace("AREAD").first)
, AGO(&*ptr.emplace("AGO").first)
Copy link
Contributor

Choose a reason for hiding this comment

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

to match the actual initialization order.

Suggested change
, ACTR(&*ptr.emplace("ACTR").first)
, AREAD(&*ptr.emplace("AREAD").first)
, AGO(&*ptr.emplace("AGO").first)
, AGO(&*ptr.emplace("AGO").first)
, ACTR(&*ptr.emplace("ACTR").first)
, AREAD(&*ptr.emplace("AREAD").first)

@sonarcloud
Copy link

sonarcloud bot commented Jun 7, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 11 Code Smells

95.5% 95.5% Coverage
0.0% 0.0% Duplication

@michalbali256 michalbali256 merged commit 2541b7a into development Jun 8, 2021
@michalbali256 michalbali256 deleted the mb/macro-caching branch June 8, 2021 12:07
@github-actions
Copy link

🎉 This PR is included in version 0.14.0-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 0.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

2 participants